July 2017
Beginner to intermediate
442 pages
10h 8m
English
A polynomial kernel with degree of 2 has been used in the following code to check whether any improvement in accuracy is possible. The cost value has been kept constant with respect to the linear classifier in order to determine the impact of the non-linear kernel:
#Polynomial Kernel>>> svm_poly_fit = SVC(kernel='poly',C=1.0,degree=2)>>> svm_poly_fit.fit(x_train,y_train)>>> print ("\nSVM Polynomial Kernel Classifier - Train Confusion Matrix\n\n",pd.crosstab(y_train,svm_poly_fit.predict(x_train),rownames = ["Actuall"],colnames = ["Predicted"]) )>>> print ("\nSVM Polynomial Kernel Classifier - Train accuracy:",round(accuracy_score( y_train,svm_poly_fit.predict(x_train)),3))>>> print ("\nSVM Polynomial Kernel Classifier - ...Read now
Unlock full access