Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

'RandomForestRegressor' object has no attribute 'n_outputs_' despite of the docs?

I'm trying to test the treeinterpreter.py predict function but it raises the following error:

AttributeError: 'RandomForestRegressor' object has no attribute 'n_outputs_'.

Yet it seems that actually RandomForestRegressor has this attribute when checking the sklearn webpage about RandomForestRegressor.

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_'

You can reproduce the code from this notebook.

Comments