reset
Syntax
Description
Examples
Create a default one-class support vector machine (SVM) model for incremental anomaly detection using the stochastic gradient descent (SGD) solver. Specify to standardize the predictor data. Reset the model after incremental training and see which parameters are reset.
IncrementalMdl = incrementalOneClassSVM(Solver="sgd",StandardizeData=true)
IncrementalMdl = incrementalOneClassSVM IsWarm: 0 ContaminationFraction: 0 ScoreThreshold: 0 NumExpansionDimensions: 0 Lambda: 1.0000e-05 KernelScale: 1 Properties, Methods
IncrementalMdl
is an incrementalOneClassSVM
model object. All its properties are read-only. By default, the software sets the anomaly contamination fraction to 0 and the score threshold to 0.
IncrementalMdl
must be fit to data before you can use it to perform any other operations.
Load Data
Load the 1994 census data stored in census1994.mat
. The data set consists of demographic data from the US Census Bureau.
load census1994.mat
The fit
function of incrementalOneClassSVM
does not support categorical predictors and does not use observations with missing values. Remove missing values in the data to reduce memory consumption and speed up training. Remove the categorical predictors.
adultdata = rmmissing(adultdata); adultdata = removevars(adultdata,["workClass","education","marital_status", ... "occupation","relationship","race","sex","native_country","salary"]);
Fit Incremental Model
Fit the incremental model IncrementalMdl
to the data by using the fit
function. To simulate a data stream, fit the model in chunks of 100 observations at a time. At each iteration:
Process 100 observations.
Overwrite the previous incremental model with a new one fitted to the incoming observations.
n = numel(adultdata(:,1)); numObsPerChunk = 100; nchunk = floor(n/numObsPerChunk); % Incremental fitting rng("default"); % For reproducibility for j = 1:nchunk ibegin = min(n,numObsPerChunk*(j-1) + 1); iend = min(n,numObsPerChunk*j); idx = ibegin:iend; IncrementalMdl = fit(IncrementalMdl,adultdata(idx,:)); end
Display all the properties of the trained model object IncrementalMdl
.
details(IncrementalMdl);
incrementalOneClassSVM with properties: KernelScale: 1 Lambda: 1.0000e-05 NumExpansionDimensions: 256 SolverOptions: [1×1 struct] Solver: 'sgd' FittedLoss: 'hinge' Mu: [37.9400 1.9217e+05 10.1980 567.7170 102.5340 40.7060] Sigma: [12.8905 1.0789e+05 2.5006 2.4309e+03 431.7485 11.7970] EstimationPeriod: 1000 IsWarm: 1 ContaminationFraction: 0 NumTrainingObservations: 29100 NumPredictors: 6 ScoreThreshold: 2.0912 ScoreWarmupPeriod: 0 PredictorNames: {'age' 'fnlwgt' 'education_num' 'capital_gain' 'capital_loss' 'hours_per_week'} ScoreWindowSize: 1000 Methods, Superclasses
Reset Incremental Model
Reset the learned parameters by using the reset
function, and compare them to the previous model to see which parameters are reset.
newMdl = reset(IncrementalMdl); details(newMdl)
incrementalOneClassSVM with properties: KernelScale: 1 Lambda: 1.0000e-05 NumExpansionDimensions: 256 SolverOptions: [1×1 struct] Solver: 'sgd' FittedLoss: 'hinge' Mu: [0 0 0 0 0 0] Sigma: [1 1 1 1 1 1] EstimationPeriod: 1000 IsWarm: 0 ContaminationFraction: 0 NumTrainingObservations: 0 NumPredictors: 6 ScoreThreshold: 0 ScoreWarmupPeriod: 0 PredictorNames: {'age' 'fnlwgt' 'education_num' 'capital_gain' 'capital_loss' 'hours_per_week'} ScoreWindowSize: 1000 Methods, Superclasses
The
reset
function resets the warmup status of the model (IsWarm
= 0), the score threshold, the number of training observations, and the estimated hyperparameters (Mu
and Sigma
).
Input Arguments
Incremental one-class SVM model, specified as an
incrementalOneClassSVM
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 incrementalOneClassSVM
object page.
Version History
Introduced in R2023b
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.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- 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)