figure - decision tree with defined hyperparameters on bike sharing dataset now we start with the actual training process as must be evident from our workflow so farwe would train our regressor using -fold cross validation since we have hyperparameters as well in case of decision trees to worrywe need method to fine-tune them as well there are many ways of fine-tuning the hyperparametersthe most common ones are grid search and random searchwith grid search being the more popular one as the name suggestsrandom search randomly searches the combinations of hyperparameters to find the best combinationgrid search on the other hand is more systematic approach where all combinations are tried before the best is identified to make our lives easiersklearn provides utility to grid search the hyperparameters while cross validating the model using the gridsearchcv(method from model_selection module the gridsearchcv(method takes the regression/classifier object as input parameter along with dictionary of hyperparametersnumber of cross validations requiredand few more we use the following dictionary to define our grid of hyperparameters in [ ]param_grid {"criterion"["mse""mae"]"min_samples_split"[ ]"max_depth"[ ]"min_samples_leaf"[ ]"max_leaf_nodes"[ ]the dictionary basically provides list of feasible values for each of the hyperparameters that we want to fine-tune the hyperparameters are the keyswhile the values are presented as list of possible values of these hyperparameters for instanceour dictionary provides max_depth with possible values of and levels the gridsearchcv(function will in turn search in this defined list of possible values to arrive at the best one value the following snippet prepares gridsearchcv object and fits our training dataset to it in [ ]grid_cv_dtr gridsearchcv(dtrparam_gridcv=