madman_with_a_box
madman_with_a_box

Reputation: 84

How to Overfit a Decision Tree in scikit-learn on purpose?

Say I have n training samples and a binary classification task. I want to train a decision tree of smallest possible depth and having fewest possible total nodes such that the training accuracy on these n samples is 100%. In the worst case, this would mean that I have one leaf node per sample. Is there some configuration of parameters in Scikit-Learn's implementation [1] of the DecisionTreeClassifier that would let me achieve this?

[1] https://scikit-learn.org/stable/modules/generated/sklearn.tree.DecisionTreeClassifier.html#sklearn-tree-decisiontreeclassifier

Upvotes: 0

Views: 601

Answers (1)

ombk
ombk

Reputation: 2111

Answer

By reading the documentation you get your answer.

If you dont set a limit to max_depth the tree will keep expanding to the deepest leaf.

Also you can check here similar question.

Upvotes: 1

Related Questions