In [28]:
import numpy
import pandas
import json
In [32]:
# Load the data from file, make it into a pretty pandas Dataframe
data = pandas.read_json('samples/target.json').T
data['name'] = data.index
data.reset_index(inplace=True, drop=True) # reset index to numbers, drop extra index column
data.head()
Out[32]:
In [33]:
# Getting an idea of how the data is distributed
data['class'].value_counts()
Out[33]:
In [34]:
from roofcam.classifier import classify_wet_or_dry
data['prediction'] = data.apply(lambda row: classify_wet_or_dry("samples/" + row['name']), axis=1)
data.head()
Out[34]:
In [35]:
data['prediction'].value_counts()
Out[35]:
In [84]:
# Drop error rows, we're not that interested in them (errors are caused by faulty images)
data = data[data['prediction'] != "ERROR"]
# Drop NIGHT rows
# data = data[data['prediction'] != "NIGHT"]
# data = data[data['class'] != "NIGHT"]
In [85]:
correct = len(data[data['prediction'] == data['class']])
correct_percent = float(correct)/len(data) * 100
print "TOTAL", len(data)
print "CORRECT", correct, "({0:0.0f}%)".format(correct_percent)
print "INCORRECT", len(data) - correct, "({0:0.0f}%)".format(100 - correct_percent)
In [86]:
from pandas_ml import ConfusionMatrix
y_true=data['class']
y_pred=data['prediction']
confusion_matrix = ConfusionMatrix(y_true, y_pred)
print("Confusion matrix:\n%s" % confusion_matrix)
In [87]:
%matplotlib inline
import matplotlib.pyplot as plt
confusion_matrix.plot()
Out[87]:
In [ ]: