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.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这行代码通常用于在OpenCV中检测人脸。它使用了一个名为“faces”的列表来存储检测到的人脸的坐标信息,包括每个人脸的左上角坐标(x和y)以及人脸的宽度和高度(w和h)。 当使用OpenCV中的人脸检测器时,它通常会返回一个包含每个检测到的人脸坐标信息的列表。这个列表通常被命名为“faces”,并且可以通过for循环来遍历每个人脸的坐标信息。 在这个例子中,for循环使用了一个“元组解包”的技巧,将每个人脸的坐标信息解包到四个变量(x、y、w和h)中。在每次迭代中,这些变量将包含一个人脸的左上角坐标以及人脸的宽度和高度。 您可以使用这些坐标信息来在图像中绘制矩形,以突出显示检测到的人脸,例如: ``` import cv2 # 加载图像并将其转换为灰度格式 image = cv2.imread('your_image.jpg') gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) # 加载人脸检测器并检测人脸 face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml') faces = face_cascade.detectMultiScale(gray, scaleFactor=1.3, minNeighbors=5) # 在图像中绘制矩形以突出显示检测到的人脸 for (x, y, w, h) in faces: cv2.rectangle(image, (x, y), (x + w, y + h), (0, 255, 0), 2) # 显示结果图像 cv2.imshow('Detected Faces', image) cv2.waitKey(0) cv2.destroyAllWindows() ``` 在这个例子中,我们加载了一张图像并将其转换为灰度格式。然后,我们使用OpenCV的人脸检测器来检测人脸,并将每个检测到的人脸的坐标信息存储在一个名为“faces”的列表中。最后,我们使用一个for循环遍历每个人脸的坐标信息,并在图像中绘制矩形以突出显示检测到的人脸。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值