Timothy Helton
These exercises use pictures of famous people collected over the internet. Scikit-Learn Reference
NOTE:
This notebook uses code found in the
k2datascience.classification module.
To execute all the cells do one of the following items:
In [ ]:
from k2datascience import classification
from k2datascience import plotting
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
%matplotlib inline
In [ ]:
wf = classification.WildFaces(n_faces=70)
wf.data.shape
In [ ]:
wf.faces_plot()
In [ ]:
wf.targets_barplot()
In [ ]:
wf.calc_pca()
wf.var_pct[wf.var_pct.cumsum() < .99].tail(1).index[0]
In [ ]:
wf.avg_face_plot()
In [ ]:
wf.components_plot()
In [ ]:
wf.classify_data(model='LR')
print(wf.score)
print(wf.log_loss)
wf.confusion
print(wf.classification)
In [ ]:
wf.accuracy_vs_k()
In [ ]:
wf.classify_data(model='KNN', n=9)
print(wf.score)
print(wf.log_loss)
wf.confusion
print(wf.classification)
In [ ]:
wf.classify_data(model='LDA')
print(wf.score)
print(wf.log_loss)
wf.confusion
print(wf.classification)
In [ ]:
wf.classify_data(model='NB')
print(wf.score)
print(wf.log_loss)
wf.confusion
print(wf.classification)
In [ ]:
wf.classify_data(model='QDA')
print(wf.score)
print(wf.log_loss)
wf.confusion
print(wf.classification)
The linear models more accurately describe this dataset.
In [ ]:
In [ ]:
plotting.confusion_heatmap_plot(wf.confusion, wf.target_names,
title='Labeled Faces in the Wild')
In [ ]: