一.sklearn评估
1.混淆矩阵
from sklearn.metrics import confusion_matrix
confusion_matrix(testLabel,pre_label)
2.大小类评估指标:精确率,召回率,f1得分
from sklearn.metrics import classification_report
classification_report(testLabel, pre_label)
3.交叉验证
mode = GradientBoostingClassifier()
cross_val_score(mode, feaSet, inLabel, cv = 10, scoring = 'accuracy')
二.matplot 绘图
1.设置坐标轴标注
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.bar(x, befor, width=width, label='befor',color='b')
2.设置要显示的坐标轴坐标
ax.set_xticks([1,2,3,4,5])
#设置对应坐标的显示文字,rotation为文字的顺时针旋转角度,fontsize为文字大小
ax.set_xticklabels(['one','two','three','four','five'],rotation=45,fontsize=12)
plt.show()
3.设置图标标注
#loc表示位置
plt.legend(loc='lower right')
4.设置坐标轴的显示范围
plt.xlim(0.5, 5.5)
plt.ylim(0.5, 1.0)
5.在图中显示文字标注
#三个参数分别为x,y,要显示的内容
plt.text(xloc,yloc,str)
6.美化风格
1.混淆矩阵
from sklearn.metrics import confusion_matrix
confusion_matrix(testLabel,pre_label)
2.大小类评估指标:精确率,召回率,f1得分
from sklearn.metrics import classification_report
classification_report(testLabel, pre_label)
3.交叉验证
mode = GradientBoostingClassifier()
cross_val_score(mode, feaSet, inLabel, cv = 10, scoring = 'accuracy')
二.matplot 绘图
1.设置坐标轴标注
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.bar(x, befor, width=width, label='befor',color='b')
2.设置要显示的坐标轴坐标
ax.set_xticks([1,2,3,4,5])
#设置对应坐标的显示文字,rotation为文字的顺时针旋转角度,fontsize为文字大小
ax.set_xticklabels(['one','two','three','four','five'],rotation=45,fontsize=12)
plt.show()
3.设置图标标注
#loc表示位置
plt.legend(loc='lower right')
4.设置坐标轴的显示范围
plt.xlim(0.5, 5.5)
plt.ylim(0.5, 1.0)
5.在图中显示文字标注
#三个参数分别为x,y,要显示的内容
plt.text(xloc,yloc,str)
6.美化风格