Link to the previous post: https://statinfer.com/204-3-9-the-problem-of-overfitting-the-decision-tree
#We will rebuild a new tree by using above data and see how it works by tweeking the parameteres
dtree = tree.DecisionTreeClassifier(criterion = "gini", splitter = 'random', max_leaf_nodes = 10, min_samples_leaf = 5, max_depth= 5)
dtree.fit(X_train,y_train)
predict3 = dtree.predict(X_train)
print(predict3)
predict4 = dtree.predict(X_test)
print(predict4)
#Accuracy of the model that we created with modified model parameters.
score2 = dtree.score(X_test, y_test)
score2
The next post is a practice session on tree building model selection.
Link to the next post : https://statinfer.com/204-3-11-practice-tree-building-model-selection