(self)
| 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 | """简单绘制混淆矩阵 |