Advertisement
mhdew

RBF kernel SVM

Sep 25th, 2020
992
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. from sklearn.datasets import load_breast_cancer
  2. cancer = load_breast_cancer()
  3. (X_cancer, y_cancer) = load_breast_cancer(return_X_y = True)
  4. from sklearn.model_selection import train_test_split
  5.  
  6. from sklearn.svm import SVC
  7. X_train, X_test, y_train, y_test = train_test_split(X_cancer, y_cancer,
  8.                                                    random_state = 0)
  9.  
  10. clf = SVC(C=10).fit(X_train, y_train)
  11. print('Breast cancer dataset (unnormalized features)')
  12. print('Accuracy of RBF-kernel SVC on training set: {:.2f}'
  13.      .format(clf.score(X_train, y_train)))
  14. print('Accuracy of RBF-kernel SVC on test set: {:.2f}'
  15.      .format(clf.score(X_test, y_test)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement