Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. import numpy as np
  2. import pandas as pd
  3. from sklearn import svm
  4. from mlxtend.plotting import plot_decision_regions
  5. from sklearn.model_selection import train_test_split
  6. import matplotlib.pyplot as plt
  7.  
  8. autism = pd.read_csv('10-features-uns.csv')
  9.  
  10. X = autism.drop(['TARGET'], axis = 1)
  11. y = autism['TARGET']
  12. x_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.30, random_state=1)
  13.  
  14. clf = svm.SVC(C=1.0, kernel='rbf', gamma=0.8)
  15. clf.fit(X_test.values, y_test.values)
  16.  
  17. value=1.5
  18. width=0.75
  19.  
  20. # Plot Decision Region using mlxtend's awesome plotting function
  21. plot_decision_regions(X=X_test.values,
  22. y=y_test.values,
  23. clf=clf,
  24. feature_index=[0,9],
  25. filler_feature_values={2: value, 3:value, 4:value},
  26. filler_feature_ranges={2: width, 3: width, 4: width},
  27. legend=2)
  28.  
  29. # Update plot object with X/Y axis labels and Figure Title
  30. plt.xlabel(X_test.columns[0], size=14)
  31. plt.ylabel(X_test.columns[1], size=14)
  32. plt.title('SVM Decision Region Boundary', size=16)
  33. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement