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]:
feature1 feature2 target
0 1 1 1
1 1 0 0
2 0 1 0
3 0 0 0

In [63]:
X = dataset.values[:,:2]
Y = dataset['target'].values

In [64]:
model = LinearSVC().fit(X,Y)
model


Out[64]:
LinearSVC(C=1.0, class_weight=None, dual=True, fit_intercept=True,
     intercept_scaling=1, loss='squared_hinge', max_iter=1000,
     multi_class='ovr', penalty='l2', random_state=None, tol=0.0001,
     verbose=0)

In [65]:
score = model.score(X,Y)
print('Score com dados de teste: ', score)


Score com dados de teste:  1.0

In [69]:
print('Valor previsto: ', model.predict([[1,1]])[0])


Valor previsto:  1

In [74]:
plot_decision_regions(X, Y, clf=model)
plt.xlabel('features')
plt.ylabel('target')
plt.title('AND')
plt.show()