如何从RandomForestClassifier中提取决策树?

时间:2014-10-02 15:11:07

标签: python scikit-learn

我有以下代码:

print('Training...')
forest = RandomForestClassifier(n_estimators=100)
forest = forest.fit( train_data[0::,1::], train_data[0::,0] )


print('Predicting...')
output = forest.predict(test_data).astype(int)

if sys.version_info >= (3,0,0):
    predictions_file = open("myfirstforest.csv", 'w', newline='')
else:
    predictions_file = open("myfirstforest.csv", 'wb')


tree.export_graphviz(forest, out_file='tree.dot')

最后一行不起作用,因为forest不包含树。有没有办法生成一个代表分类器校准的点文件?

0 个答案:

没有答案