Main Content

predictorImportance

Estimates of predictor importance for XGBoost model

Since R2026a

    Description

    imp = predictorImportance(mdl) computes estimates of predictor importance for mdl by summing the estimates over all weak learners in the XGBoost model. imp has one element for each input predictor in the data used to train the model. A high value indicates that the predictor is important for mdl, with 0 representing the smallest possible importance.

    example

    Examples

    collapse all

    Estimate the predictor importance for all variables in the ionosphere data.

    This example includes a pretrained XGBoost classification model trained using the ionosphere dataset. The model was trained in Python and saved as a json file using model.save_model('trainedXGBoostModel.json').

    load ionosphere
    modelfile = "trainedXGBoostModel.json";
    Mdl = importModelFromXGBoost(modelfile)
    Mdl = 
      CompactClassificationXGBoost
                   ResponseName: 'Y'
                     ClassNames: [0 1]
                 ScoreTransform: 'logit'
                     NumTrained: 30
        ImportedModelParameters: [1×1 struct]
    
    
      Properties, Methods
    
    

    Estimate the predictor importance for all predictor variables.

    imp = predictorImportance(Mdl);
    figure
    bar(imp)
    title("Predictor Importance Estimates")
    ylabel("Estimates")
    xlabel("Predictors")

    Figure contains an axes object. The axes object with title Predictor Importance Estimates, xlabel Predictors, ylabel Estimates contains an object of type bar.

    The 27th predictor has the most importance and some predictors have zero importance on the classification.

    Input Arguments

    collapse all

    XGBoost model, specified as a CompactClassificationXGBoost or CompactRegressionXGBoost model object imported with importModelFromXGBoost.

    More About

    collapse all

    Version History

    Introduced in R2026a