Skip to content
Advertisement

Plot Decision Tree train/test accuracy against max depth

I was trying to plot the accuracy of my train and test set from a decision tree model. Since I am new to using python, I wasn’t sure what type of graphing package I should use. I have used a simple for loop for getting the printed results, but not sure how ]I can plot it.

Thanks!

My code:

JavaScript

Desired graph enter image description here

Advertisement

Answer

The plot in the image you posted was most likely created with the matplotlib.pyplot module. You can probably plot a similar graph by executing something like this, assuming that you have imported other necessary dependencies:

JavaScript

I’m new to this community as well, so I am in no position to give advice to other users. However, it’s probably a good idea to format your source code for better readability and presentation. Just a heads up.

I hope this helps. Let me know if anything is unclear.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement