Accuracy in Machine Learning

import numpy as np

import pandas as pd

from sklearn import tree

features = [[140, 1], [130, 1], [135, 1], [145, 1], [150, 2], [160, 2], [170, 2], [165, 2]]

labels = [1, 1, 1, 1, 2, 2, 2, 2]

clf = tree.DecisionTreeClassifier()

clf = clf.fit(features, labels)

clf.predict([[150, 2]])

from sklearn.metrics import accuracy_score

y_pred=[1,1,2,1,2,1,2,1,1,1,2]

y_true=[1,1,2,1,2,1,2,1,1,2,1]

accuracy_score(y_pred,y_true)

Result: 0.8181818181818182

Leave a Reply

Your email address will not be published. Required fields are marked *