ClassificationNeuralNetwork
statistics: ClassificationNeuralNetwork
Neural network classification
The ClassificationNeuralNetwork class implements a neural network
classifier object, which can predict responses for new data using the
predict method.
Neural network classification is a machine learning method that uses interconnected nodes in multiple layers to learn complex patterns in data. It processes inputs through hidden layers with activation functions to produce classification outputs.
Create a ClassificationNeuralNetwork object by using the
fitcnet function or the class constructor.
See also: fitcnet
Source Code: ClassificationNeuralNetwork
A numeric matrix containing the unstandardized predictor data. Each column of X represents one predictor (variable), and each row represents one observation. This property is read-only.
Specified as a logical or numeric column vector, or as a character array or a cell array of character vectors with the same number of rows as the predictor data. Each row in Y is the observed class label for the corresponding row in X. This property is read-only.
A positive integer value specifying the number of observations in the training dataset used for training the ClassificationNeuralNetwork model. This property is read-only.
A logical column vector with the same length as the observations in the original predictor data X specifying which rows have been used for fitting the ClassificationNeuralNetwork model. This property is read-only.
A positive integer value specifying the number of predictors in the training dataset used for training the ClassificationNeuralNetwork 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:
Specified as a function handle for transforming the classification
scores. Add or change the ScoreTransform property using dot
notation as in:
obj.ScoreTransform = 'function_name'
obj.ScoreTransform = @function_handle
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 boolean flag indicating whether the predictor data has been standardized
prior to training. When true, the predictors are centered and
scaled to have zero mean and unit variance. This property is read-only.
A numeric vector containing the standard deviations of the predictors
used for standardization. Empty if Standardize is false.
This property is read-only.
A numeric vector containing the means of the predictors used for
standardization. Empty if Standardize is false.
This property is read-only.
A positive integer vector specifying the sizes of the fully connected
layers in the neural network model. The i-th element of LayerSizes
is the number of outputs in the i-th fully connected layer of the neural
network model. LayerSizes does not include the size of the final
fully connected layer. This layer always has K outputs, where K is the
number of classes in Y. This property is read-only.
A character vector or cell array of character vectors specifying the
activation functions used in the hidden layers of the neural network.
Supported activation functions include: "linear",
"sigmoid", "relu", "tanh", "softmax",
"lrelu", "prelu", "elu", and "gelu".
This property is read-only.
A character vector specifying the activation function of the output layer
of the neural network. Supported activation functions are the same as
for the Activations property. This property is read-only.
A positive scalar value defining the learning rate used by the gradient descent algorithm during training. This property is read-only.
A positive integer value defining the maximum number of epochs for training the model. This property is read-only.
A structure containing the parameters used to train the neural network
classifier model, including layer weights and activations as generated by
the fcnntrain function. This property is read-only.
A structure containing convergence information of the neural network classifier model with the following fields:
Accuracy - The prediction accuracy at each iteration
during training
TrainingLoss - The loss value recorded at each iteration
during training
Time - The cumulative time taken for all iterations in
seconds
This property is read-only.
A boolean flag indicating whether to print information during training. This property is read-only.
A character vector specifying the solver algorithm used to train the
neural network model. Currently only "Gradient Descend" is
supported. This property is read-only.
statistics: obj = ClassificationNeuralNetwork (X, Y)
statistics: obj = ClassificationNeuralNetwork (…, name, value)
obj = ClassificationNeuralNetwork (X, Y) returns
a ClassificationNeuralNetwork object, with X as the predictor data
and Y containing the class labels of observations in X.
X must be a numeric matrix of input data where rows
correspond to observations and columns correspond to features or
variables. X will be used to train the neural network model.
Y is matrix or cell matrix containing the class labels
of corresponding predictor data in X. Y can contain any type
of categorical data. Y must have the same number of rows as
X.
obj = ClassificationNeuralNetwork (…, name,
value) returns a ClassificationNeuralNetwork object with
parameters specified by the following name, value
paired input arguments:
| Name | Value | |
|---|---|---|
'PredictorNames' | A cell array of character vectors specifying the names of the predictors. The length of this array must match the number of columns in X. | |
'ResponseName' | A character vector specifying the name of the response variable. | |
'ClassNames' | Names of the classes in the class
labels, Y, used for fitting the neural network model.
ClassNames are of the same type as the class labels in Y. | |
'ScoreTransform' | A user-defined function handle
or a character vector specifying one of the following builtin functions
specifying the transformation applied to predicted classification scores.
Supported values include 'doublelogit', 'invlogit',
'ismax', 'logit', 'none', 'identity',
'sign', 'symmetric', 'symmetricismax', and
'symmetriclogit'. | |
'Standardize' | A logical scalar specifying whether
to standardize the predictor data. When true, the predictors are
centered and scaled to have zero mean and unit variance. | |
'LayerSizes' | A positive integer vector specifying the sizes of the fully connected layers in the neural network. The default is 10. | |
'Activations' | A character vector or cell array of
character vectors specifying the activation functions for the hidden
layers. Supported values include 'linear', 'sigmoid',
'relu', 'tanh', 'softmax', 'lrelu',
'prelu', 'elu', and 'gelu'. The default is
'sigmoid'. | |
'OutputLayerActivation' | A character vector
specifying the activation function for the output layer. Supported
values are the same as for 'Activations'. The default is
'sigmoid'. | |
'LearningRate' | A positive scalar specifying the learning rate for gradient descent. The default is 0.01. | |
'IterationLimit' | A positive integer specifying the maximum number of training iterations. The default is 1000. | |
'DisplayInfo' | A logical scalar specifying whether
to display training information. The default is false. |
See also: fitcnet
ClassificationNeuralNetwork: label = predict (obj, XC)
ClassificationNeuralNetwork: [label, score] = predict (obj, XC)
label = predict (obj, XC) returns the vector of
labels predicted for the corresponding instances in XC, using the
predictor data in obj.X and corresponding labels, obj.Y,
stored in the ClassificationNeuralNetwork model, obj.
ClassificationNeuralNetwork class object.
[label, score] = predict (obj, XC) also
returns score, which contains the predicted class scores or
posterior probabilities for each instance of the corresponding unique
classes.
The score matrix contains the classification scores for each class.
For each observation in XC, the predicted class label is the one
with the highest score among all classes. If the ScoreTransform
property is set to a transformation function, the scores are transformed
accordingly before being returned.
See also: ClassificationNeuralNetwork, fitcnet
ClassificationNeuralNetwork: label = resubPredict (obj)
ClassificationNeuralNetwork: [label, score] = resubPredict (obj)
label = resubPredict (obj) returns the vector of
labels predicted for the corresponding instances in the training data,
using the predictor data in obj.X and corresponding labels,
obj.Y, stored in the neural network classification model,
obj.
ClassificationNeuralNetwork class object.
[label, score] = resubPredict (obj) also
returns score, which contains the predicted class scores or
posterior probabilities for each instance of the corresponding unique
classes.
See also: ClassificationNeuralNetwork, fitcnet
ClassificationNeuralNetwork: CVMdl = crossval (obj)
ClassificationNeuralNetwork: CVMdl = crossval (…, Name, Value)
CVMdl = crossval (obj) returns a cross-validated model
object, CVMdl, from a trained model, obj, using 10-fold
cross-validation by default.
CVMdl = crossval (obj, name, value)
specifies additional name-value pair arguments to customize the
cross-validation process.
| Name | Value | |
|---|---|---|
"KFold" | Specify the number of folds to use in
k-fold cross-validation. "KFold", k, where k is an
integer greater than 1. | |
"Holdout" | Specify the fraction of the data to
hold out for testing. "Holdout", p, where p is a
scalar in the range . | |
"Leaveout" | Specify whether to perform
leave-one-out cross-validation. "Leaveout", Value, where
Value is ’on’ or ’off’. | |
"CVPartition" | Specify a cvpartition
object used for cross-validation. "CVPartition", cv, where
isa (cv, "cvpartition") = 1. |
See also: fitcnet, ClassificationNeuralNetwork, cvpartition, ClassificationPartitionedModel
ClassificationNeuralNetwork: CVMdl = compact (obj)
CVMdl = compact (obj) creates a compact version of the
ClassificationNeuralNetwork object, obj.
See also: fitcnet, ClassificationNeuralNetwork, CompactClassificationNeuralNetwork
ClassificationNeuralNetwork: savemodel (obj, filename)
savemodel (obj, filename) saves each property of a
ClassificationNeuralNetwork 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, fitcnet, ClassificationNeuralNetwork