# MLJ for XGBoost - extracting feature gain

**URL:** <https://discourse.julialang.org/t/mlj-for-xgboost-extracting-feature-gain/93518>\
**Category:** General Usage\
**Tags:** mlj\
**Created:** [January 25, 2023, 5:34pm UTC](https://discourse.julialang.org/t/mlj-for-xgboost-extracting-feature-gain/93518 "2023-01-25T17:34:26Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![ablaom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ablaom/32/4889_2.png) [@ablaom](https://discourse.julialang.org/u/ablaom)\
**Post date:** [January 25, 2023, 9:22pm UTC](https://discourse.julialang.org/t/mlj-for-xgboost-extracting-feature-gain/93518/2 "2023-01-25T21:22:03Z")

</div>

@Ivan Thanks for reporting this.

In the last breaking release of MLJXGBoostInterface those particular access points were indeed removed. However, MLJ now has a generic `feature_importance` accessor function you can call on machines wrapping supported models, and the MLJXGBoostInterface models are now supported.

Unfortunately, I just discovered a minor [bug](https://github.com/JuliaAI/MLJXGBoostInterface.jl/issues/33), so that only the classifier is currently working. Here’s the workflow in that case:

```julia
using MLJ
XGBoostClassifier = @load XGBoostClassifier pkg=XGBoost
X, y = @load_iris

model = XGBoostClassifier()
mach = machine(model, X, y) |> fit!

julia> feature_importances(mach)
4-element Vector{Pair{Symbol, Float32}}:
 :petal_length => 2.991818
  :petal_width => 1.3149351
  :sepal_width => 0.072732545
 :sepal_length => 0.042442977

```

---

_[View the full topic](https://discourse.julialang.org/t/mlj-for-xgboost-extracting-feature-gain/93518)._
