4.1. Exercises
Feature Splitting
Parameter or Hyperparameter
For the following statements, state if it corresponds to a Parameter or Hyperparameter.
Playing with Hyperparameters
Instructions:
Running a coding exercise for the first time could take a bit of time for everything to load. Be patient, it could take a few minutes.
When you see ____ in a coding exercise, replace it with what you assume to be the correct code. Run it and see if you obtain the desired output. Submit your code to validate if you were correct.
Make sure you remove the hash (#) symbol in the coding portions of this question. We have commented them so that the line wonβt execute and you can test your code after each step.
Letβs build a decision tree classifier using DecisionTreeClassifier() but this time, letβs set some different hyperparameters.
Tasks:
- Build a decision tree classifier and make sure to set the argument
random_stateto 1. - Set the
max_depthof the tree to 8 and themin_samples_splitto 4. - Save the model in an object named
hyper_tree. - Fit your model on the objects
Xandy. - Save the accuracy of the model rounded to 2 decimal places in a variable named
tree_scoreand display it.