我正在尝试获取随机福雷斯特分类器的标准差,但它返回错误。我可以从RFC获得标准偏差吗?我评估的不仅仅是单个数字。
我尝试了多种方法,包括:
#print'\nStandard Deviation: \n {0:.2f}%'.format(np.std(accuracy_test))
OR
#acc_std = accuracy.std()
#print'Test accuracy - standard deviation: ', acc_std
# Making the confusion matrix
from sklearn.metrics import confusion_matrix
# Let's check the test accuracy after optimised
y_pred_test = classifier.predict(X_test_std)
test_acc_opt = classification_report(y_test, y_pred_test, labels=[1, 0])
print(test_acc_opt)
cm_test = confusion_matrix(y_test, y_pred_test)
print(cm_test)
#print "Accuracy of prediction:", (round((cm[0,0]+cm[1,1])/cm.sum(), 4))
#print(sum(diag(cm))/sum(cm))
#Find accuracy of optimised testing set
TP = cm_test[1,1]
FP = cm_test[0,1]
TN = cm_test[0,0]
FN = cm_test[1,0]
accuracy_te = float(TP + TN) / float(TP + FP + TN + FN)
accuracy_test = accuracy_te*100
print'\nTest accuracy mean: {0:.2f}%' .format(np.mean(accuracy_test))
acc22_std = classifier.std()*100
print'\nStandard Deviation:\n {0:.2f}%'.format(acc22_std)
我得到以下信息:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-58-f81c82be86fe> in <module>()
23 print'\nTest accuracy mean: {0:.2f}%' .format(np.mean(accuracy_test))
24 print'\nStandard Deviation: \n {0:.2f}%'.format(np.std(accuracy_test))
---> 25 acc22_std = classifier.std()*100
26 print'\nStandard Deviation:\n {0:.2f}%'.format(acc22_std)
27
AttributeError: 'RandomForestClassifier' object has no attribute 'std'
我想要以下内容: 标准偏差:1.43%