Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature_importances for Pipeline including XGBoost don't work #1100

Closed
paulotrefosco opened this issue Mar 7, 2024 · 2 comments
Closed

feature_importances for Pipeline including XGBoost don't work #1100

paulotrefosco opened this issue Mar 7, 2024 · 2 comments
Assignees

Comments

@paulotrefosco
Copy link

Description of the bug
For a machine using only XGBoostClassifier (e.g. xgbm) I can extract feature_importances(xgbm), but for a pipeline machine like one hot encoder |> XGBoostClassifier it seems to exist a bug.
I've tried to have some checks like reports_feature_importances(xgbm.model.xg_boost_classifier) (results in true) but both codes below lead to errors:

feature_importances(xgbm) >> Results nothing

feature_importances(xgbm.model.xg_boost_classifier) >> Error Message:

MethodError: no method matching feature_importances(::MLJXGBoostInterface.XGBoostClassifier)

Closest candidates are:
  feature_importances(::Union{MLJXGBoostInterface.XGBoostAbstractClassifier, MLJXGBoostInterface.XGBoostAbstractRegressor}, ::Any, ::Any)
   @ MLJXGBoostInterface C:\Users\User\.julia\packages\MLJXGBoostInterface\uFARS\src\MLJXGBoostInterface.jl:121
  feature_importances(::Machine)
   @ MLJBase C:\Users\User\.julia\packages\MLJBase\eCnWm\src\machines.jl:910
  feature_importances(::Union{MLJDecisionTreeInterface.AdaBoostStumpClassifier, MLJDecisionTreeInterface.DecisionTreeClassifier, MLJDecisionTreeInterface.DecisionTreeRegressor, MLJDecisionTreeInterface.RandomForestClassifier, MLJDecisionTreeInterface.RandomForestRegressor}, ::Any, ::Any)
   @ MLJDecisionTreeInterface C:\Users\User\.julia\packages\MLJDecisionTreeInterface\kPIDf\src\MLJDecisionTreeInterface.jl:483


Stacktrace:
 [1] top-level scope
   @ In[32]:1

To Reproduce

XGBC = @load XGBoostClassifier
xgb = XGBC()
ohe = OneHotEncoder()

xgb_pipe = ohe |> xgb

y, X = unpack(df, ==(:y_label), col->true)

train, test = partition(1:length(y), 0.7, shuffle=true)

xgbm = machine(xgb_pipe, X, y)
fit!(xgbm, rows=train, verbosity=0)

feature_importances(xgbm.model.xg_boost_classifier)

Versions
julia\environments\v1.9
MLJ v0.20.0

Any idea if it's a bug or if I should write something different in the code?
Thanks a lot for the support!

@ablaom
Copy link
Member

ablaom commented Mar 7, 2024

No this is something between a missing feature and a bug, depending on your point-of-view. You're not doing anything wrong that I can see.

@ablaom
Copy link
Member

ablaom commented Mar 17, 2024

closed by JuliaAI/MLJBase.jl#963

@ablaom ablaom closed this as completed Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants