E = edge(obj,X,Y)
E = edge(obj,X,Y,Name,Value)
returns the classification edge for
E = edge(
obj with data
X and classification
computes the edge with additional options specified by one or more
E = edge(
Name,Value pair arguments.
If the predictor data
X contains any missing values, the
edge function can return NaN. For more details,
see edge can return NaN for predictor data with missing values.
Discriminant analysis classifier of class
Matrix where each row represents an observation, and each column
represents a predictor. The number of columns in
Class labels, with the same data type as exists in
Specify optional pairs of arguments as
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.
Before R2021a, use commas to separate each name and value, and enclose
Name in quotes.
Observation weights, a numeric vector of length
Edge, a scalar representing the weighted average value of the margin.
Compute the classification edge and margin for the Fisher iris data, trained on its first two columns of data, and view the last 10 entries:
load fisheriris X = meas(:,1:2); obj = fitcdiscr(X,species); E = edge(obj,X,species) E = 0.4980 M = margin(obj,X,species); M(end-10:end) ans = 0.6551 0.4838 0.6551 -0.5127 0.5659 0.4611 0.4949 0.1024 0.2787 -0.1439 -0.4444
The classifier trained on all the data is better:
obj = fitcdiscr(meas,species); E = edge(obj,meas,species) E = 0.9454 M = margin(obj,meas,species); M(end-10:end) ans = 0.9983 1.0000 0.9991 0.9978 1.0000 1.0000 0.9999 0.9882 0.9937 1.0000 0.9649
The edge is the weighted mean value of the classification margin. The weights are class prior probabilities. If you supply additional weights, those weights are normalized to sum to the prior probabilities in the respective classes, and are then used to compute the weighted average.
The classification margin is the difference between the classification score for the true class and maximal classification score for the false classes.
The classification margin is a column vector with the same number
of rows as in the matrix
X. A high value of margin
indicates a more reliable prediction than a low value.
Score (discriminant analysis)
For discriminant analysis, the score of a classification is the posterior probability of the classification. For the definition of posterior probability in discriminant analysis, see Posterior Probability.
Calculate with arrays that have more rows than fit in memory.
This function fully supports tall arrays. For more information, see Tall Arrays.
edge can return NaN for predictor data with missing values
edge function no longer omits an observation
with a NaN score when computing the weighted mean of the classification margins.
edge can now return NaN when the
X contains any missing values. In most
cases, if the test set observations do not contain missing predictors, the
edge function does not return NaN.
This change improves the automatic selection of a classification model when
fitcauto. Before this change, the software might select a model
(expected to best classify new data) with few non-NaN predictors.
edge in your code returns NaN, you can update
your code to avoid this result. Remove or replace the missing values by using
The following table shows the classification models for which the
edge object function might return NaN. For more
details, see the Compatibility Considerations for each
|Model Type||Full or Compact Model Object|
|Discriminant analysis classification model|
|Ensemble of learners for classification|
|Gaussian kernel classification model|
|k-nearest neighbor classification model|
|Linear classification model|
|Neural network classification model|
|Support vector machine (SVM) classification model|