권황관
권황관

Reputation: 31

Decide max_depth of DecisionTreeClassifier in sklearn

When I tuning Decision Tree using GridSearchCV in skelarn, I have a question. When I decide range of max_depth, I think that required max_depth is different case by case. Because, the number of sample, or features affect to decide max_depth. So, Is there any appropriate criteria for decide range of max_depth, or it's only decided by intuition?

Upvotes: 1

Views: 13236

Answers (2)

l'L'l
l'L'l

Reputation: 47159

Typically the recommendation is to start with max_depth=3 and then working up from there, which the Decision Tree (DT) documentation covers more in-depth.

Specifically using Ensemble Methods such as RandomForestClassifier or DT Regression is also helpful in determining whether or not max_depth is set to high and/or overfitting.

Upvotes: 2

Mars Gao
Mars Gao

Reputation: 69

You can try to change the max_depth from case to case and record the performance.

This might help you to get the performance.

http://scikit-learn.org/stable/modules/generated/sklearn.metrics.log_loss.html

You may decide a max depth with the tests. However, if you want to make the max_depth adapted from the tree, You can try to train another learning algorithm with enough data to find it out. (Or simply with a linear regression)

Upvotes: 1

Related Questions