In [10]:
%run eigenfaces.py


===================================================
Faces recognition example using eigenfaces and SVMs
===================================================

The dataset used in this example is a preprocessed excerpt of the
"Labeled Faces in the Wild", aka LFW_:

  http://vis-www.cs.umass.edu/lfw/lfw-funneled.tgz (233MB)

  .. _LFW: http://vis-www.cs.umass.edu/lfw/

  original source: http://scikit-learn.org/stable/auto_examples/applications/face_recognition.html


Total dataset size:
n_samples: 1217
n_features: 1850
n_classes: 6
Extracting the top 100 eigenfaces from 912 faces
/Users/sunnyamrat/anaconda/envs/python2/lib/python2.7/site-packages/sklearn/utils/deprecation.py:57: DeprecationWarning: Class RandomizedPCA is deprecated; RandomizedPCA was deprecated in 0.18 and will be removed in 0.20. Use PCA(svd_solver='randomized') instead. The new implementation DOES NOT store whiten ``components_``. Apply transform to get them.
  warnings.warn(msg, category=DeprecationWarning)
done in 0.426s
Projecting the input data on the eigenfaces orthonormal basis
done in 0.037s
Fitting the classifier to the training set
done in 9.693s
Best estimator found by grid search:
SVC(C=1000.0, cache_size=200, class_weight='balanced', coef0=0.0,
  decision_function_shape='ovr', degree=3, gamma=0.005, kernel='rbf',
  max_iter=-1, probability=False, random_state=None, shrinking=True,
  tol=0.001, verbose=False)
Predicting the people names on the testing set
done in 0.030s
                   precision    recall  f1-score   support

     Ariel Sharon       0.71      0.71      0.71        14
     Colin Powell       0.93      0.77      0.84        65
  Donald Rumsfeld       0.83      0.73      0.77        33
    George W Bush       0.85      0.95      0.90       133
Gerhard Schroeder       0.78      0.78      0.78        23
       Tony Blair       0.78      0.76      0.77        37

      avg / total       0.84      0.84      0.84       305

[[ 10   0   2   2   0   0]
 [  0  50   0  10   1   4]
 [  1   1  24   4   1   2]
 [  3   2   1 127   0   0]
 [  0   0   1   2  18   2]
 [  0   1   1   4   3  28]]

Ratios of each PCA component relative to the others


In [5]:
pca.explained_variance_ratio_


Out[5]:
array([ 0.17562418,  0.15863183,  0.07318624,  0.06090244,  0.05172847,
        0.0316058 ,  0.02576042,  0.02138092,  0.02082747,  0.0194815 ,
        0.01633405,  0.01437654,  0.01234267,  0.0112105 ,  0.01047355,
        0.01003144,  0.00935481,  0.00880119,  0.00819125,  0.00757657,
        0.00696915,  0.00683099,  0.00645418,  0.00609689,  0.00553001,
        0.00538431,  0.00521731,  0.00491459,  0.00469905,  0.00441257,
        0.00404327,  0.00383702,  0.00376177,  0.00361683,  0.00358959,
        0.00343653,  0.00331045,  0.00310248,  0.00301165,  0.00280813,
        0.00276719,  0.00272816,  0.00264804,  0.00258614,  0.00250417,
        0.00243213,  0.00235727,  0.00232123,  0.00222529,  0.0021248 ,
        0.0021146 ,  0.00205831,  0.00199117,  0.00197045,  0.00187473,
        0.00184511,  0.00180552,  0.00177763,  0.00175003,  0.00166362,
        0.00163889,  0.00161587,  0.00157866,  0.00156959,  0.00153282,
        0.00151667,  0.00147544,  0.00144853,  0.00142013,  0.0013877 ,
        0.00136784,  0.0013104 ,  0.00129731,  0.0012532 ,  0.00122244,
        0.00121657,  0.00119694,  0.00117878,  0.00116962,  0.00114623,
        0.00112683,  0.00109808,  0.00109337,  0.00105846,  0.00104187,
        0.00102965,  0.0010181 ,  0.00099596,  0.00098029,  0.00094678,
        0.00093468,  0.00092692,  0.00090256,  0.00088927,  0.00086973,
        0.00086564,  0.00084274,  0.00083641,  0.00083094,  0.00079854,
        0.00078971,  0.0007705 ,  0.00076833,  0.00076416,  0.00074155,
        0.00073675,  0.00072124,  0.00071367,  0.00070566,  0.00068145,
        0.00067251,  0.00066795,  0.00064503,  0.00064071,  0.00063043,
        0.00061432,  0.00060438,  0.00059771,  0.00058392,  0.00057237,
        0.00055722,  0.0005535 ,  0.00054122,  0.00053294,  0.0005293 ,
        0.00052532,  0.00051487,  0.00050572,  0.00049208,  0.00048643,
        0.00047371,  0.00046086,  0.00045867,  0.00043907,  0.00043084,
        0.00042527,  0.00042185,  0.00041094,  0.00040895,  0.00039905,
        0.00038855,  0.00038131,  0.00037785,  0.00037223,  0.00036779,
        0.00035716,  0.00035149,  0.0003435 ,  0.00033495,  0.00032464], dtype=float32)

In [9]:
len(pca.explained_variance_ratio_)


Out[9]:
150

In [ ]: