MCPcopy Create free account
hub / github.com/Giyn/DataMiningVisualizationSystem / confuse_matrix

Method confuse_matrix

model_assessment/clf.py:28–39  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

26 self.y_predict = a
27
28 def confuse_matrix(self):
29 # 计算混淆矩阵
30 TP, FP, TN, FN = 0,0,0,0
31 for i in range(len(self.y_predict)):
32 if self.y_predict[i] == self.y_test[i]:
33 if self.y_predict[i] == 1: TP += 1
34 else: TN += 1
35 elif self.y_predict[i] == 1 and self.y_test[i] == 0:
36 FP += 1
37 elif self.y_predict[i] == 0 and self.y_test[i] == 1:
38 FN += 1
39 self.TP, self.FP, self.TN, self.FN = TP, FP, TN, FN
40
41 def print_matrix(self, filename, view=False):
42 """简单绘制混淆矩阵

Callers 3

__init__Method · 0.95
paint_PRMethod · 0.95
paint_ROCMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected