3

With the following code:

classes = ['ham', 'spam']
dot_data = StringIO()
with open("./plots/ritesh.dot", "w") as f:
    export_graphviz(dt_old.named_steps['classifier'], out_file=f, feature_names=vocab1, class_names=classes)

I am getting error as unexpected keyword argument.

Traceback (most recent call last):
  File "DecisionTree.py", line 198, in <module>
    main()
  File "DecisionTree.py", line 133, in main
    export_graphviz(dt_old.named_steps['classifier'], out_file=f, feature_names=vocab1, class_names=classes)
TypeError: export_graphviz() got an unexpected keyword argument 'class_names'

But it is clearly mentioned in scikit-learn doc that

sklearn.tree.export_graphviz(decision_tree, out_file='tree.dot', max_depth=None, feature_names=None, class_names=None, label='all', filled=False, leaves_parallel=False, impurity=True, node_ids=False, proportion=False, rotate=False, rounded=False, special_characters=False)

What is the cause of that TypeError?

1 Answer 1

7

The version of sklearn you have installed is likely out of date with the documentation. If you installed sklearn with anaconda try on the command line "conda update scikit-learn"

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.