In [1]:
import pandas as pd
import matplotlib.pyplot as plt
from mlxtend.plotting import plot_decision_regions
from sklearn.svm import SVC
%matplotlib inline
In [2]:
dataset = pd.DataFrame([[1,1,0], [1,0,1], [0,1,1], [0,0,0]], columns=['feature1', 'feature1', 'target'])
In [3]:
dataset
Out[3]:
In [4]:
X = dataset.values[:,:2]
Y = dataset['target'].values
In [5]:
model = SVC(kernel='rbf').fit(X,Y)
model
Out[5]:
In [6]:
score = model.score(X,Y)
print('Score com dados de teste: ', score)
In [7]:
model.predict([[0,0]])
Out[7]:
In [9]:
plot_decision_regions(X, Y, clf=model)
plt.xlabel('features')
plt.ylabel('target')
plt.title('XOR')
plt.show()