https://github.com/nixtla logo
#general
Title
# general
v

Vasilis Kontonis

07/10/2023, 1:00 PM
Hello, I have a question about mlforecast and I thought of asking it here in case anyone could help me. I am using mlforecast with the lightgbm regressor and I create a lot of features (dynamic, recursive and date features). I would like to see the feature importances in order to understand which of those features were the most important for the model and restrict my feature set a little bit. Does anyone know how to extract the feature importances from the mlforecast object?
t

Tyler Blume

07/10/2023, 1:14 PM
Just need to access the underlying model via the models_ attribute of MLForecast and plot using LightGBM's function:
import lightgbm as lgb
lgb.plot_importance(mlf.models_['LGBMRegressor'], max_num_features=5)
Here mlf is the mlforecast class after fitting and max_num_features is the number of the top features to plot.
👍 1
m

Max (Nixtla)

07/10/2023, 4:46 PM
Cc @José Morales