Expand description
Online / incremental learning algorithms for streaming data.
Implements three production-grade online learning algorithms:
- Perceptron — classic binary classifier; updates weights only on mispredictions.
- Passive-Aggressive (PA-I) — margin-based update with a soft constraint
(
Cparameter) that controls the trade-off between aggressiveness and passiveness. - SGD with Momentum — stochastic gradient descent with configurable momentum, learning rate, and L2 regularisation.
All algorithms share a unified OnlineLearner interface that tracks
running statistics (total updates, accuracy, average loss, weight norm).
§Examples
use ipfrs_tensorlogic::online_learner::{
OnlineLearner, OnlineAlgorithm, OlLossFunction, TrainingSample,
};
let mut learner = OnlineLearner::new(
OnlineAlgorithm::Perceptron,
2,
OlLossFunction::Hinge,
);
let sample = TrainingSample { features: vec![1.0, 0.5], label: 1.0 };
learner.update(&sample).expect("example: should succeed in docs");
let class = learner.predict_class(&[1.0, 0.5]).expect("example: should succeed in docs");
assert!(class == 1 || class == -1);Structs§
- Online
Learner - Online / incremental learner supporting Perceptron, Passive-Aggressive, and SGD-with-Momentum algorithms.
- Online
Learner Stats - Running statistics tracked by
OnlineLearneracross all updates and predictions. - Training
Sample - A single labelled training example for online learning.
Enums§
- Learner
Error - Errors that can be raised by
OnlineLearneroperations. - OlLoss
Function - Loss function used for computing per-sample losses and SGD gradients.
- Online
Algorithm - Online learning algorithm selection.