Main Content

edge

Classification edge

Syntax

E = edge(obj,X,Y)
E = edge(obj,X,Y,Name,Value)

Description

E = edge(obj,X,Y) returns the classification edge for obj with data X and classification Y.

E = edge(obj,X,Y,Name,Value) computes the edge with additional options specified by one or more Name,Value pair arguments.

Note

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.

Input Arguments

obj

Discriminant analysis classifier of class ClassificationDiscriminant or CompactClassificationDiscriminant, typically constructed with fitcdiscr.

X

Matrix where each row represents an observation, and each column represents a predictor. The number of columns in X must equal the number of predictors in obj.

Y

Class labels, with the same data type as exists in obj. The number of elements of Y must equal the number of rows of X.

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.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

weights

Observation weights, a numeric vector of length size(X,1). If you supply weights, edge computes the weighted classification edge.

Default: ones(size(X,1),1)

Output Arguments

E

Edge, a scalar representing the weighted average value of the margin.

Examples

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

More About

expand all

Extended Capabilities

Version History

expand all