An example in sklearn: Faces recognition example using eigenfaces and SVMs

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

Some basic concept:

Precision&Recall:

通俗的讲,Precision 就是检索出来的条目中(比如网页)有多少是准确的,Recall就是所有准确的条目有多少被检索出来了。

http://en.wikipedia.org/wiki/Precision_and_recall

http://blog.csdn.net/wangran51/article/details/7579100

Accuracy&Precision

the accuracy is the proportion of true results (bothtrue positives and true negatives) in the population.

precision or positive predictive value is defined as the proportion of the true positives against all the positive results (both true positives andfalse positives)

http://en.wikipedia.org/wiki/Accuracy_and_precision

F1 score:

F Measure是Precision和Recall加权调和平均:

F = (a^2+1)P*R / a^2P +R

当参数a=1时,就是最常见的F1了:

F1 = 2P*R / (P+R)

很容易理解,F1综合了PR的结果。

Confusion Matrix:

inunsupervised learning it is usually called a matching matrix

http://en.wikipedia.org/wiki/Confusion_matrix


Tools:

sklearn.metrics.classification_report(y_true,y_pred, labels=None, target_names=None, sample_weight=None)

http://scikit-learn.org/stable/modules/generated/sklearn.metrics.classification_report.html#sklearn.metrics.classification_report

>>> from sklearn.metrics import classification_report
>>> y_true = [0, 1, 2, 2, 2]
>>> y_pred = [0, 0, 2, 2, 1]
>>> target_names = ['class 0', 'class 1', 'class 2']
>>> print(classification_report(y_true, y_pred, target_names=target_names))
             precision    recall  f1-score   support

    class 0       0.50      1.00      0.67         1
    class 1       0.00      0.00      0.00         1
    class 2       1.00      0.67      0.80         3

avg / total       0.70      0.60      0.61         5
sklearn.metrics.confusion_matrix(y_true,y_pred, labels=None)

>>> from sklearn.metrics import confusion_matrix
>>> y_true = [2, 0, 2, 2, 0, 1]
>>> y_pred = [0, 0, 2, 2, 0, 2]
>>> confusion_matrix(y_true, y_pred)
array([[2, 0, 0],
       [0, 0, 1],
       [1, 0, 2]])
class sklearn.decomposition.RandomizedPCA(n_components=None,copy=True, iterated_power=3, whiten=False, random_state=None)

Principal component analysis (PCA) using randomized SVD

Linear dimensionality reduction using approximated Singular ValueDecomposition of the data and keeping only the most significantsingular vectors to project the data to a lower dimensional space.


你可能感兴趣的:(scikit-learn)