监督学习算法模型评估实例(sklearn版)
sklearn机器学习包中的模型评估指标都在包 sklearn.metrics 下; 链接地址:https://scikit-learn.org/stable/modules/classes.html?highlight=metrics#module-sklearn.metrics 这里我们选择几个常用的指标进行展示,sklearn的版本为0.22.1。 混淆矩阵(confusion_matrix) 函数原型为: sklearn . metrics . confusion_matrix ( y_true , y_pred , labels = None , sample_weight = None , normalize = None ) 详情链接:https://scikit-learn.org/stable/modules/generated/sklearn.metrics.confusion_matrix.html#sklearn.metrics.confusion_matrix Examples >> > from sklearn . metrics import confusion_matrix >> > y_true = [ 2 , 0 , 2 , 2 , 0 , 1 ] >> > y_pred = [ 0 , 0 , 2 , 2 , 0 , 2 ] >> >