Sweep XGboost features importance custom names

Hi there,
I’m new in WB and I’like to know if it is possible to assign customs names in Sweep features importance table display.

Here some of my code:

def train():
    with wandb.init(job_type="sweep") as run:

        bst_params = {
              'gamma': run.config['gamma']
            , 'learning_rate': run.config['learning_rate']
            , 'max_depth': run.config['max_depth']
            , 'min_child_weight': run.config['min_child_weight']
            .....
        }

        # Initialize the XGBoostClassifier with the WandbCallback
        clf= XGBClassifier(error_score='raise',
                                              gpu_id=GPU_ID,
                                              #eval_metric=eval_metric,
                                              **bst_params,
                                              callbacks=[WandbCallback()],
                                              early_stopping_rounds=run.config['early_stopping_rounds'])

        # Train the model
        clf.fit(eval_set[0][0],
                eval_set[0][1],
                **{'eval_set':[eval_set[1]],
                    'verbose':False,
                    ...})

        bstr = clf.get_booster()
        #Set features names
        bstr.feature_names = cols_name

        # Log booster metrics
        run.summary["best_ntree_limit"] = bstr.best_ntree_limit

        # Get train and validation predictions
        trnYpreds = clf.predict_proba(eval_set[0][0])[:,1]
        valYpreds = clf.predict_proba(eval_set[1][0])[:,1]

        # Log additional Validation metrics
        ks_stat, ks_pval = ks_2samp(valYpreds[eval_set[1][1]==1], valYpreds[eval_set[1][1]==0])
        run.summary["val_ks_2samp"] = ks_stat
        run.summary["val_ks_pval"] = ks_pval
        run.summary["val_auc"] = metrics.roc_auc_score(eval_set[1][1], valYpreds)
        ...

This is the features importance output:

When I look at the Sweep features importance report I see features names as ‘f0’,…‘fn’.
I suppose that this report refers to model features importance and my question is: is it possible to assign custom names to the features ? How to do that?

Many thanks, Fabio

Hi @d-fdamore-fabio , thanks for writing in an happy to help. Currently once a table artifact is logged to a project, it’s values cannot be manually modified from the UI.

How are you generating the feature importance table, example? If you update the values before the table is logged the updates will be reflected in the UI.

Thank you @mohammadbakir !
The features importance table is automatic generated. I guess it is the XGBoost integration that does it for me.
I solved passing to XGBoost fit method the X data as dataframe (both training and evaluation data). Setting the dataframe columns names i fix it.

Thank you very much.
Ciao, Fabio

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.