Skip to Content
Statistics for Machine Learning
book

Statistics for Machine Learning

by Pratap Dangeti
July 2017
Beginner to intermediate
442 pages
10h 8m
English
Packt Publishing
Content preview from Statistics for Machine Learning

Maximum margin classifier - linear kernel

The following code shows a linear classifier (also known as a maximum margin classifier) with cost value as 1.0:

>>> svm_fit = SVC(kernel='linear',C=1.0,random_state=43) 
>>> svm_fit.fit(x_train,y_train) 
 
>>> print ("\nSVM Linear Classifier - Train Confusion Matrix\n\n",pd.crosstab(y_train, svm_fit.predict(x_train),rownames = ["Actuall"],colnames = ["Predicted"]) )      
>>> print ("\nSVM Linear Classifier - Train accuracy:",round(accuracy_score(y_train, svm_fit.predict(x_train)),3)) 
>>> print ("\nSVM Linear Classifier - Train Classification Report\n", classification_report(y_train,svm_fit.predict(x_train))) 

Following code used for printing the test accuracy values:

>>> print ("\n\nSVM Linear Classifier ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Probability and Statistics for Machine Learning

Probability and Statistics for Machine Learning

Jon Krohn

Publisher Resources

ISBN: 9781788295758Supplemental Content