Closed rafmacalaba closed 4 years ago
@rafmacalaba you can try setting categorical_feature in fit_params dictionary that you provide for LOFO. https://github.com/aerdem4/lofo-importance/blob/master/lofo/lofo_importance.py#L30
lofo_imp = LOFOImportance(dataset, cv=cv, scoring="roc_auc", fit_params={"categorical_feature": ["cat1", "cat2"]})
Ah!! make sense. I just figured it out just now, I added the categorical_feature
parameter in my dict. Thanks :D btw, it would be good if you add that on your README.md :D Thank you so much Ahmet! Please resolve this.
Seems like it doesn't work :x: @aerdem4
~/anaconda3/lib/python3.7/site-packages/sklearn/model_selection/_validation.py in _fit_and_score(estimator, X, y, scorer, train, test, verbose, parameters, fit_params, return_train_score, return_parameters, return_n_test_samples, return_times, return_estimator, error_score)
526 estimator.fit(X_train, **fit_params)
527 else:
--> 528 estimator.fit(X_train, y_train, **fit_params)
529
530 except Exception as e:
TypeError: fit() got an unexpected keyword argument 'objective'```
@aerdem4 is there a way I can download this specific version 6mos ago? https://www.kaggle.com/divrikwicky/lofo-importance
objective is not fit_params but model parameters, you need to set it while you create your lightgbm model.
If you still want to use an old version you can pip install lofo-importance==0.2.0
@aerdem4 I made it work with some workarounds, I think I found the culprit of my error. specifically in infer_defaults.py
I am using the dtype category
instead of the object
that the one you're using in the script. Might be good to add this in the file.
Thank you!
Can you paste your code that reproduces the error?
@aerdem4 it's just the classic Could not convert to float - string
which any models would be angry to have, basically my categorical features are in category
dtype not object
which was in your infer_defaults.py
script. I made a PR for this and just check if it's good to go :D Thanks!
Solved by #25
I don't know how to feature request XD.
It would be great if you can add the
categorical_feature
parameter in yourDataset
just like in the lightgbm docs. Thanks!!