Python-SKlearn

Scikit-learn Introduction

sklearn.linear_model.Perceptron

Usage:

from sklearn.linear_model import Perceptron
pct=Perceptron(max_iter=10,eta0=0.1,random_state=0)#iterative, speed of learning, random resort of training data
pct.fit(X_train, y_train)

y_pred=pct.predict(X_test)

# Estimate Ein / Eout error of our model:
from sklearn.metrics import accuracy_score
pct.score(X_train,y_train)
print ('Accuracy:%.2f' %accuracy_score(y_test,y_pred))

https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.Perceptron.html
Example of Perceptron:
https://scikit-learn.org/stable/auto_examples/applications/plot_out_of_core_classification.html#sphx-glr-auto-examples-applications-plot-out-of-core-classification-py

sklearn.metrics.accuracy_score

This function computes subset accuracy: the set of labels predicted for a sample must exactly match the corresponding set of labels in y_true.

from sklearn.metrics import accuracy_score
y_pred = [0, 2, 1, 3]
y_true = [0, 1, 2, 3]
accuracy_score(y_true, y_pred)
>> 0.5
accuracy_score(y_true, y_pred, normalize=False)
>> 2

https://scikit-learn.org/stable/modules/generated/sklearn.metrics.accuracy_score.html