# Chapter 3.pdf - Chapter 3 MACHINE LEARNING CLASSIFIERS...

• 63

Course Hero uses AI to attempt to automatically extract content from documents to surface to you and others so you can study better, e.g., in search results, to enrich docs, and more. This preview shows page 1 - 8 out of 63 pages.

Chapter 3MACHINE LEARNING CLASSIFIERS USINGSCIKIT-LEARNSanjay Kumar C KSANJAY KUMAR C K
ObjectivesAn introduction to robust and popular algorithms for classification, suchas logistic regression, support vector machines, and decision treesExamples and explanations using the scikit-learn machine learning library,which provides a wide variety of machine learning algorithms via a user-friendly Python APIDiscussions about the strengths and weaknesses of classifiers with linearand nonlinear decision boundariesSANJAY KUMAR C K
Choosing a classificationalgorithmIt is recommended that we compare the performance of at least a handful of different learning algorithmsto select the best model for the particular problem; these may differ inthe number of featuresorexamples,the amount of noisein a dataset, and whether the classes arelinearly separable or not.The performance of a classifier (computational performance as well as predictive power) depends on thedata available for learning.The five main steps in training a supervised machine learning algorithm are:1.Selecting features and collecting labeled training examples.2.Choosing a performance metric.3.Choosing a classifier and optimization algorithm.4.Evaluating the performance of the model.5.Tuning the algorithm.SANJAY KUMAR C K
Scikit-learn – training aperceptronfrom sklearn import datasetsimport numpy as npiris=datasets.load_iris()print (iris)X = iris.data[:, [2, 3]]y = iris.targetfrom sklearn.model_selection import train_test_splitX_train, X_test, y_train, y_test = train_test_split(X, y,test_size=0.3, random_state=1, stratify=y)from sklearn.preprocessing import StandardScalersc = StandardScaler()sc.fit(X_train)X_train_std = sc.transform(X_train)X_test_std = sc.transform(X_test)from sklearn.linear_model import Perceptronppn = Perceptron(eta0=0.1, random_state=1)ppn.fit(X_train_std, y_train)y_pred = ppn.predict(X_test_std)print('\nMisclassified examples: %d' % (y_test !=y_pred).sum())from sklearn.metrics import accuracy_scoreprint('Accuracy: %.3f' % accuracy_score(y_test, y_pred))SANJAY KUMAR C K
SANJAY KUMAR C K
Modeling Class probabilities usingLogistic Regressionlogistic regression is a probabilistic model for binaryclassificationwhenpstands for the probability of the positive event,we define odds as:We can then further define thelogitfunction, which issimply the logarithm of the odds (log-odds):We define the conditional probability, p(y=1|x)that a particular example belongs to class 1 given its features,x.we are interested in predicting the probability that a certain example belongs to a particular class, which is the inverseform of the logit function, called thelogistic sigmoid function.SANJAY KUMAR C K
Logistic Regressionsigmoid function:Here,zis the net input, the linear combination of weights, andthe inputsSANJAY KUMAR C K

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 63 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Spring
Professor
N/A
Tags
Statistical classification, Sanjay Kumar C K