incremental learning overview -凯发k8网页登录

main content

incremental learning overview

what is incremental learning?

incremental learning, or online learning, is a branch of machine learning that involves processing incoming data from a data stream—continuously and in real time—possibly given little to no knowledge of the distribution of the predictor variables, sample size, aspects of the prediction or objective function (including adequate tuning parameter values), and whether the observations have labels. another type of incremental learning involves training a model and detecting anomalies in an incoming data stream (see ).

incremental learning algorithms are flexible, efficient, and adaptive. the following characteristics distinguish incremental learning from traditional machine learning:

  • an incremental model is fit to data quickly and efficiently, which means it can adapt, in real time, to changes (or drifts) in the data distribution.

  • because observation labels can be missing when corresponding predictor data is available, the algorithm must be able to generate predictions from the latest version of the model quickly, and defer training the model.

  • little information might be known about the population before incremental learning starts. therefore, the algorithm can be run with a cold start. for example, for classification problems, the class names might not be known until after the model processes observations. when enough information is known before learning begins (for example, you have good estimates of linear model coefficients), you can specify such information to provide the model with a warm start.

  • because observations can arrive in a stream, the sample size is likely unknown and possibly large, which makes data storage inefficient or impossible. therefore, the algorithm must process observations when they are available and before the system discards them. this incremental learning characteristic makes hyperparameter tuning difficult or impossible.

in traditional machine learning, a batch of labeled data is available to perform cross-validation to estimate the generalization error and tune hyperparameters, infer the predictor variable distribution, and fit the model. however, the resulting model must be retrained from the beginning if underlying distributions drift or the model degrades. although performing cross-validation to tune hyperparameters is difficult in an incremental learning environment, incremental learning methods are flexible because they can adapt to distribution drift in real time, with predictive accuracy approaching that of a traditionally trained model as the model trains more data.

suppose an incremental model is prepared to generate predictions and have its predictive performance measured. given incoming chunks of observations, an incremental learning scheme processes data in real time and in any of the following ways, but usually in the specified order:

  1. evaluate model: track the predictive performance of the model when true labels are available, either on the incoming data only, over a sliding window of observations, or over the entire history of the model used for incremental learning.

  2. detect drift: check for structural breaks or distribution drift. for example, determine whether the distribution of any predictor variable has sufficiently changed.

  3. train model: update the model by training it on the incoming observations, when true labels are available or when the current model has sufficiently degraded.

  4. generate predictions: predict labels from the latest model.

this procedure is a special case of incremental learning, in which all incoming chunks are treated as test (holdout) sets. the procedure is called interleaved test-then-train or prequential evaluation [1].

if insufficient information exists for an incremental model to generate predictions, or you do not want to track the predictive performance of the model because it has not been trained enough, you can include an optional initial step to find adequate values for hyperparameters, for models that support one (estimation period), or an initial training period before model evaluation (metrics warm-up period).

as an example of an incremental learning problem, consider a smart thermostat that automatically sets a temperature given the ambient temperature, relative humidity, time of day, and other measurements, and can learn the user's indoor temperature preferences. suppose the manufacturer prepared the device by embedding a known model that describes the average person's preferences given the measurements. after installation, the device collects data every minute, and adjusts the temperature to its presets. the thermostat adjusts the embedded model, or retrains itself, based on the user's actions or inactions with the device. this cycle can continue indefinitely. if the thermostat has limited disk space to store historical data, it needs to retrain itself in real time. if the manufacturer did not prepare the device with a known model, the device retrains itself more often.

incremental learning with matlab

statistics and machine learning toolbox™ functionalities enable you to implement incremental learning for classification or regression. like other statistics and machine learning toolbox machine learning functionalities, the entry point into incremental learning is an incremental learning object, which you pass to functions with data to implement incremental learning. unlike other machine learning functions, data is not required to create an incremental learning object. however, the incremental learning object specifies how to process incoming data, such as when to fit the model, measure performance metrics, or perform both actions, in addition to the parametric form of the model and problem-specific options.

incremental learning model objects

this table contains the available entry-point model objects for incremental learning with their supported machine learning objective, model type, and information required to create the model object.

model objectobjectivemodel typerequired information
multiclass classificationerror-correcting output codes (ecoc) model with binary learnersmaximum number of classes expected in the data during incremental learning or the names of all expected classes
binary classificationlinear support vector machine (svm) and logistic regression with gaussian kernelsnone
binary classificationlinear svm and logistic regressionnone
multiclass classificationnaive bayes with normal, multinomial, or multivariate multinomial predictor conditional distributionsmaximum number of classes expected in the data during incremental learning or the names of all expected classes
regressionleast-squares and linear svm regression with gaussian kernelsnone
regressionleast-squares and linear svm regressionnone

properties of an incremental learning model object specify:

  • data characteristics, such as the number of predictor variables numpredictors and their first and second moments

  • model characteristics, such as, for linear models, the learner type learner, linear coefficients beta, and intercept bias

  • training options, such as, for linear models, the objective solver solver and solver-specific hyperparameters such as the ridge penalty lambda for standard and average stochastic gradient descent (sgd and asgd)

  • model performance evaluation characteristics and options, such as whether the model is warm iswarm, which performance metrics to track metrics, and the latest values of the performance metrics

unlike when working with other machine learning model objects, you can create an incremental learning model by directly calling the object and specifying property values of options using name-value arguments; you do not need to fit a model to data to create one. this feature is convenient when you have little information about the data or model before training it. depending on your specifications, the software can enforce estimation and metrics warm-up periods, during which incremental fitting functions infer data characteristics and then train the model for performance evaluation. by default, for linear models, the software solves the objective function using the adaptive scale-invariant solver, which does not require tuning and is insensitive to the predictor variable scales [2] .

alternatively, you can convert a traditionally trained model to a model for incremental learning by using the incrementallearner function. for example, converts a trained linear classification model of type classificationlinear to an incrementalclassificationlinear object. this table lists the convertible models and their conversion functions.

traditionally trained convertible model objectconversion functionmodel object for incremental learning
classificationecoc and compactclassificationecoc
classificationkernel
classificationsvm and compactclassificationsvm
classificationlinear
regressionsvm and compactregressionsvm
regressionlinear

by default, the software considers converted models to be prepared for all aspects of incremental learning (converted models are warm). incrementallearner carries over data characteristics (such as class names), fitted parameters, and options available for incremental learning from the traditionally trained model being converted. for example:

  • for naive bayes classification, incrementallearner carries over all class names in the data expected during incremental learning, and the fitted moments of the conditional predictor distributions (distributionparameters).

  • for linear models, if the objective solver of the traditionally trained model is sgd, incrementallearner sets the incremental learning solver to sgd.

for more details, see the output argument description of each incrementallearner function page.

incremental learning functions

the incremental learning model object specifies all aspects of the incremental learning algorithm, from training and model evaluation preparation through training and model evaluation. to implement incremental learning, you pass the configured incremental learning model to an incremental fitting function or model evaluation function. you can find the list of supported incremental learning functions in the object functions section of each incremental learning model object page.

statistics and machine learning toolbox incremental learning functions offer two workflows that are well suited for prequential learning. for simplicity, the following workflow descriptions assume that the model is prepared to evaluate the model performance (in other words, the model is warm).

  • flexible workflow — when a data chunk is available:

    1. compute cumulative and window model performance metrics by passing the data and current model to the updatemetrics function. the data is treated as test (holdout) data because the model has not been trained on it yet. updatemetrics overwrites the model performance stored in the model with the new values.

    2. optionally detect distribution drift or whether the model has degraded.

    3. train the model by passing the incoming data chunk and current model to the fit function. the fit function uses the specified solver to fit the model to the incoming data chunk, and overwrites the current coefficients and bias with the new estimates.

    the flexible workflow enables you to perform custom model and data quality assessments before deciding whether to train the model. all steps are optional, but call updatemetrics before fit when you plan to call both functions.

  • succinct workflow — when a data chunk is available, supply the incoming chunk and a configured incremental model to the updatemetricsandfit function. updatemetricsandfit calls updatemetrics immediately followed by fit. the succinct workflow enables you to implement incremental learning with prequential evaluation easily when you plan to track the model performance and train the model on all incoming data chunks.

once you create an incremental model object and choose a workflow to use, write a loop that implements incremental learning:

  1. read a chunk of observations from a data stream, when the chunk is available.

  2. implement the flexible or succinct workflow. to perform incremental learning properly, overwrite the input model with the output model. for example:

    • flexible workflow

      mdl = updatemetrics(mdl,x,y);
      %
      % insert optional code
      %
      mdl = fit(mdl,x,y);
    • succinct workflow

      mdl = updatemetricsandfit(mdl,x,y);

    the model tracks its performance on incoming data incrementally using metrics measured since the beginning of training (cumulative) and over a specified window of consecutive observations (window). however, you can optionally compute the model loss on the incoming chunk, and then pass the incoming chunk and current model to the loss function. loss returns the scalar loss; it does not adjust the model.

    model configurations determine whether incremental learning functions train or evaluate model performance during each iteration. configurations can change as the functions process data. for more details, see incremental learning periods.

  3. optionally:

    • generate predictions by passing the chunk and latest model to predict.

    • if the model was fit to data, compute the resubstitution loss by passing the chunk and latest model to loss.

    • for naive bayes classification models, the function enables you to detect outliers in real-time. the function returns the log unconditional probability density of the predictor variables at each observation in the chunk.

incremental learning periods

given incoming chunks of data, the actions performed by incremental learning functions depend on the current configuration or state of the model. this figure shows the periods (consecutive groups of observations) during which incremental learning functions perform particular actions.

number line showing the periods during which incremental learning functions perform certain actions

this table describes the actions performed by incremental learning functions during each period.

periodassociated model propertiessize (number of observations)actions
estimationestimationperiod, applies to linear classification, kernel classification, linear regression, and kernel regression models only

n1

when required, fitting functions choose values for hyperparameters based on estimation period observations. actions can include the following:

  • estimate the predictor moments mu and sigma for data standardization (applies to linear and kernel models only).

  • adjust the learning rate learnrate for sgd solvers according to the learning rate schedule learnrateschedule.

  • estimate the svm regression parameter ε epsilon.

  • store information buffers required for estimation.

  • update corresponding properties at the end of the period.

for more details, see the algorithms section of each object and incrementallearner function page.

metrics warm-upmetricswarmupperiod

n2n1

when the property iswarm is false, fitting functions perform the following actions:

  • fit the model to the incoming chunk of data.

  • update corresponding model properties, such as beta or distributionparameters, after fitting the model.

  • at the end of the period, the model is warm (the iswarm property becomes true).

performance evaluation jmetrics and metricswindowsizem
  • at the start of performance evaluation period 1, functions begin to track cumulative cumulative and window window metrics. window is a vector of nans throughout this period.

  • functions overwrite cumulative metrics with the updated cumulative metric at each iteration. at the end of each performance evaluation period, functions compute and overwrite window metrics based on the last m observations.

  • functions store information buffers required for computing model performance.

references

[1] bifet, albert, ricard gavaldá, geoffrey holmes, and bernhard pfahringer. machine learning for data streams with practical example in moa. cambridge, ma: the mit press, 2007.

[2] kempka, michał, wojciech kotłowski, and manfred k. warmuth. "adaptive scale-invariant online algorithms for learning linear models." preprint, submitted february 10, 2019. .

see also

objects

  • | |

related topics

    网站地图