manifoldai / merf

Mixed Effects Random Forest
MIT License
219 stars 52 forks source link

TypeError: __init__() got an unexpected keyword argument 'n_estimators' #61

Closed jessie831024 closed 3 years ago

jessie831024 commented 3 years ago

When trying to set arguments like n_estimators for MERF, MERF.fit returns the above initialisation error. It works fine with default setting. This seems to suggest that MERF to sklearn random forest API is broken. Is this a version issue? I'm using: Python 3.9.5 scikit-learn==0.24.2

jessie831024 commented 3 years ago

I tried using Python 3.6.13 scikit-learn==0.22.2.post1 The error is still there using your notebook examples:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-11-dd6516a35cc1> in <module>
----> 1 mrf = MERF(n_estimators=300, max_iterations=100)
      2 mrf.fit(X_train, Z_train, clusters_train, y_train)

TypeError: __init__() got an unexpected keyword argument 'n_estimators'`
fabianegli commented 3 years ago

You have to supply the regressor, not just its parameters.

MERF(fixed_effects_model=RandomForestRegressor(n_estimators=300, max_iterations=100, n_jobs=-1))
jessie831024 commented 3 years ago

Just figured that out. The notebook examples are a little misleading. Thanks.