Vaue Error - Wrap-up quiz 5

Hello everybody, i have a problem with tree regressor,

ValueError: Input contains NaN, infinity or a value too large for dtype('float32').

my lines are:

from sklearn.tree import DecisionTreeRegressor

#Tree Decision model
tree = DecisionTreeRegressor(max_depth=1)
tree.fit(data_numerical, target)

where:

target = ames_housing[target_name]

I tried with a SimpleImputer with strategy='mean')

but i don’t know if the results is what we expect.

My code is here:

#Tree Decision model
model_tree = make_pipeline(SimpleImputer(strategy='mean'),
                          DecisionTreeRegressor(max_depth=1))
#tree = DecisionTreeRegressor(max_depth=1)
model_tree.fit(data_numerical, target)
model_tree.score(data_numerical, target)
0.3650136125329395

I don’t really recall the wrap-up quiz but indeed the data where containing missing data and using a SimpleImputer to impute the missing data was the right move.