0

I have the following piece of code:

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')

The last line does not work because forest does not contain a tree. Is there a way to generate a dot file representing the calibration of the classifier ?

BlueTrin
  • 9,610
  • 12
  • 49
  • 78
  • Does this help: http://stackoverflow.com/questions/25274673/is-it-possible-to-print-the-decision-tree-in-scikit-learn/25280046#25280046 ? – EdChum Oct 02 '14 at 15:12
  • but the forest has many trees – mdurant Oct 02 '14 at 15:36
  • 1
    How do I print all the trees, the link you put is the reason I ask this question, it seems that it does not work directly straight out of the box and I am totally new to scikit-learn. – BlueTrin Oct 02 '14 at 15:40

0 Answers0