feature_importances for Pipeline including XGBoost don't work
paulotrefosco opened this issue · 2 comments
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!
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.
closed by JuliaAI/MLJBase.jl#963