Dealing with the nonlinearly separable case using slack variables

来源:互联网 发布:电脑喊麦用什么软件 编辑:程序博客网 时间:2024/05/22 15:51

1. Train a SVM model :

from sklearn.svm import SVCsvm = SVC(kernel='linear', C=1.0, random_state=0)svm.fit(X_train_std, y_train)plot_decision_regions(X_combined_std, y_combined, classifier=svm, test_idx=range(105, 150))

2.  Showing :

plt.xlabel('petal length [standardized]')plt.ylabel('petal width [standardized]')plt.legend(loc='upper left')plt.show()

3. Results:



Reference: 《Python Machine Learning》


0 0
原创粉丝点击