In [60]:
import pandas as pd
import matplotlib.pyplot as plt
from mlxtend.plotting import plot_decision_regions
from sklearn.svm import LinearSVC
%matplotlib inline
In [61]:
dataset = pd.DataFrame([[1,1,1], [1,0,0], [0,1,0], [0,0,0]], columns=['feature1', 'feature2', 'target'])
In [62]:
dataset
Out[62]:
In [63]:
X = dataset.values[:,:2]
Y = dataset['target'].values
In [64]:
model = LinearSVC().fit(X,Y)
model
Out[64]:
In [65]:
score = model.score(X,Y)
print('Score com dados de teste: ', score)
In [69]:
print('Valor previsto: ', model.predict([[1,1]])[0])
In [74]:
plot_decision_regions(X, Y, clf=model)
plt.xlabel('features')
plt.ylabel('target')
plt.title('AND')
plt.show()