Non-Linear SVC Sklearn - Training a SVM Classification Model With RBF Kernel

Python

 1|  from sklearn.svm import SVC
 2|  from sklearn.metrics import classification_report
 3|  
 4|  # create an SVC model with an rbf kernel and balanced class weights
 5|  model = SVC(C=1, kernel='rbf', class_weight='balanced')
 6|  
 7|  # fit model
 8|  model.fit(X_train, y_train)
 9|  
10|  # make prediction on test data
11|  y_pred = model.predict(X_test)
12|  
13|  # print classification report
14|  print(classification_report(y_test, y_pred))
Did you find this snippet useful?

Sign up for free to to add this to your code library