第1关:为什么要有训练集与测试集
1、D
2、A
第2关:欠拟合与过拟合
1、B
2、ABD
第3关:偏差与方差
1、B
第4关:验证集与交叉验证
1、D
2、BCD
第5关:衡量回归的性能指标
1、AB
第6关:准确度的陷阱与混淆矩阵
import numpy as np
def confusion_matrix(y_true, y_predict):
'''
构建二分类的混淆矩阵,并将其返回
:param y_true: 真实类别,类型为ndarray
:param y_predict: 预测类别,类型为ndarray
:return: shape为(2, 2)的ndarray
'''
def TN(y_true, y_predict):
return np.sum((y_true == 0) & (y_predict == 0))
def FP(y_true, y_predict):
return np.sum((y_true == 0) & (y_predict == 1))
def FN(y_true, y_predict):
return np.sum((y_true == 1) & (y_predict == 0))
def TP(y_true, y_predict):