Online machine learning

Short description: Method of machine learning

Not to be confused with online and offline.

Machine learning and
data mining

Problems

* Classification
* Clustering
* Regression
* Anomaly detection
* AutoML
* Association rules
* Reinforcement learning
* Structured prediction
* Feature engineering
* Feature learning
* Online learning
* Semi-supervised learning
* Unsupervised learning
* Learning to rank
* Grammar induction

Supervised learning
(classification • regression)

* Decision trees
* Ensembles
* Bagging
* Boosting
* Random forest
* k-NN
* Linear regression
* Naive Bayes
* Artificial neural networks
* Logistic regression
* Perceptron
* Relevance vector machine (RVM)
* Support vector machine (SVM)

Clustering

* BIRCH
* CURE
* Hierarchical
* k-means
* Expectation–maximization (EM)

DBSCAN
* OPTICS
* Mean-shift

Dimensionality reduction

* Factor analysis
* CCA
* ICA
* LDA
* NMF
* PCA
* t-SNE

Structured prediction

* Graphical models
* Bayes net
* Conditional random field
* Hidden Markov

Anomaly detection

* k-NN
* Local outlier factor

Artificial neural networks

* Autoencoder
* Deep learning
* DeepDream
* Multilayer perceptron
* RNN
* LSTM
* GRU
* Restricted Boltzmann machine
* GAN
* SOM
* Convolutional neural network
* U-Net

Reinforcement learning

* Q-learning
* SARSA
* Temporal difference (TD)

Theory

* Bias–variance dilemma
* Computational learning theory
* Empirical risk minimization
* Occam learning
* PAC learning
* Statistical learning
* VC theory

Machine-learning venues

* NeurIPS
* ICML
* ML
* JMLR
* ArXiv:cs.LG

Glossary of artificial intelligence

* Glossary of artificial intelligence

Related articles

* List of datasets for machine-learning research
* Outline of machine learning

* v
* t
* e

In computer science, online machine learning is a method of machine learning in which data becomes available in a sequential order and is used to update the best predictor for future data at each step, as opposed to batch learning techniques which generate the best predictor by learning on the entire training data set at once. Online learning is a common technique used in areas of machine learning where it is computationally infeasible to train over the entire dataset, requiring the need of out-of-core algorithms. It is also used in situations where it is necessary for the algorithm to dynamically adapt to new patterns in the data, or when the data itself is generated as a function of time, e.g., prediction of prices in the financial international markets. Online learning algorithms may be prone to catastrophic interference, a problem that can be addressed by incremental learning approaches.

Online machine learning algorithms find applications in a wide variety of fields such as sponsored search to maximize ad revenue, portfolio optimization, shortest path prediction (with stochastic weights, e.g. traffic on roads for a maps application), spam filtering, real-time fraud detection, dynamic pricing for e-commerce, etc. There is also growing interest in usage of online learning paradigms for LLMs to enable continuous, real-time adaptation after the initial training.[1]

## Contents

* 1 Introduction
* 2 Statistical view of online learning
* 2.1 Example: linear least squares
* 2.2 Batch learning
* 2.3 Online learning: recursive least squares
* 2.4 Stochastic gradient descent
* 2.5 Incremental stochastic gradient descent
* 2.6 Kernel methods
* 2.7 Online convex optimization
* 2.7.1 Follow the leader (FTL)
* 2.7.2 Follow the regularised leader (FTRL)
* 2.8 Online subgradient descent (OSD)
* 2.9 Other algorithms
* 3 Continual learning
* 4 Interpretations of online learning
* 5 Implementations
* 6 See also
* 7 References
* 8 External links

## Introduction

In the setting of supervised learning, a function of f:X->Y is to be learned, where X is thought of as a space of inputs and Y as a space of outputs, that predicts well on instances that are drawn from a joint probability distribution p(x,y) on X×Y. In reality, the learner never knows the true distribution p(x,y) over instances. Instead, the learner usually has access to a training set of examples (x1,y1),…,(xn,yn). In this setting, the loss function is given as V:Y×Y->ℝ, such that V(f(x),y) measures the difference between the predicted value f(x) and the true value y. The ideal goal is to select a function f∈ℋ, where ℋ is a space of functions called a hypothesis space, so that some notion of total loss is minimized. Depending on the type of model (statistical or adversarial), one can devise different notions of loss, which lead to different learning algorithms.

## Statistical view of online learning

In statistical learning models, the training sample (xi,yi) are assumed to have been drawn from the true distribution p(x,y) and the objective is to minimize the expected "risk" I[f]=𝔼[V(f(x),y)]=∫V(f(x),y)dp(x,y) . A common paradigm in this situation is to estimate a function f^ through empirical risk minimization or regularized empirical risk minimization (usually Tikhonov regularization). The choice of loss function here gives rise to several well-known learning algorithms such as regularized least squares and support vector machines. A purely online model in this category would learn based on just the new input (xt+1,yt+1), the current best predictor ft and some extra stored information (which is usually expected to have storage requirements independent of training data size). For many formulations, for example nonlinear kernel methods, true online learning is not possible, though a form of hybrid online learning with recursive algorithms can be used where ft+1 is permitted to depend on ft and all previous data points (x1,y1),…,(xt,yt). In this case, the space requirements are no longer guaranteed to be constant since it requires storing all previous data points, but the solution may take less time to compute with the addition of a new data point, as compared to batch learning techniques.

A common strategy to overcome the above issues is to learn using mini-batches, which process a small batch of b≥1 data points at a time, this can be considered as pseudo-online learning for b much smaller than the total number of training points. Mini-batch techniques are used with repeated passing over the training data to obtain optimized out-of-core versions of machine learning algorithms, for example, stochastic gradient descent. When combined with backpropagation, this is currently the de facto training method for training artificial neural networks.

### Example: linear least squares

The simple example of linear least squares is used to explain a variety of ideas in online learning. The ideas are general enough to be applied to other settings, for example, with other convex loss functions.

### Batch learning

Consider the setting of supervised learning with f being a linear function to be learned: f(xj)=⟨w,xj⟩=w⋅xj where xj∈ℝd is a vector of inputs (data points) and w∈ℝd is a linear filter vector. The goal is to compute the filter vector w. To this end, a square loss function V(f(xj),yj)=(f(xj)−yj)2=(⟨w,xj⟩−yj)2 is used to compute the vector w that minimizes the empirical loss In[w]=∑j=1nV(⟨w,xj⟩,yj)=∑j=1n(xjTw−yj)2 where yj∈ℝ.

Let X be the i×d data matrix and y∈ℝi is the column vector of target values after the arrival of the first i data points. Assuming that the covariance matrix Σi=XTX is invertible (otherwise it is preferential to proceed in a similar fashion with Tikhonov regularization), the best solution f*(x)=⟨w*,x⟩ to the linear least squares problem is given by w*=(XTX)−1XTy=Σi−1∑j=1ixjyj.

Now, calculating the covariance matrix Σi=∑j=1ixjxjT takes time O(id2), inverting the d×d matrix takes time O(d3), while the rest of the multiplication takes time O(d2), giving a total time of O(id2+d3). When there are n total points in the dataset, to recompute the solution after the arrival of every datapoint i=1,…,n, the naive approach will have a total complexity O(n2d2+nd3). Note that when storing the matrix Σi, then updating it at each step needs only adding xi+1xi+1T, which takes O(d2) time, reducing the total time to O(nd2+nd3)=O(nd3), but with an additional storage space of O(d2) to store Σi.[2]

### Online learning: recursive least squares

The recursive least squares (RLS) algorithm considers an online approach to the least squares problem. It can be shown that by initialising w0=0∈ℝd and Γ0=I∈ℝd×d, the solution of the linear least squares problem given in the previous section can be computed by the following iteration: Γi=Γi−1−Γi−1xixiTΓi−11+xiTΓi−1xi wi=wi−1−Γixi(xiTwi−1−yi) The above iteration algorithm can be proved using induction on i.[3] The proof also shows that Γi=Σi−1. One can look at RLS also in the context of adaptive filters (see RLS).

The complexity for n steps of this algorithm is O(nd2), which is an order of magnitude faster than the corresponding batch learning complexity. The storage requirements at every step i here are to store the matrix Γi, which is constant at O(d2). For the case when Σi is not invertible, consider the regularised version of the problem loss function ∑j=1n(xjTw−yj)2+λ‖w‖22. Then, it's easy to show that the same algorithm works with Γ0=(I+λI)−1, and the iterations proceed to give Γi=(Σi+λI)−1.[2]

### Stochastic gradient descent

Main article: Stochastic gradient descent

When this wi=wi−1−Γixi(xiTwi−1−yi) is replaced by wi=wi−1−γixi(xiTwi−1−yi)=wi−1−γi∇V(⟨wi−1,xi⟩,yi) or Γi∈ℝd×d by γi∈ℝ, this becomes the stochastic gradient descent algorithm. In this case, the complexity for n steps of this algorithm reduces to O(nd). The storage requirements at every step i are constant at O(d).

However, the stepsize γi needs to be chosen carefully to solve the expected risk minimization problem, as detailed above. By choosing a decaying step size γi≈1i, one can prove the convergence of the average iterate w‾n=1n∑i=1nwi. This setting is a special case of stochastic optimization, a well known problem in optimization.[2]

### Incremental stochastic gradient descent

In practice, one can perform multiple stochastic gradient passes (also called cycles or epochs) over the data. The algorithm thus obtained is called incremental gradient method and corresponds to an iteration wi=wi−1−γi∇V(⟨wi−1,xti⟩,yti) The main difference with the stochastic gradient method is that here a sequence ti is chosen to decide which training point is visited in the i-th step. Such a sequence can be stochastic or deterministic. The number of iterations is then decoupled to the number of points (each point can be considered more than once). The incremental gradient method can be shown to provide a minimizer to the empirical risk.[4] Incremental techniques can be advantageous when considering objective functions made up of a sum of many terms e.g. an empirical error corresponding to a very large dataset.[2]

### Kernel methods

See also: Kernel method

Kernels can be used to extend the above algorithms to non-parametric models (or models where the parameters form an infinite dimensional space). The corresponding procedure will no longer be truly online and instead involve storing all the data points, but is still faster than the brute force method. This discussion is restricted to the case of the square loss, though it can be extended to any convex loss. It can be shown by an easy induction [2] that if Xi is the data matrix and wi is the output after i steps of the SGD algorithm, then, wi=XiTci where ci=((ci)1,(ci)2,...,(ci)i)∈ℝi and the sequence ci satisfies the recursion: c0=0 (ci)j=(ci−1)j,j=1,2,...,i−1 and (ci)i=γi(yi−∑j=1i−1(ci−1)j⟨xj,xi⟩) Notice that here ⟨xj,xi⟩ is just the standard Kernel on ℝd, and the predictor is of the form fi(x)=⟨wi−1,x⟩=∑j=1i−1(ci−1)j⟨xj,x⟩.

Now, if a general kernel K is introduced instead and let the predictor be fi(x)=∑j=1i−1(ci−1)jK(xj,x) then the same proof will also show that predictor minimising the least squares loss is obtained by changing the above recursion to (ci)i=γi(yi−∑j=1i−1(ci−1)jK(xj,xi)) The above expression requires storing all the data for updating ci. The total time complexity for the recursion when evaluating for the n-th datapoint is O(n2dk), where k is the cost of evaluating the kernel on a single pair of points.[2] Thus, the use of the kernel has allowed the movement from a finite dimensional parameter space wi∈ℝd to a possibly infinite dimensional feature represented by a kernel K by instead performing the recursion on the space of parameters ci∈ℝi, whose dimension is the same as the size of the training dataset. In general, this is a consequence of the representer theorem.[2]

### Online convex optimization

Online convex optimization (OCO) [5] is a general framework for decision making which leverages convex optimization to allow for efficient algorithms. The framework is that of repeated game playing as follows:

For t=1,2,...,T

* Learner receives input xt
* Learner outputs wt from a fixed convex set S
* Nature sends back a convex loss function vt:S->ℝ.
* Learner suffers loss vt(wt) and updates its model

The goal is to minimize regret, or the difference between cumulative loss and the loss of the best fixed point u∈S in hindsight. As an example, consider the case of online least squares linear regression. Here, the weight vectors come from the convex set S=ℝd, and nature sends back the convex loss function vt(w)=(⟨w,xt⟩−yt)2. Note here that yt is implicitly sent with vt.

Some online prediction problems however cannot fit in the framework of OCO. For example, in online classification, the prediction domain and the loss functions are not convex. In such scenarios, two simple techniques for convexification are used: randomisation and surrogate loss functions [6].

Some simple online convex optimisation algorithms are:

#### Follow the leader (FTL)

The simplest learning rule to try is to select (at the current step) the hypothesis that has the least loss over all past rounds. This algorithm is called Follow the leader, and round t is simply given by: wt=argminw∈S∑i=1t−1vi(w) This method can thus be looked as a greedy algorithm. For the case of online quadratic optimization (where the loss function is vt(w)=‖w−xt‖22), one can show a regret bound that grows as log⁡(T). However, similar bounds cannot be obtained for the FTL algorithm for other important families of models like online linear optimization. To do so, one modifies FTL by adding regularisation.

#### Follow the regularised leader (FTRL)

This is a natural modification of FTL that is used to stabilise the FTL solutions and obtain better regret bounds. A regularisation function R:S->ℝ is chosen and learning performed in round t as follows: wt=argminw∈S∑i=1t−1vi(w)+R(w) As a special example, consider the case of online linear optimisation i.e. where nature sends back loss functions of the form vt(w)=⟨w,zt⟩. Also, let S=ℝd. Suppose the regularisation function R(w)=12η‖w‖22 is chosen for some positive number η. Then, one can show that the regret minimising iteration becomes wt+1=−η∑i=1tzi=wt−ηzt Note that this can be rewritten as wt+1=wt−η∇vt(wt), which looks exactly like online gradient descent.

If S is instead some convex subspace of ℝd, S would need to be projected onto, leading to the modified update rule wt+1=ΠS(−η∑i=1tzi)=ΠS(ηθt+1) This algorithm is known as lazy projection, as the vector θt+1 accumulates the gradients. It is also known as Nesterov's dual averaging algorithm. In this scenario of linear loss functions and quadratic regularisation, the regret is bounded by O(T), and thus the average regret goes to 0 as desired.

### Online subgradient descent (OSD)

See also: Subgradient method

The above proved a regret bound for linear loss functions vt(w)=⟨w,zt⟩. To generalise the algorithm to any convex loss function, the subgradient ∂vt(wt) of vt is used as a linear approximation to vt near wt, leading to the online subgradient descent algorithm:

Initialise parameter η,w1=0

For t=1,2,...,T

* Predict using wt, receive ft from nature.
* Choose zt∈∂vt(wt)
* If S=ℝd, update as wt+1=wt−ηzt
* If S⊂ℝd, project cumulative gradients onto S i.e. wt+1=ΠS(ηθt+1),θt+1=θt+zt

One can use the OSD algorithm to derive O(T) regret bounds for the online version of SVM's for classification, which use the hinge lossvt(w)=max⁡{0,1−yt(w⋅xt)}

### Other algorithms

Quadratically regularised FTRL algorithms lead to lazily projected gradient algorithms as described above. To use the above for arbitrary convex functions and regularisers, one uses online mirror descent. The optimal regularization in hindsight can be derived for linear loss functions, this leads to the AdaGrad algorithm. For the Euclidean regularisation, one can show a regret bound of O(T), which can be improved further to a O(log⁡T) for strongly convex and exp-concave loss functions.

## Continual learning

Continual learning means constantly improving the learned model by processing continuous streams of information.[7] Continual learning capabilities are essential for software systems and autonomous agents interacting in an ever changing real world. However, continual learning is a challenge for machine learning and neural network models since the continual acquisition of incrementally available information from non-stationary data distributions generally leads to catastrophic forgetting.

## Interpretations of online learning

The paradigm of online learning has different interpretations depending on the choice of the learning model, each of which has distinct implications about the predictive quality of the sequence of functions f1,f2,…,fn. The prototypical stochastic gradient descent algorithm is used for this discussion. As noted above, its recursion is given by wt=wt−1−γt∇V(⟨wt−1,xt⟩,yt)

The first interpretation consider the stochastic gradient descent method as applied to the problem of minimizing the expected risk I[w] defined above.[8] Indeed, in the case of an infinite stream of data, since the examples (x1,y1),(x2,y2),… are assumed to be drawn i.i.d. from the distribution p(x,y), the sequence of gradients of V(⋅,⋅) in the above iteration are an i.i.d. sample of stochastic estimates of the gradient of the expected risk I[w] and therefore one can apply complexity results for the stochastic gradient descent method to bound the deviation I[wt]−I[w∗], where w∗ is the minimizer of I[w].[9] This interpretation is also valid in the case of a finite training set; although with multiple passes through the data the gradients are no longer independent, still complexity results can be obtained in special cases.

The second interpretation applies to the case of a finite training set and considers the SGD algorithm as an instance of incremental gradient descent method.[4] In this case, one instead looks at the empirical risk: In[w]=1n∑i=1nV(⟨w,xi⟩,yi) . Since the gradients of V(⋅,⋅) in the incremental gradient descent iterations are also stochastic estimates of the gradient of In[w], this interpretation is also related to the stochastic gradient descent method, but applied to minimize the empirical risk as opposed to the expected risk. Since this interpretation concerns the empirical risk and not the expected risk, multiple passes through the data are readily allowed and actually lead to tighter bounds on the deviations In[wt]−In[wn∗], where wn∗ is the minimizer of In[w].

## Implementations

* Vowpal Wabbit: Open-source fast out-of-core online learning system which is notable for supporting a number of machine learning reductions, importance weighting and a selection of different loss functions and optimisation algorithms. It uses the hashing trick for bounding the size of the set of features independent of the amount of training data.
* scikit-learn: Provides out-of-core implementations of algorithms for
* Classification: Perceptron, SGD classifier, Naive bayes classifier.
* Regression: SGD Regressor, Passive Aggressive regressor.
* Clustering: Mini-batch k-means.
* Feature extraction: Mini-batch dictionary learning, Incremental PCA.

## See also

Learning paradigms

* Incremental learning
* Lazy learning
* Offline learning, the opposite model
* Reinforcement learning
* Multi-armed bandit
* Supervised learning

General algorithms

* Online algorithm
* Online optimization
* Streaming algorithm
* Stochastic gradient descent

Learning models

* Adaptive Resonance Theory
* Hierarchical temporal memory
* k-nearest neighbor algorithm
* Learning vector quantization
* Perceptron

## References

1. ↑ Liang, Juhao; Wang, Ziwei; Ma, Zhuoheng; Li, Jianquan; Zhang, Zhiyi; Wu, Xiangbo; Wang, Benyou (2024). "Online Training of Large Language Models: Learn while Chatting". arXiv:2403.04790v1 [cs.CL].
2. ↑ 2.0 2.1 2.2 2.3 2.4 2.5 2.6 L. Rosasco, T. Poggio, Machine Learning: a Regularization Approach, MIT-9.520 Lectures Notes, Manuscript, Dec. 2015. Chapter 7 - Online Learning
3. ↑ Kushner, Harold J.; Yin, G. George (2003). Stochastic Approximation and Recursive Algorithms with Applications (Second ed.). New York: Springer. pp. 8–12. ISBN 978-0-387-21769-7. https://archive.org/details/stochasticapprox00yinh.
4. ↑ 4.0 4.1 Bertsekas, D. P. (2011). Incremental gradient, subgradient, and proximal methods for convex optimization: a survey. Optimization for Machine Learning, 85.
5. ↑ Hazan, Elad (2015). Introduction to Online Convex Optimization. Foundations and Trends in Optimization. http://ocobook.cs.princeton.edu/OCObook.pdf.
6. ↑ Zhuang, Zhenxun; Cutkosky, Ashok; Orabona, Francesco (2019). "Surrogate Losses for Online Learning of Stepsizes in Stochastic Non-Convex Optimization". Proceedings of the 36th International Conference on Machine Learning. Proceedings of Machine Learning Research. 97. pp. 7664–7672. https://proceedings.mlr.press/v97/zhuang19a.html.
7. ↑ Parisi, German I.; Kemker, Ronald; Part, Jose L.; Kanan, Christopher; Wermter, Stefan (2019). "Continual lifelong learning with neural networks: A review". Neural Networks 113: 54–71. doi:10.1016/j.neunet.2019.01.012. ISSN 0893-6080. PMID 30780045. http://dx.doi.org/10.1016/j.neunet.2019.01.012.
8. ↑ Bottou, Léon (1998). "Online Algorithms and Stochastic Approximations". Online Learning and Neural Networks. Cambridge University Press. ISBN 978-0-521-65263-6. https://archive.org/details/onlinelearningin0000unse.
9. ↑ Stochastic Approximation Algorithms and Applications, Harold J. Kushner and G. George Yin, New York: Springer-Verlag, 1997. ISBN 0-387-94916-X; 2nd ed., titled Stochastic Approximation and Recursive Algorithms and Applications, 2003, ISBN 0-387-00894-2.

## External links

* 6.883: Online Methods in Machine Learning: Theory and Applications. Alexander Rakhlin. MIT

0.00

(0 votes)

Original source: https://en.wikipedia.org/wiki/Online machine learning. Read more

|

Retrieved from "https://handwiki.org/wiki/index.php?title=Online_machine_learning&oldid=4414571"
*[v]: View this template
*[t]: Discuss this template
*[e]: Edit this template