$\tt{Accuracy} = \frac{correct}{samples}$
In [24]:
from sklearn import datasets, neighbors, metrics
import pandas as pd
%matplotlib inline
In [6]:
iris = datasets.load_iris()
In [8]:
irisdf = pd.DataFrame(iris.data, columns=iris.feature_names)
irisdf.head(4)
Out[8]:
In [9]:
irisdf["target"] = iris.target
In [10]:
irisdf.head(4)
Out[10]:
In [12]:
cmap = {"0": "r", "1": "g", "2": "b"}
In [13]:
irisdf["ctarget"] = irisdf.target.apply(lambda x: cmap[str(x)])
In [14]:
irisdf.head(6)
Out[14]:
In [17]:
irisdf.plot('petal length (cm)', 'petal width (cm)', kind='scatter', c=irisdf.ctarget)
Out[17]:
In [19]:
print(irisdf.describe())
In [25]:
def my_classifier(row):
if row["petal length (cm)"] < 2:
return 0
else:
return 1
irisdf['predictions_1'] = irisdf.apply(my_classifier, axis=1)
In [26]:
irisdf.head(6)
Out[26]:
In [ ]: