reset
Syntax
Description
Mdl = reset(
returns the incremental model
Mdl
)Mdl
with reset learned parameters. If any hyperparameters of
Mdl
are estimated during incremental training,
reset
function resets these hyperparameters as well.
reset
always preserves Mdl.Numpredictors
property.
For incremental classification models, reset
always preserves
Mdl.ClassNames
property and resets Mdl.Prior
if it
is "empirical"
.
Examples
Reset Incremental Classification Model
Load the human activity data set. Randomly shuffle the data.
load humanactivity n = numel(actid); rng(1); % For reproducibility idx = randsample(n,n); X = feat(idx,:); Y = actid(idx);
For details on the data set, enter Description
at the command line.
Responses can be one of five classes: Sitting, Standing, Walking, Running, or Dancing. Dichotomize the response by identifying whether the subject is moving (actid > 2).
Y = Y > 2;
Create an incremental linear SVM model for binary classification. Configure it for loss by specifying the class names, prior class distribution (uniform), and arbitrary coefficient and bias values. Specify a metrics window size of 1000 observations.
p = size(X,2); Beta = randn(p,1); Bias = randn(1); Mdl = incrementalClassificationLinear('Beta',Beta,'Bias',Bias,... 'ClassNames',unique(Y),'Prior','uniform','MetricsWindowSize',1000,'Metrics','classiferror');
Mdl
is an incrementalClassificationLinear
model. All its properties are read-only.
Simulate a data stream with incoming chunks of 50 observations each.
Call
updateMetricsAndFit
to update the performance metrics and fit the model to the incoming window of data. Overwrite the previous incremental model with the new one.Investigate the model.
Call
reset
to reset the learned parameters and compare to the previous model to see which parameters are reset.
numObsPerChunk = 50; nchunk = floor(n/numObsPerChunk); for j = 1:nchunk ibegin = min(n,numObsPerChunk*(j-1) + 1); iend = min(n,numObsPerChunk*j); idx = ibegin:iend; Mdl = updateMetricsAndFit(Mdl,X(idx,:),Y(idx)); end
Display some of the model parameters.
Mdl
Mdl = incrementalClassificationLinear IsWarm: 1 Metrics: [1x2 table] ClassNames: [0 1] ScoreTransform: 'none' Beta: [60x1 double] Bias: -0.9069 Learner: 'svm'
Mdl.Metrics
ans=1×2 table
Cumulative Window
__________ ______
ClassificationError 0.0018185 0
Mdl.Beta(1:10)
ans = 10×1
-0.8806
-0.0259
1.6498
12.0393
0.4948
8.9050
0.1317
0.0006
0.1071
0.0092
The model is warm (IsWarm
=1), you can see the value of the performance metric, ClassificationError
, estimations for the model parameters, Bias
and Beta
.
Reset the model and display the same parameters.
newMdl = reset(Mdl)
newMdl = incrementalClassificationLinear IsWarm: 0 Metrics: [1x2 table] ClassNames: [0 1] ScoreTransform: 'none' Beta: [60x1 double] Bias: 0 Learner: 'svm'
newMdl.Metrics
ans=1×2 table
Cumulative Window
__________ ______
ClassificationError NaN NaN
newMdl.Beta(1:10)
ans = 10×1
0
0
0
0
0
0
0
0
0
0
reset
function resets the warmup status of the model (IsWarm
= 0), the values of the performance metrics and the estimated model parameters. In addition to these, it resets the properties, such as NumTrainingObservations
, that the software updates at each iteration.
Input Arguments
Mdl
— Incremental learning model
incrementalClassificationKernel
model object | incrementalClassificationLinear
model object | incrementalClassificationECOC
model object | incrementalClassificationNaiveBayes
model object
Incremental learning model, specified as an incrementalClassificationKernel
, incrementalClassificationLinear
, incrementalClassificationECOC
, or incrementalClassificationNaiveBayes
model object. You can create
Mdl
directly or by converting a supported, traditionally trained
machine learning model using the incrementalLearner
function. For
more details, see the corresponding object page.
Version History
Introduced in R2022a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)