edge
R2026bDescription
returns the classification edge e = edge(mdl,tbl,ResponseVarName)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.
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.e = edge(___,Name=Value)
Examples
Find the classification edge for some of the data used to train an XGBoost classifier. An XGBoost model trained using the ionosphere data set 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
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
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="auto") specifies to run function in
parallel.
Option to perform computations in parallel using a parallel pool of workers, specified as one of these values:
"off"— Run in serial on the MATLAB® client."auto"— Use a parallel pool if one is open or if MATLAB can automatically create one. If a parallel pool is not available, run in serial on the MATLAB client."on"— Use a parallel pool if one is open or if MATLAB can automatically create one. If a parallel pool is not available, throw an error.
If you do not have a parallel pool open and automatic pool creation is enabled, MATLAB opens a pool using the default cluster profile. To use a parallel pool to run computations in MATLAB, you must have Parallel Computing Toolbox™. For more information, see Run MATLAB Functions with Automatic Parallel Support (Parallel Computing Toolbox).
Before R2026b: To run in parallel, set
UseParallel to true.
Example: UseParallel="auto"
Data Types: char | string
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
The edge is the weighted mean value of the classification margin.
The weights are the class probabilities in
ens.Prior. If you supply weights in the
Weights name-value argument, those weights are used instead of class
probabilities.
Extended Capabilities
Usage notes and limitations:
You cannot use the
UseParallelname-value argument with tall arrays.
For more information, see Tall Arrays.
The edge function has automatic parallel support. To run
computations in parallel, set the UseParallel argument to
"on" or "auto".
For more information, see Run MATLAB Functions with Automatic Parallel Support (Parallel Computing Toolbox).
You cannot use the UseParallel name-value
argument with tall arrays, GPU arrays, or code generation.
GPU Arrays
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
Version History
Introduced in R2026aThe UseParallel name-value argument now accepts
"off", "auto", or "on" values
instead of true or false. This change gives you more
control over when to use a parallel pool for parallel execution. Specifying the
UseParallel name-value argument as true or
false is not recommended.
This table shows how to update your code depending on your goal.
| Goal | Not Recommended | Recommended |
|---|---|---|
Write code that runs on the MATLAB client. |
UseParallel=false
|
UseParallel="off"
|
| Write portable code that runs on a parallel pool and, if a pool is not available, runs on the MATLAB client. |
UseParallel=true
|
UseParallel="auto"
|
| Write code that runs on a parallel pool and errors if a pool is not available. | N/A |
UseParallel="on"
|
There are no plans to remove support for the true or
false values.
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.
Amerika
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)