Skip to content

Commit

Permalink
add feature importance to fit step
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomarvid committed Mar 5, 2024
1 parent aa670ec commit c5210f1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions pipeline_lib/core/data_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class DataContainer:
EXPLAINER = "explainer"
TUNING_PARAMS = "tuning_params"
TARGET = "target"
IMPORTANCE = "importance"

def __init__(self, initial_data: Optional[dict] = None):
"""
Expand Down
4 changes: 4 additions & 0 deletions pipeline_lib/implementation/tabular/xgboost/fit_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ def execute(self, data: DataContainer) -> DataContainer:
# Save the model to the data container
data[DataContainer.MODEL] = model

importance = model.get_booster().get_score(importance_type="gain")
importance = dict(sorted(importance.items(), key=lambda item: item[1], reverse=True))
data[DataContainer.IMPORTANCE] = importance

end_time = time.time()
elapsed_time = end_time - start_time
minutes = int(elapsed_time // 60)
Expand Down

0 comments on commit c5210f1

Please sign in to comment.