Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import pandas as pd
- from sklearn import svm
- from mlxtend.plotting import plot_decision_regions
- from sklearn.model_selection import train_test_split
- import matplotlib.pyplot as plt
- autism = pd.read_csv('10-features-uns.csv')
- X = autism.drop(['TARGET'], axis = 1)
- y = autism['TARGET']
- x_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.30, random_state=1)
- clf = svm.SVC(C=1.0, kernel='rbf', gamma=0.8)
- clf.fit(X_test.values, y_test.values)
- value=1.5
- width=0.75
- # Plot Decision Region using mlxtend's awesome plotting function
- plot_decision_regions(X=X_test.values,
- y=y_test.values,
- clf=clf,
- feature_index=[0,9],
- filler_feature_values={2: value, 3:value, 4:value},
- filler_feature_ranges={2: width, 3: width, 4: width},
- legend=2)
- # Update plot object with X/Y axis labels and Figure Title
- plt.xlabel(X_test.columns[0], size=14)
- plt.ylabel(X_test.columns[1], size=14)
- plt.title('SVM Decision Region Boundary', size=16)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement