ClassificationNeuralNetwork
Create a ClassificationNeuralNetwork
class object containing a Neural
Network classification model.
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 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 same numbers of rows as X.
obj = ClassificationNeuralNetwork (…, name,
value)
returns a ClassificationNeuralNetwork object with parameters
specified by Name-Value
pair arguments. Type help fitcnet
for more info.
A ClassificationNeuralNetwork
object, obj, stores the labelled
training data and various parameters for the Neural Network classification
model, which can be accessed in the following fields:
Field | Description | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
X | Unstandardized predictor data, specified as a numeric matrix. Each column of X represents one predictor (variable), and each row represents one observation. | |||||||||||||
Y | Class labels, specified as a logical or numeric vector, or cell array of character vectors. Each value in Y is the observed class label for the corresponding row in X. | |||||||||||||
NumObservations | Number of observations used in
training the model, specified as a positive integer scalar. This number can
be less than the number of rows in the training data because rows containing
NaN values are not part of the fit. | |||||||||||||
RowsUsed | Rows of the original training data
used in fitting the ClassificationNeuralNetwork model, specified as a
numerical vector. If you want to use this vector for indexing the training
data in X, you have to convert it to a logical vector, i.e
X = obj.X(logical (obj.RowsUsed), :); | |||||||||||||
Standardize | A boolean flag indicating whether the data in X have been standardized prior to training. | |||||||||||||
Sigma | Predictor standard deviations, specified
as a numeric vector of the same length as the columns in X. If the
predictor variables have not been standardized, then "obj.Sigma" is
empty. | |||||||||||||
Mu | Predictor means, specified as a numeric
vector of the same length as the columns in X. If the predictor
variables have not been standardized, then "obj.Mu" is empty. | |||||||||||||
NumPredictors | The number of predictors (variables) in X. | |||||||||||||
PredictorNames | Predictor variable names, specified as a cell array of character vectors. The variable names are in the same order in which they appear in the training data X. | |||||||||||||
ResponseName | Response variable name, specified as a character vector. | |||||||||||||
ClassNames | Names of the classes in the class
labels, Y, used for fitting the ClassificationNeuralNetwork model.
ClassNames are of the same type as the class labels in Y. | |||||||||||||
LayerSizes | Sizes of the fully connected layers in the neural network model, returned as a positive integer vector. The ith element of LayerSizes is the number of outputs in the ith 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. | |||||||||||||
Activations | A character vector or a cell array of character vector specifying the activation functions used in the hidden layers of the neural network. | |||||||||||||
OutputLayerActivation | A character vector specifying the activation function of the output layer the neural network. | |||||||||||||
LearningRate | A positive scalar value defining the learning rate used by the gradient descend algorithm during training. | |||||||||||||
IterationLimit | A positive scalar value defining the number of epochs for training the model. | |||||||||||||
DisplayInfo | A boolean flag indicating whether to print information during training. | |||||||||||||
ModelParameters | A structure containing the
parameters used to train the Neural Network classifier model containing the
fields LayerWeights and Activations as generated by the
fcnntrain function. | |||||||||||||
ConvergenceInfo | A structure containing the
Convergence info of the Neural Network classifier model with the following
fields:
| |||||||||||||
Solver | Solver used to train the neural network model, returned as ’Gradient Search’. | |||||||||||||
ScoreTransform | A function_handle which is used
for transforming the Neural Network prediction score into a posterior
probability. By default, it is 'none' , in which case the
predict and resubPredict methods return the prediction scores. |
See also: fitcnet, fcnntrain, fcnnpredict
Source Code: ClassificationNeuralNetwork
compact
Create a CompactClassificationNeuralNetwork object.
CVMdl = compact (obj)
creates a compact version of the
ClassificationNeuralNetwork object, obj.
See also: fitcnet, ClassificationNeuralNetwork, CompactClassificationNeuralNetwork
crossval
Cross Validate a Neural Network classification object.
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
predict
Classify new data points into categories using the Neural Network classification object.
labels = predict (obj, XC)
returns the vector of
labels predicted for the corresponding instances in XC, using the
trained neural network classification model in obj.
ClassificationNeuralNetwork
class object.
[labels, scores] = predict (obj, XC
also
returns scores, which represent the probability of each label
belonging to a specific class. For each observation in X, the predicted
class label is the one with the highest score among all classes.
Alternatively, scores can contain the posterior probabilities if
the ScoreTransform has been previously set.
See also: fitcnet, ClassificationNeuralNetwork
resubPredict
Classify the training data using the trained Neural Network classification object.
labels = 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.
[labels, scores] = resubPredict (obj, XC)
also returns scores, which represent the probability of each label
belonging to a specific class. For each observation in X, the predicted
class label is the one with the highest score among all classes.
Alternatively, scores can contain the posterior probabilities if
the ScoreTransform has been previously set.
See also: fitcnet, ClassificationNeuralNetwork
savemodel
Save a ClassificationNeuralNetwork object.
savemodel (obj, filename)
saves a
ClassificationNeuralNetwork object into a file defined by filename.
See also: loadmodel, fitcnet, ClassificationNeuralNetwork, cvpartition, ClassificationPartitionedModel