treeinterpreter
treeinterpreter copied to clipboard
'RandomForestRegressor' object has no attribute 'n_outputs_' needed for the predict function
I'm trying to test the predict function but it raises the following error:
AttributeError: 'RandomForestRegressor' object has no attribute 'n_outputs_'.
Yet it seems that actually it has when checking the sklearn webpage.
Here is the full error message:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-101-56bf611044fd> in <module>
1 # checking the performance of training data itselfz
----> 2 prediction, bias, contributions = ti.predict(rf, numpy_df_train)
3 idx = pd.date_range(train_start_date, train_end_date)
4 predictions_df1 = pd.DataFrame(data=prediction[0:], index = idx, columns=['prices'])
5 predictions_df1.plot()
C:\ProgramData\Anaconda3\lib\site-packages\treeinterpreter\treeinterpreter.py in predict(model, X, joint_contribution)
193 """
194 # Only single out response variable supported,
--> 195 if model.n_outputs_ > 1:
196 raise ValueError("Multilabel classification trees not supported")
197
AttributeError: 'RandomForestRegressor' object has no attribute 'n_outputs_'
Did you fit the RandomForestRegressor before using ti.predict? the n_outputs_ attribute is created only once the model is fitted.