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.
See also: fitcdiscr, ClassificationDiscriminant
Source Code: CompactClassificationDiscriminant
A positive integer value specifying the number of predictors in the training dataset used for training the CompactClassificationDiscriminant model. This property is read-only.
A cell array of character vectors specifying the names of the predictor variables. The names are in the order in which the appear in the training dataset. This property is read-only.
A character vector specifying the name of the response variable Y. This property is read-only.
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:
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.
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.
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. Nevertherless, 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" |
A numeric array specifying the within-class covariance. For linear discriminant type (currently supported) this is a matrix, where is the number of predictors. This property is read-only.
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.
A @math {KxK structure containing the coeeficient 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 linear (currently
supported) boundaries 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.
A nonnegative scalar specifying the threshold for linear discriminant model. Currently unimplemented and fixed to 0. This property is read-only.
A character vector specifying the type discriminant model. Currently only linear discriminant models are supported. This property is read-only.
A scalar value ranging from 0 to 1, specifying the Gamma regularization parameter. This property is read-only.
A scalar value ranging from 0 to 1, specifying the minimum value that the Gamma regularization parameter can have. This property is read-only.
A scalar value specifying the logarithm of the determinant of the within-class covariance matrix. This property is read-only.
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
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
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
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
# and compare their size load fisheriris X = meas; Y = species; Mdl = fitcdiscr (X, Y, 'ClassNames', unique (species)) CMdl = crossval (Mdl) |
Mdl =
ClassificationDiscriminant
ResponseName: 'Y'
ClassNames: {'setosa' 'versicolor' 'virginica'}
ScoreTransform: 'none'
NumObservations: 150
NumPredictors: 4
DiscrimType: 'linear'
Mu: [3x4 double]
Coeffs: [4x4 struct]
CMdl =
ClassificationPartitionedModel object with properties:
BinEdges: []
CategoricalPredictors: []
X: [5.1000, 3.5000, 1.4000, 0.2000; 4.9000, 3, 1.4000, 0.2000; 4.7000, 3.2000, ...]
Y: [150x1 cell]
ClassNames: [3x1 cell]
Cost: [0, 1, 1; 1, 0, 1; 1, 1, 0]
CrossValidatedModel: 'ClassificationDiscriminant'
KFold: 10
ModelParameters: [1x1 struct]
NumObservations: 150
Partition: [1x1 cvpartition]
PredictorNames: [1x4 cell]
Prior: [0.3333; 0.3333; 0.3333]
ResponseName: 'Y'
ScoreTransform: [1x1 function_handle]
Standardize: []
Trained: [10x1 cell]
|