Mistake in Gridsearch Q2


Hi, I am struggling in doing the gridsearch. I guess it is because I am not imputing any values for the missing data, but when I tried giving a pipeline with SimpleImputer it didn’t work. What may be the reason? if it is because of the missing data, where should I set the SimpleImputer?

Thanks!

If you have missing data then you need to impute before the tree:

model = make_pipeline(SimpleImputer(), DecisionTreeRegressor())

and then you can pass model to the grid-search.

I think something similar was asked in the first wrap-up quiz.


That is what I did at the very beginning and I get this error

Your model is a pipeline, wich does not have the parameter max_depth. Only the DecisionTreeRegressor() in you pipeline has this, thus the key in your param_grid needs to provide additional information (i.e. 'decisiontreeregressor__max_depth': np.arange(...)).

1 Like

Yes @jrahn is right.

1 Like