主要内容

edge

Classification edge for XGBoost classification model

Since R2026a

    Description

    e = edge(mdl,tbl,ResponseVarName) returns the classification edge e for the trained classification XGBoost model mdl using the predictor data in table tbl and the class labels in tbl.ResponseVarName.

    The classification edge e is a scalar value.

    example

    e = edge(mdl,tbl,Y) returns the classification edge using the predictor data in table tbl and the class labels in Y.

    e = edge(mdl,X,Y) returns the classification edge using the predictor data in matrix X and the class labels in Y.

    e = edge(___,Name=Value) specifies options using one or more name-value arguments in addition to any of the input argument combinations in the previous syntaxes. For example, you can specify observation weights and perform computations in parallel.

    Examples

    collapse all

    Find the classification edge for some of the data used to train an XGBoost classifier. An XGBoost model trained using the ionosphere dataset is provided with this example.

    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
    
    

    Convert the response data to a boolean array to match the imported model.

    Y = (Y=="g");

    Find the classification edge for the last few rows.

    E = edge(Mdl,X(end-10:end,:),Y(end-10:end))
    E = single
    
    0.6442
    

    Input Arguments

    collapse all

    Compact classification XGBoost model, specified as a CompactClassificationXGBoost model object created with importModelFromXGBoost.

    Sample data, specified as a table. Each row of tbl corresponds to one observation, and each column corresponds to one predictor variable. tbl must contain all of the predictors used to train the model. Multicolumn variables and cell arrays other than cell arrays of character vectors are not allowed.

    Data Types: table

    Response variable name, specified as the name of a variable in tbl. If mdl.ResponseName is the response variable name, then you do not need to specify ResponseVarName.

    If you specify ResponseVarName, you must specify it as a character vector or string scalar. For example, if the response variable Y is stored as tbl.Y, then specify it as "Y". Otherwise, the software treats all columns of tbl, including Y, as predictors.

    The response variable must be a logical or numeric vector.

    Data Types: char | string

    Class labels, specified as a logical or numeric vector. Y must have the same data type as tbl or X.

    Y must be of the same type as the classification used to train mdl, and its number of elements must equal the number of rows of tbl or X.

    Data Types: logical | single | double

    Predictor data, specified as a numeric matrix.

    Each row of X corresponds to one observation, and each column corresponds to one variable. The number of rows in X must equal the number of rows in Y.

    The variables that make up the columns of X must have the same order as the predictor variables used to train mdl.

    Data Types: double | single

    Name-Value Arguments

    collapse all

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: edge(Mdl,X,Y,UseParallel=true) specifies to run function in parallel.

    Flag to run in parallel, specified as a numeric or logical 1 (true) or 0 (false). If you specify UseParallel=true, the edge function executes for-loop iterations by using parfor. The loop runs in parallel when you have Parallel Computing Toolbox™.

    Example: UseParallel=true

    Data Types: logical

    Observation weights, specified as a numeric vector or the name of a variable in tbl. If you supply weights, edge computes the weighted classification edge.

    If you specify Weights as a numeric vector, then the size of Weights must be equal to the number of observations in X or tbl. The software normalizes Weights to sum up to the value of the prior probability in the respective class.

    If you specify Weights as the name of a variable in tbl, you must specify it as a character vector or string scalar. For example, if the weights are stored as tbl.w, then specify Weights as "w". Otherwise, the software treats all columns of tbl, including tbl.w, as predictors.

    Data Types: single | double | char | string

    More About

    collapse all

    Extended Capabilities

    expand all

    GPU Arrays
    Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.

    Version History

    Introduced in R2026a