MCPcopy Create free account
hub / github.com/apachecn/ailearning / show_precision_recall

Function show_precision_recall

src/python/3.DecisionTree/DTSklearn.py:55–76  ·  view source on GitHub ↗

准确率与召回率 参考链接: http://scikit-learn.org/stable/modules/generated/sklearn.metrics.precision_recall_curve.html#sklearn.metrics.precision_recall_curve

(x, y, clf,  y_train, y_pre)

Source from the content-addressed store, hash-verified

53
54
55def show_precision_recall(x, y, clf, y_train, y_pre):
56 '''
57 准确率与召回率
58 参考链接: http://scikit-learn.org/stable/modules/generated/sklearn.metrics.precision_recall_curve.html#sklearn.metrics.precision_recall_curve
59 '''
60 precision, recall, thresholds = precision_recall_curve(y_train, y_pre)
61 # 计算全量的预估结果
62 answer = clf.predict_proba(x)[:, 1]
63
64 '''
65 展现 准确率与召回率
66 precision 准确率
67 recall 召回率
68 f1-score 准确率和召回率的一个综合得分
69 support 参与比较的数量
70 参考链接:http://scikit-learn.org/stable/modules/generated/sklearn.metrics.classification_report.html#sklearn.metrics.classification_report
71 '''
72 # target_names 以 y的label分类为准
73 target_names = ['thin', 'fat']
74 print(classification_report(y, answer, target_names=target_names))
75 print(answer)
76 print(y)
77
78
79def show_pdf(clf):

Callers 1

DTSklearn.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected