How it works...
In this recipe, we combined the information of three variables from the Boston House Prices dataset into a new variable utilizing a decision tree. We loaded the dataset from scikit-learn and then separated the data into train and test sets using the train_test_split() function. Next, we created a dictionary with the decision tree parameter to optimize as keys, and a list of the values to examine as values.
Next, we created an instance of a decision tree for regression using DecisionTreeRegressor() from scikit-learn inside GridSearch(), indicating the fold cross-validation, the metric to optimize, and the dictionary with the parameters and values to examine. Next, we fit the decision tree to the three variables of interest, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access