CompactClassificationDiscriminant
statistics: CompactClassificationDiscriminant
Compact discriminant analysis classification
The CompactClassificationDiscriminant class implements a compact
version of a linear discriminant analysis classifier object, which can
predict responses for new data using the predict method but does not
store the training data.
A CompactClassificationDiscriminant object is a compact version of a
discriminant analysis model, ClassificationDiscriminant. It does
not include the training data resulting in a smaller classifier size, which
can be used for making predictions from new data, but not for tasks such as
cross validation. It can only be created from a
ClassificationDiscriminant model by using the compact object
method.
Create a CompactClassificationDiscriminant object by using the
compact method of a ClassificationDiscriminant object.
Six discriminant types are available, in two families. The linear family,
'linear', 'diagLinear' and 'pseudoLinear', pools
one covariance across the classes and separates them with a hyperplane.
The quadratic family, 'quadratic', 'diagQuadratic' and
'pseudoQuadratic', estimates a covariance per class and separates
them with a quadric. A 'diag' type keeps only the variances,
which is the same model as a Gamma of 1, and a 'pseudo'
type inverts a singular covariance rather than refusing it.
DiscrimType may be assigned after fitting, but only within
its own family: the family is fixed when the model is fitted, because it
decides which covariances the fit has to estimate. Assigning it, or
Gamma, re-derives Sigma, LogDetSigma and
Coeffs without refitting.
See also: fitcdiscr, ClassificationDiscriminant
Source Code: CompactClassificationDiscriminant
The CompactClassificationDiscriminant class contains the following properties:
A positive integer value specifying the number of predictors in the training dataset used for training the CompactClassificationDiscriminant model. This property is read-only.
Create a discriminant analysis classifier and its compact version and compare their size
load fisheriris X = meas; Y = species; Mdl = fitcdiscr (X, Y, 'ClassNames', unique (species))
Mdl =
ClassificationDiscriminant
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
ScoreTransform: 'none'
NumObservations: 150
NumPredictors: 4
DiscrimType: 'linear'
Mu: [3x4 double]
Coeffs: [3x3 struct]
CMdl = crossval (Mdl)
CMdl =
ClassificationPartitionedModel
CrossValidatedModel: 'Discriminant'
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
NumObservations: 150
KFold: 10
ScoreTransform: 'none'
A cell array of character vectors specifying the names of the predictor variables. The names are in the order in which they appear in the training dataset. This property is read-only.
Create a discriminant analysis classifier and its compact version and compare their size
load fisheriris X = meas; Y = species; Mdl = fitcdiscr (X, Y, 'ClassNames', unique (species))
Mdl =
ClassificationDiscriminant
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
ScoreTransform: 'none'
NumObservations: 150
NumPredictors: 4
DiscrimType: 'linear'
Mu: [3x4 double]
Coeffs: [3x3 struct]
CMdl = crossval (Mdl)
CMdl =
ClassificationPartitionedModel
CrossValidatedModel: 'Discriminant'
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
NumObservations: 150
KFold: 10
ScoreTransform: 'none'
A -by- matrix holding the covariance of the class means about the overall mean, weighted by how many observations each class contributes. With observations in class , and , it is
BetweenSigma = sum_k n_k (Mu(k,:) - mubar)' * (Mu(k,:) - mubar)
/ (n * (1 - sum_k p_k^2))
|
The denominator is the unbiased one for a weighted covariance, so a
balanced fit divides by . It reads the class
sizes, not Prior: assigning a prior leaves it where it was. It
is estimated for every discriminant type, the quadratic family included,
since it describes the classes rather than the fit. This property is
read-only.
Create a discriminant analysis classifier and its compact version and compare their size
load fisheriris X = meas; Y = species; Mdl = fitcdiscr (X, Y, 'ClassNames', unique (species))
Mdl =
ClassificationDiscriminant
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
ScoreTransform: 'none'
NumObservations: 150
NumPredictors: 4
DiscrimType: 'linear'
Mu: [3x4 double]
Coeffs: [3x3 struct]
CMdl = crossval (Mdl)
CMdl =
ClassificationPartitionedModel
CrossValidatedModel: 'Discriminant'
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
NumObservations: 150
KFold: 10
ScoreTransform: 'none'
A numeric vector of column indices into X naming the predictors
treated as categorical, and empty when none is. This property is
read-only.
Create a discriminant analysis classifier and its compact version and compare their size
load fisheriris X = meas; Y = species; Mdl = fitcdiscr (X, Y, 'ClassNames', unique (species))
Mdl =
ClassificationDiscriminant
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
ScoreTransform: 'none'
NumObservations: 150
NumPredictors: 4
DiscrimType: 'linear'
Mu: [3x4 double]
Coeffs: [3x3 struct]
CMdl = crossval (Mdl)
CMdl =
ClassificationPartitionedModel
CrossValidatedModel: 'Discriminant'
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
NumObservations: 150
KFold: 10
ScoreTransform: 'none'
A cell array of character vectors. It matches PredictorNames
unless a categorical predictor was expanded into indicator variables.
This property is read-only.
Create a discriminant analysis classifier and its compact version and compare their size
load fisheriris X = meas; Y = species; Mdl = fitcdiscr (X, Y, 'ClassNames', unique (species))
Mdl =
ClassificationDiscriminant
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
ScoreTransform: 'none'
NumObservations: 150
NumPredictors: 4
DiscrimType: 'linear'
Mu: [3x4 double]
Coeffs: [3x3 struct]
CMdl = crossval (Mdl)
CMdl =
ClassificationPartitionedModel
CrossValidatedModel: 'Discriminant'
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
NumObservations: 150
KFold: 10
ScoreTransform: 'none'
A character vector specifying the name of the response variable Y. This property is read-only.
Create a discriminant analysis classifier and its compact version and compare their size
load fisheriris X = meas; Y = species; Mdl = fitcdiscr (X, Y, 'ClassNames', unique (species))
Mdl =
ClassificationDiscriminant
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
ScoreTransform: 'none'
NumObservations: 150
NumPredictors: 4
DiscrimType: 'linear'
Mu: [3x4 double]
Coeffs: [3x3 struct]
CMdl = crossval (Mdl)
CMdl =
ClassificationPartitionedModel
CrossValidatedModel: 'Discriminant'
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
NumObservations: 150
KFold: 10
ScoreTransform: 'none'
An array of unique values of the response variable Y, which has the
same data types as the data in Y. This property is read-only.
ClassNames can have any of the following datatypes:
Create a discriminant analysis classifier and its compact version and compare their size
load fisheriris X = meas; Y = species; Mdl = fitcdiscr (X, Y, 'ClassNames', unique (species))
Mdl =
ClassificationDiscriminant
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
ScoreTransform: 'none'
NumObservations: 150
NumPredictors: 4
DiscrimType: 'linear'
Mu: [3x4 double]
Coeffs: [3x3 struct]
CMdl = crossval (Mdl)
CMdl =
ClassificationPartitionedModel
CrossValidatedModel: 'Discriminant'
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
NumObservations: 150
KFold: 10
ScoreTransform: 'none'
A numeric array whose shape follows DiscrimType, with
predictors and classes:
| DiscrimType | Sigma | LogDetSigma |
|---|---|---|
'linear', 'pseudoLinear' | scalar | |
'quadratic', 'pseudoQuadratic' | ||
'diagLinear' | scalar | |
'diagQuadratic' |
The linear family pools one covariance across the classes and the
quadratic family estimates one per class. This property is read-only,
but it is re-derived whenever DiscrimType or Gamma is
assigned.
Create a discriminant analysis classifier and its compact version and compare their size
load fisheriris X = meas; Y = species; Mdl = fitcdiscr (X, Y, 'ClassNames', unique (species))
Mdl =
ClassificationDiscriminant
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
ScoreTransform: 'none'
NumObservations: 150
NumPredictors: 4
DiscrimType: 'linear'
Mu: [3x4 double]
Coeffs: [3x3 struct]
CMdl = crossval (Mdl)
CMdl =
ClassificationPartitionedModel
CrossValidatedModel: 'Discriminant'
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
NumObservations: 150
KFold: 10
ScoreTransform: 'none'
A numeric matrix specifying the mean of the multivariate normal distribution of each corresponding class, where is the number of classes and is the number of predictors. This property is read-only.
Create a discriminant analysis classifier and its compact version and compare their size
load fisheriris X = meas; Y = species; Mdl = fitcdiscr (X, Y, 'ClassNames', unique (species))
Mdl =
ClassificationDiscriminant
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
ScoreTransform: 'none'
NumObservations: 150
NumPredictors: 4
DiscrimType: 'linear'
Mu: [3x4 double]
Coeffs: [3x3 struct]
CMdl = crossval (Mdl)
CMdl =
ClassificationPartitionedModel
CrossValidatedModel: 'Discriminant'
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
NumObservations: 150
KFold: 10
ScoreTransform: 'none'
A structure containing the coefficient matrices, where
is the number of classes. If the 'FillCoeffs' parameter
was set to 'off' in the original
ClassificationDiscriminant model, then Coeffs is empty
([]). This property is read-only.
Coeffs(i,j) contains the coefficients of the boundary between
the classes i and j in the following fields:
DiscrimType - A character vector
Class1 - ClassNames(i)
Class2 - ClassNames(j)
Const - A scalar
Linear - A vector with length as the number of predictors.
Quadratic - The quadratic family only. A
matrix, or a vector for 'diagQuadratic', following
the shape of Sigma.
The diagonal entries carry the two class names and nothing else. The
structure is rebuilt whenever DiscrimType, Gamma or
Prior is assigned.
Create a discriminant analysis classifier and its compact version and compare their size
load fisheriris X = meas; Y = species; Mdl = fitcdiscr (X, Y, 'ClassNames', unique (species))
Mdl =
ClassificationDiscriminant
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
ScoreTransform: 'none'
NumObservations: 150
NumPredictors: 4
DiscrimType: 'linear'
Mu: [3x4 double]
Coeffs: [3x3 struct]
CMdl = crossval (Mdl)
CMdl =
ClassificationPartitionedModel
CrossValidatedModel: 'Discriminant'
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
NumObservations: 150
KFold: 10
ScoreTransform: 'none'
A row vector with one entry per predictor, the value of Delta at
which that predictor’s coefficient is zero for every class and the
predictor leaves the model altogether. It is all zeros for the
quadratic family, which has no linear coefficients to eliminate.
This property is read-only, and it describes the fit rather than the
threshold: assigning Delta does not move it.
Create a discriminant analysis classifier and its compact version and compare their size
load fisheriris X = meas; Y = species; Mdl = fitcdiscr (X, Y, 'ClassNames', unique (species))
Mdl =
ClassificationDiscriminant
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
ScoreTransform: 'none'
NumObservations: 150
NumPredictors: 4
DiscrimType: 'linear'
Mu: [3x4 double]
Coeffs: [3x3 struct]
CMdl = crossval (Mdl)
CMdl =
ClassificationPartitionedModel
CrossValidatedModel: 'Discriminant'
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
NumObservations: 150
KFold: 10
ScoreTransform: 'none'
A scalar from 0 to 1, the least regularization that leaves the
correlation matrix invertible. It is 0 when the matrix is already
invertible, and positive when the predictors are collinear, in which
case a plain 'linear' or 'quadratic' fit is raised to it
rather than failing. Assigning a Gamma below it is refused.
This property is read-only.
Create a discriminant analysis classifier and its compact version and compare their size
load fisheriris X = meas; Y = species; Mdl = fitcdiscr (X, Y, 'ClassNames', unique (species))
Mdl =
ClassificationDiscriminant
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
ScoreTransform: 'none'
NumObservations: 150
NumPredictors: 4
DiscrimType: 'linear'
Mu: [3x4 double]
Coeffs: [3x3 struct]
CMdl = crossval (Mdl)
CMdl =
ClassificationPartitionedModel
CrossValidatedModel: 'Discriminant'
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
NumObservations: 150
KFold: 10
ScoreTransform: 'none'
A scalar for the linear family and a vector for the quadratic
one, one entry per class. It is computed in correlation space, as the
sum of the logarithms of the predictor variances plus the log
determinant of the correlation matrix, which is far better conditioned
than the covariance when the data are nearly collinear. A predictor
with no variance contributes nothing rather than an infinity, and the
'pseudo' types sum only over the directions that carry variance.
This property is read-only.
Create a discriminant analysis classifier and its compact version and compare their size
load fisheriris X = meas; Y = species; Mdl = fitcdiscr (X, Y, 'ClassNames', unique (species))
Mdl =
ClassificationDiscriminant
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
ScoreTransform: 'none'
NumObservations: 150
NumPredictors: 4
DiscrimType: 'linear'
Mu: [3x4 double]
Coeffs: [3x3 struct]
CMdl = crossval (Mdl)
CMdl =
ClassificationPartitionedModel
CrossValidatedModel: 'Discriminant'
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
NumObservations: 150
KFold: 10
ScoreTransform: 'none'
A character vector naming the discriminant model, one of
'linear', 'quadratic', 'diagLinear',
'diagQuadratic', 'pseudoLinear' or
'pseudoQuadratic'. A linear type pools one covariance across
the classes; a quadratic type estimates one per class. A
'diag' type keeps only the variances, and a 'pseudo'
type inverts a singular covariance instead of refusing it.
This property may be assigned, but only within its own family:
the three linear types interchange freely and so do the three quadratic
ones, while no assignment moves a model between the two. The family is
fixed when the model is fitted, because it decides which covariances the
fit has to estimate. Assigning re-derives Sigma,
LogDetSigma, Gamma and Coeffs.
Create a discriminant analysis classifier and its compact version and compare their size
load fisheriris X = meas; Y = species; Mdl = fitcdiscr (X, Y, 'ClassNames', unique (species))
Mdl =
ClassificationDiscriminant
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
ScoreTransform: 'none'
NumObservations: 150
NumPredictors: 4
DiscrimType: 'linear'
Mu: [3x4 double]
Coeffs: [3x3 struct]
CMdl = crossval (Mdl)
CMdl =
ClassificationPartitionedModel
CrossValidatedModel: 'Discriminant'
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
NumObservations: 150
KFold: 10
ScoreTransform: 'none'
A scalar from 0 to 1 shrinking the covariance towards its diagonal.
Gamma and DiscrimType are one state: a value of 1 is the
diagonal type, so assigning it renames DiscrimType to
'diagLinear' or 'diagQuadratic', and assigning a
diagonal type sets Gamma to 1.
The quadratic family admits 0 and 1 only. A value below
MinGamma is refused, since it would leave the covariance
singular. Assigning re-derives Sigma, LogDetSigma and
Coeffs.
Create a discriminant analysis classifier and its compact version and compare their size
load fisheriris X = meas; Y = species; Mdl = fitcdiscr (X, Y, 'ClassNames', unique (species))
Mdl =
ClassificationDiscriminant
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
ScoreTransform: 'none'
NumObservations: 150
NumPredictors: 4
DiscrimType: 'linear'
Mu: [3x4 double]
Coeffs: [3x3 struct]
CMdl = crossval (Mdl)
CMdl =
ClassificationPartitionedModel
CrossValidatedModel: 'Discriminant'
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
NumObservations: 150
KFold: 10
ScoreTransform: 'none'
A nonnegative scalar that eliminates predictors. A per-class linear
coefficient is set to zero when it falls below Delta, and the
comparison is made on the standardized coefficient, the
coefficient times the within-class standard deviation of its predictor.
Scaling matters here: a threshold on the raw coefficients would depend
on the units each predictor is measured in, so the same model in
centimetres and in metres would drop different predictors.
DeltaPredictor reports, per predictor, the value at which it
drops out of every class at once.
It applies to the linear family only, a quadratic discriminant having no
linear coefficients to eliminate. Assigning it rebuilds Coeffs
and changes what predict answers.
Create a discriminant analysis classifier and its compact version and compare their size
load fisheriris X = meas; Y = species; Mdl = fitcdiscr (X, Y, 'ClassNames', unique (species))
Mdl =
ClassificationDiscriminant
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
ScoreTransform: 'none'
NumObservations: 150
NumPredictors: 4
DiscrimType: 'linear'
Mu: [3x4 double]
Coeffs: [3x3 struct]
CMdl = crossval (Mdl)
CMdl =
ClassificationPartitionedModel
CrossValidatedModel: 'Discriminant'
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
NumObservations: 150
KFold: 10
ScoreTransform: 'none'
A square matrix specifying the cost of misclassification of a point.
Cost(i,j) is the cost of classifying a point into class j
if its true class is i (that is, the rows correspond to the true
class and the columns correspond to the predicted class). The order of
the rows and columns in Cost corresponds to the order of the
classes in ClassNames. The number of rows and columns in
Cost is the number of unique classes in the response. By
default, Cost(i,j) = 1 if i != j, and
Cost(i,j) = 0 if i = j. In other words, the cost is 0
for correct classification and 1 for incorrect classification.
This property is read-only.
A cost may also be given as a struct with the fields
ClassNames and ClassificationCosts, which names the
order its own matrix is written in. That matrix is permuted into the
order of ClassNames above, so a caller need not know which
order the classes were sorted into. It must name every class.
A cost must be floating point, not sparse, not complex, non-negative
and zero down its diagonal, and must hold no NaN or
Inf. A single is widened to double.
Create a discriminant analysis classifier and its compact version and compare their size
load fisheriris X = meas; Y = species; Mdl = fitcdiscr (X, Y, 'ClassNames', unique (species))
Mdl =
ClassificationDiscriminant
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
ScoreTransform: 'none'
NumObservations: 150
NumPredictors: 4
DiscrimType: 'linear'
Mu: [3x4 double]
Coeffs: [3x3 struct]
CMdl = crossval (Mdl)
CMdl =
ClassificationPartitionedModel
CrossValidatedModel: 'Discriminant'
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
NumObservations: 150
KFold: 10
ScoreTransform: 'none'
A numeric vector specifying the prior probabilities for each class. The
order of the elements in Prior corresponds to the order of the
classes in ClassNames.
This property is read-only.
Specified as a row vector with one entry per class, in the order of
ClassNames, and rescaled to sum to one. It may be given as
'empirical', 'uniform', a numeric vector, or a
structure with ClassNames and ClassProbs fields, which
assigns each probability by class name rather than by position.
Create a discriminant analysis classifier and its compact version and compare their size
load fisheriris X = meas; Y = species; Mdl = fitcdiscr (X, Y, 'ClassNames', unique (species))
Mdl =
ClassificationDiscriminant
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
ScoreTransform: 'none'
NumObservations: 150
NumPredictors: 4
DiscrimType: 'linear'
Mu: [3x4 double]
Coeffs: [3x3 struct]
CMdl = crossval (Mdl)
CMdl =
ClassificationPartitionedModel
CrossValidatedModel: 'Discriminant'
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
NumObservations: 150
KFold: 10
ScoreTransform: 'none'
Specified as a function handle for transforming the classification scores. This property is read-only.
When specified as a character vector, it can be any of the following
built-in functions. Nevertheless, the ScoreTransform property
always stores their function handle equivalent.
| Value | Description |
|---|---|
'doublelogit' | |
'invlogit' | |
'ismax' | Sets the score for the class with the largest score to 1, and for all other classes to 0 |
'logit' | |
'none' | (no transformation) |
'identity' | (no transformation) |
'sign' | |
'symmetric' | |
'symmetricismax' | Sets the score for the class with the largest score to 1, and for all other classes to -1 |
'symmetriclogit' |
Create a discriminant analysis classifier and its compact version and compare their size
load fisheriris X = meas; Y = species; Mdl = fitcdiscr (X, Y, 'ClassNames', unique (species))
Mdl =
ClassificationDiscriminant
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
ScoreTransform: 'none'
NumObservations: 150
NumPredictors: 4
DiscrimType: 'linear'
Mu: [3x4 double]
Coeffs: [3x3 struct]
CMdl = crossval (Mdl)
CMdl =
ClassificationPartitionedModel
CrossValidatedModel: 'Discriminant'
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
NumObservations: 150
KFold: 10
ScoreTransform: 'none'
The CompactClassificationDiscriminant class offers the following public methods:
CompactClassificationDiscriminant: n = nLinearCoeffs (obj)
CompactClassificationDiscriminant: n = nLinearCoeffs (obj, delta)
n = nLinearCoeffs (obj) returns the number of
predictors the discriminant keeps at its own Delta.
n = nLinearCoeffs (obj, delta) returns the
number it would keep at each threshold in delta, as a column
vector however delta is shaped.
A predictor survives a threshold when its DeltaPredictor reaches
it, the comparison including equality, so delta at exactly a
predictor’s own value still counts it. A threshold above every
DeltaPredictor therefore leaves nothing and returns zero.
The count is taken whatever the DiscrimType, as MATLAB takes it,
even though Delta regularizes the linear types alone.
See also: fitcdiscr, ClassificationDiscriminant, CompactClassificationDiscriminant
Create a discriminant analysis classifier and its compact version and compare their size
load fisheriris X = meas; Y = species; Mdl = fitcdiscr (X, Y, 'ClassNames', unique (species))
Mdl =
ClassificationDiscriminant
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
ScoreTransform: 'none'
NumObservations: 150
NumPredictors: 4
DiscrimType: 'linear'
Mu: [3x4 double]
Coeffs: [3x3 struct]
CMdl = crossval (Mdl)
CMdl =
ClassificationPartitionedModel
CrossValidatedModel: 'Discriminant'
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
NumObservations: 150
KFold: 10
ScoreTransform: 'none'
CompactClassificationDiscriminant: label = predict (obj, XC)
CompactClassificationDiscriminant: [label, score, cost] = predict (obj, XC)
label = predict (obj, XC) returns the vector of
labels predicted for the corresponding instances in XC, using the
corresponding labels from the trained ClassificationDiscriminant,
model, obj.
CompactClassificationDiscriminant class
object.
[label, score, cost] = predict (obj,
XC) also returns score, which contains the predicted class
scores or posterior probabilities for each instance of the corresponding
unique classes, and cost, which is a matrix containing the expected
cost of the classifications.
The score matrix contains the posterior probabilities for each class, calculated using the multivariate normal probability density function and the prior probabilities of each class. These scores are normalized to ensure they sum to 1 for each observation.
The cost matrix contains the expected classification cost for each class, computed based on the posterior probabilities and the specified misclassification costs.
See also: CompactClassificationDiscriminant, fitcdiscr
Create a discriminant analysis classifier and its compact version and compare their size
load fisheriris X = meas; Y = species; Mdl = fitcdiscr (X, Y, 'ClassNames', unique (species))
Mdl =
ClassificationDiscriminant
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
ScoreTransform: 'none'
NumObservations: 150
NumPredictors: 4
DiscrimType: 'linear'
Mu: [3x4 double]
Coeffs: [3x3 struct]
CMdl = crossval (Mdl)
CMdl =
ClassificationPartitionedModel
CrossValidatedModel: 'Discriminant'
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
NumObservations: 150
KFold: 10
ScoreTransform: 'none'
CompactClassificationDiscriminant: L = loss (obj, X, Y)
CompactClassificationDiscriminant: L = loss (…, name, value)
L = loss (obj, X, Y) computes the loss,
L, using the default loss function 'mincost'.
obj is a CompactClassificationDiscriminant object.
X must be a numeric matrix of input data where rows
correspond to observations and columns correspond to features or
variables.
Y is matrix or cell matrix containing the class labels
of corresponding predictor data in X. Y must have same
numbers of rows as X.
L = loss (…, name, value) allows
additional options specified by name-value pairs:
| Name | Value |
|---|---|
'LossFun' | Specifies the loss function to use.
Can be a function handle with four input arguments (C, S, W, Cost)
which returns a scalar value or one of:
’binodeviance’, ’classifcost’, ’classiferror’, ’exponential’,
’hinge’, ’logit’,’mincost’, ’quadratic’.
|
'Weights' | Specifies observation weights, must be
a numeric vector of length equal to the number of rows in X.
Default is ones (size (X, 1)). loss normalizes the weights so that
observation weights in each class sum to the prior probability of that
class. When you supply Weights, loss computes the weighted
classification loss. |
See also: CompactClassificationDiscriminant
Create a discriminant analysis classifier and its compact version and compare their size
load fisheriris X = meas; Y = species; Mdl = fitcdiscr (X, Y, 'ClassNames', unique (species))
Mdl =
ClassificationDiscriminant
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
ScoreTransform: 'none'
NumObservations: 150
NumPredictors: 4
DiscrimType: 'linear'
Mu: [3x4 double]
Coeffs: [3x3 struct]
CMdl = crossval (Mdl)
CMdl =
ClassificationPartitionedModel
CrossValidatedModel: 'Discriminant'
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
NumObservations: 150
KFold: 10
ScoreTransform: 'none'
CompactClassificationDiscriminant: m = margin (obj, X, Y)
m = margin (obj, X, Y) returns
the classification margins for obj with data X and
classification Y. m is a numeric vector of length size (X,1).
obj is a CompactClassificationDiscriminant object.
X must be a numeric matrix of input data where rows
correspond to observations and columns correspond to features or
variables.
Y is matrix or cell matrix containing the class labels
of corresponding predictor data in X. Y must have same
numbers of rows as X.
The classification margin for each observation is the difference between the classification score for the true class and the maximal classification score for the false classes.
See also: fitcdiscr, CompactClassificationDiscriminant
Create a discriminant analysis classifier and its compact version and compare their size
load fisheriris X = meas; Y = species; Mdl = fitcdiscr (X, Y, 'ClassNames', unique (species))
Mdl =
ClassificationDiscriminant
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
ScoreTransform: 'none'
NumObservations: 150
NumPredictors: 4
DiscrimType: 'linear'
Mu: [3x4 double]
Coeffs: [3x3 struct]
CMdl = crossval (Mdl)
CMdl =
ClassificationPartitionedModel
CrossValidatedModel: 'Discriminant'
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
NumObservations: 150
KFold: 10
ScoreTransform: 'none'
CompactClassificationDiscriminant: e = edge (obj, X, Y)
CompactClassificationDiscriminant: e = edge (…, "Weights", w)
e = edge (obj, X, Y) reduces the vector
that margin returns to a single number, the mean margin over the
rows of X. It says how far the model puts the true class ahead of
its nearest rival on average, so a larger edge is a better model, and
unlike a loss it is not bounded above and rewards confidence rather than
bare correctness.
e = edge (…, takes the
weighted mean instead, with one weight per row of X.
"Weights", w)
Create a discriminant analysis classifier and its compact version and compare their size
load fisheriris X = meas; Y = species; Mdl = fitcdiscr (X, Y, 'ClassNames', unique (species))
Mdl =
ClassificationDiscriminant
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
ScoreTransform: 'none'
NumObservations: 150
NumPredictors: 4
DiscrimType: 'linear'
Mu: [3x4 double]
Coeffs: [3x3 struct]
CMdl = crossval (Mdl)
CMdl =
ClassificationPartitionedModel
CrossValidatedModel: 'Discriminant'
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
NumObservations: 150
KFold: 10
ScoreTransform: 'none'
CompactClassificationDiscriminant: M = mahal (obj, X)
CompactClassificationDiscriminant: M = mahal (…, 'ClassLabels', labels)
M = mahal (obj, X) returns an
matrix whose element is the squared Mahalanobis distance
from observation to the mean of class , measured
against the covariance that class carries: the one shared covariance
for a linear discriminant and the class’s own for a quadratic one.
CompactClassificationDiscriminant object.
M = mahal (…,
returns an vector instead, holding for each observation the
distance to the mean of the class labels names for it.
labels must have one entry per row of X, each of them one
of 'ClassLabels', labels)ClassNames.
The distance is measured against the covariance the model reports, so a regularized model is measured against its regularized covariance. The prior does not enter it.
Create a discriminant analysis classifier and its compact version and compare their size
load fisheriris X = meas; Y = species; Mdl = fitcdiscr (X, Y, 'ClassNames', unique (species))
Mdl =
ClassificationDiscriminant
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
ScoreTransform: 'none'
NumObservations: 150
NumPredictors: 4
DiscrimType: 'linear'
Mu: [3x4 double]
Coeffs: [3x3 struct]
CMdl = crossval (Mdl)
CMdl =
ClassificationPartitionedModel
CrossValidatedModel: 'Discriminant'
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
NumObservations: 150
KFold: 10
ScoreTransform: 'none'
CompactClassificationDiscriminant: lp = logp (obj, X)
lp = logp (obj, X) returns an
vector holding, for each row of X, the natural logarithm of
, the density of the observation summed
over the classes with each class weighted by its prior .
Each is the multivariate normal density of class
.
CompactClassificationDiscriminant object.
An unusually low value marks an observation the model finds unlikely under every class, which is what makes this an outlier test rather than a classification.
Create a discriminant analysis classifier and its compact version and compare their size
load fisheriris X = meas; Y = species; Mdl = fitcdiscr (X, Y, 'ClassNames', unique (species))
Mdl =
ClassificationDiscriminant
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
ScoreTransform: 'none'
NumObservations: 150
NumPredictors: 4
DiscrimType: 'linear'
Mu: [3x4 double]
Coeffs: [3x3 struct]
CMdl = crossval (Mdl)
CMdl =
ClassificationPartitionedModel
CrossValidatedModel: 'Discriminant'
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
NumObservations: 150
KFold: 10
ScoreTransform: 'none'
CompactClassificationDiscriminant: savemodel (obj, filename)
savemodel (obj, filename) saves each property of a
CompactClassificationDiscriminant object into an Octave binary file, the
name of which is specified in filename, along with an extra
variable, which defines the type classification object these variables
constitute. Use loadmodel in order to load a classification object
into Octave’s workspace.
See also: loadmodel, fitcdiscr, ClassificationDiscriminant
Create a discriminant analysis classifier and its compact version and compare their size
load fisheriris X = meas; Y = species; Mdl = fitcdiscr (X, Y, 'ClassNames', unique (species))
Mdl =
ClassificationDiscriminant
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
ScoreTransform: 'none'
NumObservations: 150
NumPredictors: 4
DiscrimType: 'linear'
Mu: [3x4 double]
Coeffs: [3x3 struct]
CMdl = crossval (Mdl)
CMdl =
ClassificationPartitionedModel
CrossValidatedModel: 'Discriminant'
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
NumObservations: 150
KFold: 10
ScoreTransform: 'none'
load fisheriris X = meas; Y = species; Mdl = fitcdiscr (X, Y, 'ClassNames', unique (species))
Mdl =
ClassificationDiscriminant
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
ScoreTransform: 'none'
NumObservations: 150
NumPredictors: 4
DiscrimType: 'linear'
Mu: [3x4 double]
Coeffs: [3x3 struct]
CMdl = crossval (Mdl)
CMdl =
ClassificationPartitionedModel
CrossValidatedModel: 'Discriminant'
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
NumObservations: 150
KFold: 10
ScoreTransform: 'none'