I am trying to plot SVM decision boundary which separates two classes, cancerous and non-cancerous. However, it's displaying a plot which is far from what I wanted. I wanted it to look like this:
or anything that shows the points are scattered. Here's my code:
import numpy as np
import pandas as pd
from sklearn import svm
from mlxtend.plotting import plot_decision_regions
import matplotlib.pyplot as plt
autism = pd.read_csv('predictions.csv')
# Fit Support Vector Machine Classifier
X = autism[['TARGET','Predictions']]
y = autism['Predictions']
clf = svm.SVC(C=1.0, kernel='rbf', gamma=0.8)
clf.fit(X.values, y.values)
# Plot Decision Region using mlxtend's awesome plotting function
plot_decision_regions(X=X.values,
y=y.values,
clf=clf,
legend=2)
# Update plot object with X/Y axis labels and Figure Title
plt.xlabel(X.columns[0], size=14)
plt.ylabel(X.columns[1], size=14)
plt.title('SVM Decision Region Boundary', size=16)
plt.show()
But I got a weird looking plot:
You can find the csv file here predictions.csv
predictions.csv
) because I couldn't work out with the one in my repo. But i will have a try if you could just answer my question in the comment? – Falady