label = predict(Mdl,X)
returns a vector of predicted class labels for the data in the table or matrix
X, based on the semi-supervised self-trained classifier
Mdl.
[label,score] = predict(Mdl,X)
also returns a matrix of scores indicating the likelihood that a label comes from a
particular class. For each observation in X, the predicted class label
corresponds to the maximum score among all classes.
Fit labels to the unlabeled data by using a semi-supervised self-training method. The function fitsemiself returns a SemiSupervisedSelfTrainingModel object whose FittedLabels property contains the fitted labels for the unlabeled data and whose LabelScores property contains the associated label scores.
Randomly generate 150 observations of new data, with 50 observations per class. For the purposes of validation, keep track of the true labels for the new data.
Predict the labels for the new data by using the predict function of the SemiSupervisedSelfTrainingModel object. Compare the true labels to the predicted labels by using a confusion matrix.
Predictor data to be classified, specified as a numeric matrix or table. Each row of
X corresponds to one observation, and each column corresponds to
one variable.
If you trained Mdl using matrix data (X and
UnlabeledX in the call to fitsemiself), then
specify X as a numeric matrix.
The variables in the columns of X must have the same
order as the predictor variables that trained Mdl.
The software treats the predictors in X whose indices
match Mdl.CategoricalPredictors as categorical
predictors.
If you trained Mdl using tabular data (Tbl
and UnlabeledTbl in the call to fitsemiself),
then specify X as a table.
All predictor variables in X must have the same variable
names and data types as those that trained Mdl (stored in
Mdl.PredictorNames). However, the column order of
X does not need to correspond to the column order of
Tbl. Also, Tbl and X
can contain additional variables (for example, response variables), but
predict ignores them.
predict does not support multicolumn variables or cell
arrays other than cell arrays of character vectors.
Predicted class labels, returned as a categorical or character array, logical or
numeric vector, or cell array of character vectors. label has the
same data type as the fitted class labels Mdl.FittedLabels, and its
length is equal to the number of rows in X.
Predicted class scores, returned as a numeric matrix. score has
size m-by-K, where m is the
number of observations (or rows) in X and K is
the number of classes in Mdl.ClassNames.
score(m,k) is the likelihood that observation
m in X belongs to class k,
where a higher score value indicates a higher likelihood. The range of score values
depends on the underlying classifier Mdl.Learner.