It is easy to understand the notion of the following snippet of the course:
tree_predictions = []
for inx, tree in enumerate(rf.estimators_): #'rf' is a random forest model
tree_predictions.append(tree.predict(data_test))
However, given
rf = RandomForestRegressor(n_jobs=2, random_state=0)
rf_model = make_pipeline(preprocessor, rf)
#Note: 'preprocessor' is a pipeline including: specifying categorical/numerical data columns, imputing missing data, and transforming categorical/numerical columns.
grid_search = GridSearchCV(
rf_model, param_grid=param_grid,
scoring="neg_mean_absolute_error", n_jobs=-1,
)
_ = grid_search.fit(data_train, target_train)
How to get predictions for each tree given a set of new data?