ing-bank / probatus

Validation (like Recursive Feature Elimination for SHAP) of (multiclass) classifiers & regressors and data used to develop them.
https://ing-bank.github.io/probatus
MIT License
132 stars 40 forks source link

LightGBM : AttributeError: 'TreeEnsemble' object has no attribute 'values' #189

Closed mirix closed 8 months ago

mirix commented 2 years ago

Describe the bug

When the clf is LightGBM, I receive the following error:

File "/home/mirix/work/loans/shap/test_probatus_lightgbm.py", line 166, in report = shap_elimination.fit_compute(X_train_scaled, y_train) File "/home/mirix/.local/lib/python3.10/site-packages/probatus/feature_elimination/feature_elimination.py", line 651, in fit_compute self.fit( File "/home/mirix/.local/lib/python3.10/site-packages/probatus/feature_elimination/feature_elimination.py", line 539, in fit results_per_fold = Parallel(n_jobs=self.n_jobs)( File "/home/mirix/.local/lib/python3.10/site-packages/joblib/parallel.py", line 1056, in call self.retrieve() File "/home/mirix/.local/lib/python3.10/site-packages/joblib/parallel.py", line 935, in retrieve self._output.extend(job.get(timeout=self.timeout)) File "/home/mirix/.local/lib/python3.10/site-packages/joblib/_parallel_backends.py", line 542, in wrap_future_result return future.result(timeout=timeout) File "/usr/lib/python3.10/concurrent/futures/_base.py", line 446, in result return self.get_result() File "/usr/lib/python3.10/concurrent/futures/_base.py", line 391, in get_result raise self._exception AttributeError: 'TreeEnsemble' object has no attribute 'values'

Environment (please complete the following information):

To Reproduce

Code or steps to reproduce the error

clf = lightgbm.LGBMClassifier(max_depth=5, class_weight='balanced')

tune_search = TuneSearchCV(clf, 
                           param_distributions,
                           n_trials=1,
                           early_stopping=False,
                           scoring='roc_auc',
                           max_iters=10,
                           search_optimization='hyperopt',
                           n_jobs=1,
                           verbose=2,
                           use_gpu=True
)

shap_elimination = ShapRFECV(
    clf=tune_search, step=0.1, cv=10, scoring='roc_auc', n_jobs=8)
report = shap_elimination.fit_compute(X_train_scaled, y_train)

Error traceback

If applicable please provide full traceback of the error.

>   File "/home/mirix/work/loans/shap/test_probatus_lightgbm.py", line 166, in <module>
>     report = shap_elimination.fit_compute(X_train_scaled, y_train)
>   File "/home/mirix/.local/lib/python3.10/site-packages/probatus/feature_elimination/feature_elimination.py", line 651, in fit_compute
>     self.fit(
>   File "/home/mirix/.local/lib/python3.10/site-packages/probatus/feature_elimination/feature_elimination.py", line 539, in fit
>     results_per_fold = Parallel(n_jobs=self.n_jobs)(
>   File "/home/mirix/.local/lib/python3.10/site-packages/joblib/parallel.py", line 1056, in __call__
>     self.retrieve()
>   File "/home/mirix/.local/lib/python3.10/site-packages/joblib/parallel.py", line 935, in retrieve
>     self._output.extend(job.get(timeout=self.timeout))
>   File "/home/mirix/.local/lib/python3.10/site-packages/joblib/_parallel_backends.py", line 542, in wrap_future_result
>     return future.result(timeout=timeout)
>   File "/usr/lib/python3.10/concurrent/futures/_base.py", line 446, in result
>     return self.__get_result()
>   File "/usr/lib/python3.10/concurrent/futures/_base.py", line 391, in __get_result
>     raise self._exception
> AttributeError: 'TreeEnsemble' object has no attribute 'values'

Expected behavior

A clear and concise description of what you expected to happen.

adri0 commented 1 year ago

Hi @mirix. I've seen the same problem before, but I wasn't able to reproduce it. Would you have a fully reproducible snippet?

mirix commented 1 year ago

Hi @adri0

I opened this bug over a year ago. I was on a different job. So, unfortunately, no, I do not have any code.

I remember I ended up not using probatus on that project.

ReinierKoops commented 8 months ago

Very likely this bug is fixed with the latest probatus releases. Will close this. Please feel free to make another bug report if this happens again.