irithyll 10.0.1

Streaming ML in Rust -- gradient boosted trees, neural architectures (TTT/KAN/MoE/Mamba/SNN), AutoML, kernel methods, and composable pipelines
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
# Model Specifications

This document is the canonical reference for every learning algorithm, neural architecture, and
preprocessing primitive in irithyll. Each section answers the same four questions: what is it,
when should you use it, what math drives it, and how do you configure and run it.

**How to read this document.** Start with the tier table to locate the model class, then jump
to the relevant section. The [README](README.md) gives a high-level overview and quick-start
snippets. [REFERENCES.md](REFERENCES.md) contains the full bibliography; this document links
to specific anchors there. [BENCHMARKS.md](BENCHMARKS.md) has quantitative comparisons across
datasets.

Every model implements [`StreamingLearner`](https://docs.rs/irithyll/latest/irithyll/trait.StreamingLearner.html)
unless noted otherwise. Train and predict with `model.train(features, target)` /
`model.predict(features)`. Preprocessors implement `StreamingPreprocessor` and slot into
pipelines via `pipe(preprocessor).learner(model)`.

---

## Tier Summary

| Tier | Count | Models |
|------|-------|--------|
| [Production]#production-tier | 10 | SGBT family (5 variants), RLS, KRLS, StreamingLinearModel, MondrianForest, LocallyWeightedRegression |
| [Neural — Reservoir]#neural-tier--reservoir-computing | 2 | NextGenRC, EchoStateNetwork |
| [Neural — State Space Models]#neural-tier--state-space-models | 3 | StreamingMamba, StreamingMambaV3, BDLRUMamba |
| [Neural — Spiking]#neural-tier--spiking-neural-networks | 2 | SpikeNet, SpikeNetFixed |
| [Neural — TTT]#neural-tier--test-time-training | 1 | StreamingTTT |
| [Neural — KAN]#neural-tier--kolmogorov-arnold-networks | 2 | StreamingKAN, TKAN |
| [Neural — Online Extensions]#neural-tier--online-learning-extensions | 4 | StreamingAGMP, StreamingMGrade, StreamingHGRN2, StreamingLSTM |
| [Neural — Attention]#neural-tier--streaming-linear-attention | 11 modes | GLA, GatedDeltaNet, DeltaNet, DeltaProduct, RWKV-7, HGRN2, Hawk, RetNet, mLSTM, RWKV, Log-Linear |
| [Ensemble]#ensemble-tier | 5 | NeuralMoE, AdaptiveRandomForest, MulticlassSGBT, MultiTargetSGBT, DistributionalSGBT |
| [Specialized]#specialized-tier | 5 | GaussianNB, HalfSpaceTree, ContinualLearner, ClassificationWrapper, ProjectedLearner |
| [Preprocessing]#preprocessing | 9 | IncrementalNormalizer, CCIPCA, OnlineFeatureSelector, TargetEncoder, TargetScaler, TargetLog1pTransform, FeatureHasher, OneHotEncoder, PolynomialExpander |
| [Clustering]#clustering | 3 | StreamingKMeans, CluStream, DBStream |
| [AutoML]#streaming-automl | 2 | AutoTuner, Factory |

---

## Production Tier

The production tier contains the algorithms that have been most extensively validated across
diverse streaming benchmarks. Use these by default; reach into the neural tier when temporal
structure is the primary signal.

---

### SGBT

[`SGBT`](https://docs.rs/irithyll/latest/irithyll/struct.SGBT.html) — Streaming Gradient Boosted Trees

The core algorithm of irithyll. An online ensemble of Hoeffding-bound streaming decision trees
arranged in boosting stages. Each stage owns a tree and a drift detector; drift replaces the
tree with a fresh alternate. This is the default choice for tabular streaming regression and
binary classification with concept drift.

**Paper / origin.** Gunasekara et al. (2024) — see [REFERENCES.md §Core Gradient Boosting](REFERENCES.md).

**Math summary.**

```
F(x) = base + lr * sum_{s=1}^{n_steps} tree_s(x)
h_s  = hessian of loss at residual (sample-weight)
tree_s updates histogram accumulators for its split candidates
Hoeffding bound: split when gain_best - gain_second >= sqrt(R^2 * ln(1/delta) / (2n))
```

Leaf predictions use EWMA decay (half-life configurable) and graduated sibling interpolation
for continuous output between discrete split points.

**Config reference.** [`SGBTConfig::builder()`](https://docs.rs/irithyll/latest/irithyll/struct.SGBTConfigBuilder.html)

Key parameters:
- `n_steps(usize)` — number of boosting stages (default: 100)
- `learning_rate(f64)` — shrinkage applied to each tree (default: 0.0125)
- `max_depth(usize)` — max depth per tree (default: 6)
- `grace_period(usize)` — min samples before split evaluation (default: 200)
- `drift_detector(DriftDetectorType)``PageHinkley`, `ADWIN`, or `DDM` (default: `PageHinkley`)
- `proactive_prune` — percentile-based worst-tree replacement for plasticity

**Example.**
```rust
use irithyll::{sgbt, StreamingLearner};

let mut model = sgbt(50, 0.01);  // 50 boosting steps, lr=0.01
model.train(&[1.0, 2.0], 3.0);
let pred = model.predict(&[1.0, 2.0]);

// Full builder for SHAP + drift config
use irithyll::{SGBTConfig, SGBT};
let config = SGBTConfig::builder()
    .n_steps(100)
    .learning_rate(0.0125)
    .max_depth(6)
    .grace_period(200)
    .build()
    .expect("valid config");
let mut model = SGBT::new(config);
let shap = model.explain(&[1.0, 2.0]);
```

**Benchmarks.** See [BENCHMARKS.md](BENCHMARKS.md) — Electricity (88.5% accuracy), Airlines, Covertype.

---

### AdaptiveSGBT

[`AdaptiveSGBT`](https://docs.rs/irithyll/latest/irithyll/struct.AdaptiveSGBT.html) — SGBT with online learning rate scheduling

Extends SGBT with configurable LR schedules (step decay, exponential, cosine) applied across
the stream. Use when the learning rate should decay or cycle over time rather than remain constant.

**Paper / origin.** Built on Gunasekara et al. (2024). LR schedule design draws from standard
SGD scheduling literature.

**Math summary.** Learning rate at sample t follows the selected schedule:
```
step:        lr_t = lr_0 * factor^floor(t / step_size)
exponential: lr_t = lr_0 * exp(-decay * t)
cosine:      lr_t = lr_min + 0.5*(lr_0 - lr_min)*(1 + cos(pi * t / T_max))
```

**Config reference.** [`LRSchedule`](https://docs.rs/irithyll/latest/irithyll/enum.LRSchedule.html) + `SGBTConfig`

Key parameters:
- `schedule(LRSchedule)``Step`, `Exponential`, `Cosine`, or `Constant`
- All base SGBT parameters apply

**Example.**
```rust
use irithyll::ensemble::AdaptiveSGBT;
use irithyll::ensemble::lr_schedule::LRSchedule;

let mut model = AdaptiveSGBT::new(base_config, LRSchedule::Cosine { lr_min: 0.001, t_max: 10_000 });
model.train(&[1.0, 2.0], 3.0);
```

**Benchmarks.** <!-- TODO: spec — no standalone benchmark row in BENCHMARKS.md yet. -->

---

### DistributionalSGBT

[`DistributionalSGBT`](https://docs.rs/irithyll/latest/irithyll/struct.DistributionalSGBT.html) — mean + variance SGBT for prediction uncertainty

Trains two parallel SGBT heads — one for the mean, one for the variance — producing a
Gaussian prediction `(mu, sigma)` per sample. Also exposes `honest_sigma`, the tree
contribution variance across ensemble stages, as a zero-hyperparameter epistemic uncertainty
signal. Use when you need calibrated prediction intervals or downstream uncertainty weighting.

**Paper / origin.** Gunasekara et al. (2024) for the core. `honest_sigma` and `adaptive_mts`
are irithyll extensions.

**Math summary.**
```
mu    = SGBT_mean(x)
sigma = SGBT_var(x)   (trains on squared residuals from mu head)
honest_sigma = std( { tree_s(x) : s = 1..n_steps } )
               — instant epistemic signal, one sample reaction time
adaptive_mts: tree_lifetime = base_mts * (1 - sigma_ratio * honest_sigma / sigma_threshold)
```

**Config reference.** Same as `SGBTConfig` plus:
- `honest_sigma()` method — zero-config epistemic signal
- `adaptive_mts(sigma_ratio)` — modulates tree lifetime with uncertainty

**Example.**
```rust
use irithyll::ensemble::DistributionalSGBT;
use irithyll::{SGBTConfig, StreamingLearner};

let config = SGBTConfig::builder().n_steps(50).build().unwrap();
let mut model = DistributionalSGBT::new(config);
model.train(&[1.0, 2.0], 3.0);
let (mu, sigma) = model.predict_distributional(&[1.0, 2.0]);
let epistemic = model.honest_sigma(&[1.0, 2.0]);
```

**Benchmarks.** Refer to [BENCHMARKS.md](BENCHMARKS.md) uncertainty evaluation rows.

---

### MulticlassSGBT

[`MulticlassSGBT`](https://docs.rs/irithyll/latest/irithyll/struct.MulticlassSGBT.html) — one-vs-rest SGBT for multi-class classification

Maintains one SGBT per class, each trained with softmax-normalized pseudo-residuals. At
prediction time, the class with the highest raw score wins. Per-sample cost scales linearly
with class count, so prefer this for up to ~20 classes; beyond that consider `NeuralMoE`
with classification wrappers.

**Paper / origin.** One-vs-rest strategy is classical; Gunasekara et al. (2024) for the
underlying SGBT. Softmax normalization follows Friedman (2001) multi-class gradient boosting.

**Math summary.**
```
p_k(x) = softmax( { F_k(x) : k = 1..K } )_k
residual_k = 1[y == k] - p_k(x)
Each F_k is an independent SGBT trained on its residuals.
Prediction: argmax_k F_k(x)
```

**Config reference.** `SGBTConfig` + number of classes at construction.

**Example.**
```rust
use irithyll::ensemble::MulticlassSGBT;
use irithyll::SGBTConfig;

let config = SGBTConfig::builder().n_steps(50).build().unwrap();
let mut model = MulticlassSGBT::new(config, 3);
model.train(&[1.0, 2.0], 0.0);  // class label as f64
let pred = model.predict(&[1.0, 2.0]);  // returns predicted class as f64
let proba = model.predict_proba(&[1.0, 2.0]);
```

**Benchmarks.** Covertype (7-class), see [BENCHMARKS.md](BENCHMARKS.md).

---

### MultiTargetSGBT

[`MultiTargetSGBT`](https://docs.rs/irithyll/latest/irithyll/struct.MultiTargetSGBT.html) — independent SGBTs for multi-output regression

One SGBT per output target, trained independently. Use when multiple continuous targets
share the same input features. Outputs are not modeled jointly; for correlated targets
consider a custom loss.

**Paper / origin.** Gunasekara et al. (2024). Independent multi-output extension.

**Math summary.**
```
F_j(x) = SGBT_j(x),  j = 1..n_targets
Per-sample cost: n_targets * O(n_steps * depth)
```

**Config reference.** `SGBTConfig` + `n_targets` at construction.

**Example.**
```rust
use irithyll::ensemble::MultiTargetSGBT;
use irithyll::SGBTConfig;

let config = SGBTConfig::builder().n_steps(30).build().unwrap();
let mut model = MultiTargetSGBT::new(config, 2);
model.train(&[1.0, 2.0], &[3.0, 4.0]);
let preds: Vec<f64> = model.predict_multi(&[1.0, 2.0]);
```

**Benchmarks.** <!-- TODO: spec — no dedicated multi-target benchmark row in BENCHMARKS.md yet. -->

---

### RecursiveLeastSquares (RLS)

[`RecursiveLeastSquares`](https://docs.rs/irithyll/latest/irithyll/struct.RecursiveLeastSquares.html) — exact online linear regression with confidence intervals

Exact online OLS via Sherman-Morrison rank-1 covariance update. Supports exponential
forgetting (`forgetting_factor < 1`), adaptive forgetting driven by error magnitude, and
calibrated prediction intervals. This is the readout layer inside every neural model in
irithyll; it is also a first-class StreamingLearner for linear regression tasks.

**Paper / origin.** Classical adaptive filtering; see Haykin (1996) *Adaptive Filter Theory*.
Adaptive forgetting is an irithyll extension.

**Math summary.**
```
Gain:      k_t  = P_{t-1} x_t / (lambda + x_t^T P_{t-1} x_t)
Weights:   w_t  = w_{t-1} + k_t * (y_t - x_t^T w_{t-1})
Covariance:P_t  = (P_{t-1} - k_t x_t^T P_{t-1}) / lambda
Interval:  CI   = w^T x +/- z * sqrt(sigma_n^2 * x^T P x)
```

**Config reference.** `rls(forgetting_factor)` factory or `RecursiveLeastSquares::new(ff)`

Key parameters:
- `forgetting_factor` — lambda in [0, 1]; lower = faster adaptation (default: 0.998)
- `delta` — initial P matrix diagonal (default: 100.0)

**Example.**
```rust
use irithyll::{rls, StreamingLearner, RecursiveLeastSquares};

let mut model = rls(0.99);
for i in 0..1000 {
    let x = i as f64 * 0.01;
    model.train(&[x], 2.0 * x + 1.0);
}
let (pred, lo, hi) = model.predict_interval(&[5.0], 1.96);
```

**Benchmarks.** Used as baseline in all neural model comparisons. See [BENCHMARKS.md](BENCHMARKS.md).

---

### KRLS

[`KRLS`](https://docs.rs/irithyll/latest/irithyll/struct.KRLS.html) — Kernel Recursive Least Squares

Nonlinear RLS in a kernel-induced feature space. Maintains a sparse dictionary of support
vectors via Approximate Linear Dependence (ALD) — new samples are added to the dictionary
only if they cannot be approximately represented by the existing set. Use for nonlinear
regression (sin, exp, interactions) where SGBT is not the right fit.

**Paper / origin.** Engel, Mannor & Meir (2004), "The Kernel Recursive Least Squares
Algorithm." IEEE TSP. — [citation needed for REFERENCES.md anchor]

**Math summary.**
```
ALD test: ||x - K_t^{-1} K_{x,D_t}||^2 > threshold  ->  add to dictionary
Prediction:  f(x) = sum_{i in D} alpha_i * k(x_i, x)
Update:      alpha += k_t * (y - f(x)),  K^{-1} rank-1 updated
|D| <= budget  (oldest entry evicted when full)
```

**Config reference.** `krls(gamma, budget, ald_threshold)` factory

Key parameters:
- `gamma` — RBF kernel bandwidth (default: 1.0)
- `budget` — max dictionary size; controls O(budget^2) cost (default: 100)
- `ald_threshold` — ALD novelty threshold for dictionary admission (default: 1e-4)
- Kernel: `RBFKernel`, `PolynomialKernel`, or `LinearKernel` via `KRLS::new(kernel, budget, thr)`

**Example.**
```rust
use irithyll::{krls, StreamingLearner};

let mut model = krls(1.0, 100, 1e-4);
for i in 0..500 {
    let x = i as f64 * 0.01;
    model.train(&[x], x.sin());
}
let pred = model.predict(&[1.5708]);  // ~1.0
```

**Benchmarks.** See [BENCHMARKS.md](BENCHMARKS.md) KRLS rows on nonlinear regression benchmarks.

---

### StreamingLinearModel

[`StreamingLinearModel`](https://docs.rs/irithyll/latest/irithyll/struct.StreamingLinearModel.html) — SGD linear model (ridge, lasso, elastic net)

Stochastic gradient descent linear regression. Fastest possible per-sample cost: O(d).
Supports L1, L2, and elastic net regularization via factory variants. Use as a fast baseline
before trying tree or neural models.

**Paper / origin.** Classical online SGD; no single paper. L1/L2 regularization from
Tibshirani (1996) / Hoerl & Kennard (1970).

**Math summary.**
```
w_{t+1} = w_t - lr * grad_loss(w_t, x_t, y_t)
           - lr * lambda_l2 * w_t           (ridge)
           - lr * lambda_l1 * sign(w_t)     (lasso)
grad_squared_loss = -2 * (y_t - w_t^T x_t) * x_t
```

**Config reference.** `linear(lr)` / `StreamingLinearModel::ridge(lr, lambda)` /
`StreamingLinearModel::lasso(lr, lambda)` / `StreamingLinearModel::elastic_net(lr, l1, l2)`

Key parameters:
- `learning_rate` — SGD step size (default: 0.01)
- `lambda` — regularization strength (context-dependent default)

**Example.**
```rust
use irithyll::{linear, StreamingLearner};

let mut model = linear(0.01);
model.train(&[1.0, 2.0], 3.0);
let pred = model.predict(&[1.0, 2.0]);
```

**Benchmarks.** Fastest baseline. See [BENCHMARKS.md](BENCHMARKS.md) throughput section.

---

### MondrianForest

[`MondrianForest`](https://docs.rs/irithyll/latest/irithyll/struct.MondrianForest.html) — streaming random forest with Mondrian process splits

An ensemble of Mondrian trees: each tree samples axis-aligned cuts from the Mondrian process,
giving theoretical guarantees on online learning rates. Unlike Hoeffding trees, Mondrian
trees can refine existing splits, not just add new ones. Use for streaming ensemble regression
where feature space structure is unknown.

**Paper / origin.** Lakshminarayanan, Roy & Teh (2014), "Mondrian Forests: Efficient Online
Random Forests." NIPS 2014. — [citation needed for REFERENCES.md anchor]

**Math summary.**
```
Mondrian process: cut time E(x, y) = Expo( sum_j (max_j - min_j) )
Leaf prediction:  weighted mean of samples at leaf
Tree lifetime lambda: controls expected tree depth (lower = shallower)
```

**Config reference.** `mondrian(n_trees)` factory or `MondrianForestConfig::builder()`

Key parameters:
- `n_trees` — ensemble size (default: 10)
- `max_depth` — cap on tree depth
- `lifetime(f64)` — Mondrian process parameter (controls cut rate)
- `seed(u64)` — RNG seed for reproducibility

**Example.**
```rust
use irithyll::{mondrian, StreamingLearner};

let mut model = mondrian(10);
model.train(&[1.0, 2.0], 3.0);
let pred = model.predict(&[1.0, 2.0]);
```

**Benchmarks.** See [BENCHMARKS.md](BENCHMARKS.md) Mondrian rows.

---

### LocallyWeightedRegression

[`LocallyWeightedRegression`](https://docs.rs/irithyll/latest/irithyll/struct.LocallyWeightedRegression.html) — memory-based locally adaptive regression

Stores a sliding window of recent samples. At prediction time, fits a weighted least squares
model where weights decay exponentially with Euclidean distance from the query. Adapts
automatically to locally varying linear relationships. Cost is O(window) per prediction.

**Paper / origin.** Locally Weighted Learning — Atkeson, Moore & Schaal (1997). — [citation needed for REFERENCES.md anchor]

**Math summary.**
```
w_i = exp(-||x_query - x_i||^2 / (2 * bandwidth^2))
pred = (X^T W X)^{-1} X^T W y   (weighted OLS on window)
```

**Config reference.** `LocallyWeightedRegression::new(capacity, bandwidth)`

Key parameters:
- `capacity` — sliding window size
- `bandwidth` — Gaussian kernel bandwidth for distance weighting

**Example.**
```rust
use irithyll::learners::LocallyWeightedRegression;
use irithyll::StreamingLearner;

let mut model = LocallyWeightedRegression::new(200, 1.0);
for i in 0..300 {
    let x = i as f64 * 0.05;
    model.train(&[x], x.sin());
}
let pred = model.predict(&[1.5]);
```

**Benchmarks.** Suited for locally smooth nonlinear functions. No dedicated BENCHMARKS.md row yet. <!-- TODO: spec -->

---

## Neural Tier — Reservoir Computing

Reservoir computing maps inputs through a fixed (or structured) nonlinear dynamical system
and trains only the linear readout. No backpropagation; converges in under 10 samples in the
NG-RC case.

---

### NextGenRC (NG-RC)

[`NextGenRC`](https://docs.rs/irithyll/latest/irithyll/reservoir/struct.NextGenRC.html) — time-delay + polynomial features + RLS readout

No random matrices. Input is embedded via a delay buffer (k lags, stride s), then lifted
through degree-d polynomial features, then fit by RLS readout. Designed for time series
forecasting where the signal has low-dimensional attractor dynamics.

**Paper / origin.** Gauthier, Bollt, Griffith & Barbosa (2021), "Next generation reservoir
computing." *Nature Communications*, 12, 5564. → [REFERENCES.md §Reservoir Computing](REFERENCES.md).

**Math summary.**
```
Delay embedding:  z_t = [x_t, x_{t-s}, x_{t-2s}, ..., x_{t-(k-1)s}]
Polynomial lift:  phi(z) = {z_i^a * z_j^b : a+b <= degree}
Readout:          y_t = W * phi(z_t),  W trained via RLS
```

**Config reference.** `ngrc(k, s, degree)` factory or `NGRCConfig::builder()`

Key parameters:
- `k` — number of time-delay taps
- `s` — stride between taps
- `degree` — polynomial degree (2–5)
- `forgetting_factor` — RLS lambda (default: 0.998)

**Example.**
```rust
use irithyll::{ngrc, StreamingLearner};

let mut model = ngrc(2, 1, 2);  // 2 taps, stride 1, degree 2
model.train(&[1.0], 2.0);
let pred = model.predict(&[1.0]);
```

**Benchmarks.** Strong on Mackey-Glass and Lorenz. See [BENCHMARKS.md](BENCHMARKS.md) neural-specific rows.

---

### EchoStateNetwork (ESN)

[`EchoStateNetwork`](https://docs.rs/irithyll/latest/irithyll/reservoir/struct.EchoStateNetwork.html) — cycle/ring reservoir + leaky integration + RLS readout

A deterministic ESN using the cycle/ring reservoir topology (Rodan & Tino 2010): reservoir
weights form a single ring, giving O(N) weight storage vs O(N^2) for random reservoirs. State
evolves via leaky integration. For reservoirs larger than 200 units, JL random projection
reduces the RLS readout to a manageable dimension.

**Paper / origin.** Rodan & Tino (2010) for the cycle topology; Martinuzzi (2025) for
deterministic ESN superiority over random reservoirs. → [REFERENCES.md §Reservoir Computing](REFERENCES.md).

**Math summary.**
```
h_t = (1 - alpha) * h_{t-1} + alpha * tanh(W_res * h_{t-1} + W_in * x_t)
      where W_res is a single cycle (h_i -> h_{(i+1) mod N})
      spectral_radius scales W_res so rho(W_res) = spectral_radius
readout: y_t = W_out * h_t,  W_out trained by RLS
JL projection: if N > 200, project h_t to 64-dim before RLS
```

**Config reference.** `esn(n_reservoir, spectral_radius)` factory or `ESNConfig::builder()`

Key parameters:
- `n_reservoir` — reservoir size (default: 100)
- `spectral_radius` — echo state property control (default: 0.9)
- `leaky_rate` — alpha in leaky integration (default: 1.0 = no leak)
- `forgetting_factor` — RLS readout lambda

**Example.**
```rust
use irithyll::{esn, StreamingLearner};

let mut model = esn(100, 0.9);
for i in 0..500 {
    let x = i as f64 * 0.01;
    model.train(&[x], x.sin());
}
let pred = model.predict(&[1.0]);
```

**Benchmarks.** See [BENCHMARKS.md](BENCHMARKS.md) NARMA-10 and Mackey-Glass rows.

---

## Neural Tier — State Space Models

SSMs model sequence dynamics via a latent state `h` governed by structured linear recurrence.
All irithyll SSMs are discretized for sample-by-sample streaming via zero-order hold.

---

### StreamingMamba

[`StreamingMamba`](https://docs.rs/irithyll/latest/irithyll/ssm/struct.StreamingMamba.html) — selective SSM (Mamba V1) with input-dependent parameters

The Mamba architecture selectively focuses state updates based on the current input: B, C,
and Delta are functions of x rather than fixed matrices. S4D-Inv A-matrix initialization
ensures a bounded spectrum across all state sizes. Per-channel L2-norm state energy feeds
the RLS readout, giving a feature vector of dimension d_in * n_state.

**Paper / origin.** Gu & Dao (2023), "Mamba: Linear-time sequence modeling with selective
state spaces." arXiv:2312.00752; Gu et al. (2022) for S4D-Inv initialization. →
[REFERENCES.md §State Space Models](REFERENCES.md).

**Math summary.**
```
ZOH discretization: A_bar = exp(Delta * A),  B_bar = (A_bar - I) * A^{-1} * B
State update:        h_t  = A_bar * h_{t-1} + B_bar(x_t) * x_t
Output:              y_t  = C(x_t) * h_t + D * x_t
Readout features:    f_j  = ||h_t[j]||_2  (per-channel energy, bounded)
```

**Config reference.** `mamba(d_in, n_state)` factory or `MambaConfig::builder()`

Key parameters:
- `d_in` — input/output dimension
- `n_state` — SSM state size per channel (default: 32)
- `forgetting_factor` — RLS readout lambda
- `skip_connection` — add x_t directly to output (default: enabled)

**Example.**
```rust
use irithyll::{mamba, StreamingLearner};

let mut model = mamba(8, 16);
model.train(&[0.5; 8], 1.0);
let pred = model.predict(&[0.5; 8]);

// As preprocessor: SSM features -> SGBT
use irithyll::{pipe, mamba_preprocessor, sgbt};
let mut pipeline = pipe(mamba_preprocessor(5, 16)).learner(sgbt(50, 0.01));
```

**Benchmarks.** See [BENCHMARKS.md](BENCHMARKS.md) Mackey-Glass rows; larger n_state improves after readout fix.

---

### StreamingMambaV3

[`StreamingMambaV3`](https://docs.rs/irithyll/latest/irithyll/ssm/struct.StreamingMambaV3.html) — SSM duality (Mamba2) architecture

Implements the Mamba2 / structured state space duality view (Dao & Gu 2024): the recurrence
is rewritten as a semiseparable matrix multiplication, and the state update becomes a
rank-1 outer product per head. More scalable than V1 for large d_model.

**Paper / origin.** Dao & Gu (2024), "Transformers are SSMs: Generalized models and
efficient algorithms through structured state space duality." arXiv:2405.21060. →
[REFERENCES.md §State Space Models](REFERENCES.md).

**Math summary.**
```
State update:  S_t = Lambda * S_{t-1} + v_t k_t^T   (rank-1 outer product)
Query:         o_t = S_t * q_t
Lambda:        diagonal, learned per channel (structured state)
```

**Config reference.** `MambaV3Config::builder()` (no dedicated factory function; use `StreamingMambaV3::new(config)`).

Key parameters:
- `d_model` — model dimension
- `n_heads` — number of SSM heads (block-diagonal structure)
- `forgetting_factor` — RLS readout lambda

**Example.**
```rust
use irithyll::ssm::{StreamingMambaV3, MambaV3Config};
use irithyll::StreamingLearner;

let config = MambaV3Config::builder().d_model(16).n_heads(4).build().unwrap();
let mut model = StreamingMambaV3::new(config);
model.train(&[0.5; 16], 1.0);
```

**Benchmarks.** <!-- TODO: spec — no standalone V3 benchmark row yet. -->

---

### BDLRUMamba

[`BDLRUMamba`](https://docs.rs/irithyll/latest/irithyll/ssm/struct.BDLRUMamba.html) — block-diagonal LRU state matrix

A hardware-efficient SSM variant using a block-diagonal state transition matrix where each
block is a 2×2 rotation (LRU: Linear Recurrent Unit). The block structure provides selective
per-block forgetting and is well-suited to deployment targets where matrix operations are
parallelized at the block level.

**Paper / origin.** LRU: Orvieto et al. (2023) "Resurrecting Recurrent Neural Networks for
Long Sequences." ICML 2023. — [citation needed for REFERENCES.md anchor]

**Math summary.**
```
h_t^{(b)} = A^{(b)} h_{t-1}^{(b)} + B^{(b)} x_t
A^{(b)}: 2x2 rotation matrix (block of the block-diagonal A)
Diagonal magnitude: |lambda^{(b)}| in (0, 1) controls forgetting per block
```

**Config reference.** `BDLRUConfig::builder()`

Key parameters:
- `d_model` — total state dimension
- `n_blocks` — number of 2×2 blocks in the diagonal
- `forgetting_factor` — RLS readout lambda

**Example.**
```rust
use irithyll::ssm::{BDLRUMamba, BDLRUConfig};
use irithyll::StreamingLearner;

let config = BDLRUConfig::builder().d_model(16).n_blocks(4).build().unwrap();
let mut model = BDLRUMamba::new(config);
model.train(&[0.5; 16], 1.0);
```

**Benchmarks.** <!-- TODO: spec -->

---

## Neural Tier — Spiking Neural Networks

Event-driven computation with biologically inspired LIF (Leaky Integrate-and-Fire) neurons.
E-prop replaces backpropagation through time with an online local learning rule.

---

### SpikeNet

[`SpikeNet`](https://docs.rs/irithyll/latest/irithyll/snn/struct.SpikeNet.html) — LIF neurons with e-prop online learning

A recurrent SNN where synaptic weights are updated by e-prop: a biologically plausible
approximation to BPTT that uses only locally available signals. Delta spike encoding converts
the continuous input to spike events. Surrogate gradients (piecewise linear) handle
the non-differentiable threshold. The f64 interface wraps the fixed-point core.

**Paper / origin.** Bellec et al. (2020) for e-prop; Neftci et al. (2019) for surrogate
gradients. → [REFERENCES.md §Spiking Neural Networks](REFERENCES.md).

**Math summary.**
```
Membrane: U_t^i = beta * U_{t-1}^i + sum_j W_ji * z_t^j - z_t^i * U_thr
Spike:    z_t^i = 1 if U_t^i > U_thr, else 0
Delta enc: spike when |x_t - x_{t-1}| > threshold (sparse events)
e-prop:   delta_W_ji = e_t^ji * L_t  (eligibility trace × learning signal, no BPTT)
```

**Config reference.** `spikenet(n_hidden)` factory or `SpikeNetConfig::builder()`

Key parameters:
- `n_hidden` — number of LIF neurons
- `beta` — membrane time constant (default: 0.9)
- `threshold` — spike threshold (default: 1.0)
- `learning_rate` — e-prop step size

**Example.**
```rust
use irithyll::{spikenet, StreamingLearner};

let mut model = spikenet(64);
model.train(&[0.5, -0.3], 1.0);
let pred = model.predict(&[0.5, -0.3]);
```

**Benchmarks.** See [BENCHMARKS.md](BENCHMARKS.md) sparse temporal event dataset rows.

---

### SpikeNetFixed (`no_std`)

[`SpikeNetFixed`](https://docs.rs/irithyll/latest/irithyll/irithyll_core/snn/struct.SpikeNetFixed.html) — Q1.14 integer arithmetic throughout, `no_std`

Full training in fixed-point arithmetic — no floats, no heap beyond `alloc`. 64 hidden
neurons fit in 22KB on a Cortex-M0+ with 32KB SRAM. This is the embedded-first SNN:
deploy it with `irithyll-core` on bare metal, no OS required.

**Paper / origin.** Same e-prop foundation as `SpikeNet`. Fixed-point design informed by
Kleyko et al. (2020) integer ESN work. → [REFERENCES.md §Related Work](REFERENCES.md).

**Math summary.** Same e-prop equations as `SpikeNet` but all intermediate values in Q1.14
format (1 sign bit, 1 integer bit, 14 fractional bits). Saturation arithmetic prevents overflow.

**Config reference.** `SpikeNetFixed::new(n_in, n_hidden, n_out)` — no builder, construction is explicit.

**Example.**
```rust
// In no_std context with irithyll-core
use irithyll_core::snn::SpikeNetFixed;

let mut model = SpikeNetFixed::new(4, 64, 1);
// features and targets passed as Q1.14 scaled i16 values
```

**Benchmarks.** Verified on Cortex-M0+ (22KB), M3, M4 via QEMU. See README embedded section.

---

## Neural Tier — Test-Time Training

---

### StreamingTTT

[`StreamingTTT`](https://docs.rs/irithyll/latest/irithyll/ttt/struct.StreamingTTT.html) — fast weights updated by gradient descent per sample (Titans)

The hidden state IS a small linear model (fast weight matrix W). On each sample, W is updated
by gradient descent on a self-supervised reconstruction loss, then the prediction is read
from the updated W. Titans extensions (momentum + weight decay on W) from Behrouz et al.
(2025) improve stability. Outperforms RLS on regime-shift benchmarks by ~9%.

**Paper / origin.** Sun et al. (2024) for TTT; Behrouz et al. (2025) for Titans extensions.
→ [REFERENCES.md §Test-Time Training](REFERENCES.md).

**Math summary.**
```
Fast weights:  W_t = (1 - alpha) * W_{t-1} + momentum_term
               Updated by: W_t = W_{t-1} - eta * grad_L_reconstruction(W_{t-1}, x_t)
Prediction:    y_hat = W_t * K(x_t)
Momentum:      m_t = beta * m_{t-1} + eta * grad
Weight decay:  W_t -= alpha * W_t  (Titans)
```

**Config reference.** `streaming_ttt(d_model, learning_rate)` factory or `TTTConfig::builder()`

Key parameters:
- `d_model` — fast weight matrix size
- `learning_rate` (eta) — fast weight SGD step (default: 0.1)
- `alpha` — weight decay coefficient (default: 0.001)
- `momentum` — momentum coefficient for fast weight updates

**Example.**
```rust
use irithyll::{streaming_ttt, StreamingLearner};

let mut model = streaming_ttt(8, 0.01);
model.train(&[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0], 4.5);
let pred = model.predict(&[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]);
```

**Benchmarks.** Beats RLS by 9% on regime-shift benchmarks. See [BENCHMARKS.md](BENCHMARKS.md) TTT rows.

---

## Neural Tier — Kolmogorov-Arnold Networks

---

### StreamingKAN

[`StreamingKAN`](https://docs.rs/irithyll/latest/irithyll/kan/struct.StreamingKAN.html) — B-spline edge activations with Adagrad sparse updates

KAN replaces fixed activation functions with learnable univariate functions on each edge,
parameterized as B-splines. Adagrad per-coefficient adaptive learning rates keep convergence
stable. Only 4 spline coefficients (the active basis functions) update per edge per sample,
giving sparse updates. Outperforms RLS on the Friedman benchmark by ~12%.

**Paper / origin.** Liu et al. (2024) for KAN; Hoang et al. (2026) for online convergence
analysis. → [REFERENCES.md §Kolmogorov-Arnold Networks](REFERENCES.md).

**Math summary.**
```
KAN layer: phi_{i,j}(x) = w_b * b(x) + w_s * spline(x)
           spline(x) = sum_k c_k * B_k(x)  (B-spline basis, order p, grid_size G)
           Only 4 active B_k (De Boor's algorithm) update per sample
Adagrad:   lr_{i,j,k} = lr_0 / sqrt(G_{i,j,k} + eps)
Output:    y = sum_j phi_{i,j}(x_i)  (across hidden sizes)
```

**Config reference.** `streaming_kan(n_in, n_out)` factory or `KANConfig::builder()`

Key parameters:
- `n_in` — input dimension
- `hidden_sizes` — list of hidden layer sizes
- `spline_order` — B-spline polynomial order (default: 3)
- `grid_size` — number of grid intervals (default: 8)
- `learning_rate` — base Adagrad learning rate
- `w_b`, `w_s` — blend weights for base vs spline components

**Example.**
```rust
use irithyll::{streaming_kan, StreamingLearner};

let mut model = streaming_kan(4, 1);
for i in 0..200 {
    let x = i as f64 * 0.05;
    model.train(&[x, x.sin(), x.cos(), x * x], x.sin() + x.cos());
}
let pred = model.predict(&[1.0, 1.0_f64.sin(), 1.0_f64.cos(), 1.0]);
```

**Benchmarks.** +12% over RLS on Friedman. See [BENCHMARKS.md](BENCHMARKS.md) compositional function rows.

---

### TKAN

[`TKAN`](https://docs.rs/irithyll/latest/irithyll/kan/struct.TKAN.html) — Temporal KAN with recurrent B-spline state

Extends `StreamingKAN` with a recurrent connection: hidden state from the previous step is
fed back through an additional B-spline edge, giving the network a memory of prior inputs
without a separate reservoir. Use for time series with compositional nonlinear dynamics.

**Paper / origin.** <!-- TODO: spec — no direct TKAN paper in REFERENCES.md. Temporal extension developed for irithyll. -->

**Math summary.**
```
State:   s_t = phi_{recurrent}(s_{t-1}) + phi_{input}(x_t)
Output:  y_t = W_out * s_t
Both phi are KAN layers with B-spline activations.
```

**Config reference.** `TKANConfig::builder()`

Key parameters:
- `n_in`, `hidden_sizes`, `n_out` — same as KAN
- `state_size` — dimension of recurrent state

**Example.**
```rust
use irithyll::kan::{TKAN, TKANConfig};
use irithyll::StreamingLearner;

let config = TKANConfig::builder().n_in(4).state_size(8).build().unwrap();
let mut model = TKAN::new(config);
model.train(&[0.5; 4], 1.0);
```

**Benchmarks.** <!-- TODO: spec -->

---

## Neural Tier — Online Learning Extensions

---

### StreamingLSTM (sLSTM)

[`StreamingLSTM`](https://docs.rs/irithyll/latest/irithyll/struct.StreamingLSTM.html) — exponential-gated LSTM, xLSTM scalar variant

The sLSTM cell from Beck et al. (2024) xLSTM: exponential gate activations replace sigmoid,
providing a numerically stable alternative to standard LSTM gating. The SLOTS mechanism
(block-diagonal recurrent weights when `n_heads > 1`) mixes only within head subspaces while
input projections remain dense. Optional neuron regeneration (Dohare et al. 2024 Nature)
prevents dead units on long streams.

**Paper / origin.** Beck et al. (2024), "xLSTM: Extended long short-term memory." NeurIPS 2024;
Dohare et al. (2024) for plasticity. → [REFERENCES.md §Streaming Linear Attention](REFERENCES.md)
(mLSTM / sLSTM entry).

**Math summary.**
```
sLSTM cell:
  f_t = exp(W_f x_t + R_f h_{t-1} + b_f)   (exponential forget gate)
  i_t = exp(W_i x_t + R_i h_{t-1} + b_i)   (exponential input gate)
  z_t = tanh(W_z x_t + R_z h_{t-1} + b_z)
  o_t = sigma(W_o x_t + R_o h_{t-1} + b_o)
  c_t = f_t * c_{t-1} / max(f_t, 1) + i_t * z_t
  h_t = o_t * tanh(c_t / max(|c_t|, 1))
Readout: y_t = W_out * h_t, trained by RLS
```

**Config reference.** `SLSTMConfig::builder()`

Key parameters:
- `d_model` — hidden dimension (default: 32)
- `n_heads` — SLOTS block-diagonal heads (default: 1)
- `forgetting_factor` — RLS readout lambda (default: 0.998)
- `forget_bias` — optional `linspace(3, 6)` initialization from Beck et al.
- `plasticity``PlasticityConfig` for neuron regeneration

**Example.**
```rust
use irithyll::lstm::{SLSTMConfig, StreamingLSTM};
use irithyll::StreamingLearner;

let config = SLSTMConfig::builder().d_model(32).build().unwrap();
let mut model = StreamingLSTM::new(config);
model.train(&[0.5; 8], 1.0);
```

**Benchmarks.** See [BENCHMARKS.md](BENCHMARKS.md) sLSTM rows on non-stationary sequence datasets.

---

### StreamingMGrade (mGRADE)

[`StreamingMGrade`](https://docs.rs/irithyll/latest/irithyll/struct.StreamingMGrade.html) — modulated gradient recurrent architecture

mGRADE modulates the gradient signal through a depthwise convolution over a short temporal
kernel before applying the recurrent update. This soft memory of recent gradients helps
adapt quickly to local regime changes without the full overhead of meta-learning.

**Paper / origin.** <!-- TODO: spec — mGRADE paper not listed in REFERENCES.md. Add citation when identified. -->

**Math summary.**
```
Conv feature: c_t = depthwise_conv(x_{t-kernel_size:t})
Hidden:       h_t = tanh(W_h h_{t-1} + W_c c_t)
Readout:      y_t = W_out * h_t, trained by RLS
```

**Config reference.** `MGradeConfig::builder()`

Key parameters:
- `d_in` — input dimension
- `d_hidden` — recurrent hidden size
- `kernel_size` — depthwise conv kernel length
- `forgetting_factor` — RLS readout lambda

**Example.**
```rust
use irithyll::mgrade::{MGradeConfig, StreamingMGrade};
use irithyll::StreamingLearner;

let config = MGradeConfig::builder().d_in(4).d_hidden(16).kernel_size(3).build().unwrap();
let mut model = StreamingMGrade::new(config);
model.train(&[0.5; 4], 1.0);
```

**Benchmarks.** <!-- TODO: spec -->

---

### StreamingAGMP

[`StreamingAGMP`](https://docs.rs/irithyll/latest/irithyll/struct.StreamingAGMP.html) — adaptive gradient meta-predictor

AGMP maintains a second-order estimate of the gradient curvature online, using it to scale
the primary model's update step adaptively. Designed for non-stationary streams where the
curvature of the loss surface changes over time.

**Paper / origin.** <!-- TODO: spec — AGMP paper not in REFERENCES.md. Add citation when identified. -->

**Math summary.** <!-- TODO: spec — exact recurrence for AGMP not confirmed from source. -->

**Config reference.** `AGMPConfig::builder()`

**Example.**
```rust
use irithyll::StreamingAGMP;
use irithyll::StreamingLearner;

let mut model = StreamingAGMP::new(agmp_config);
model.train(&[1.0; 4], 2.0);
```

**Benchmarks.** <!-- TODO: spec -->

---

### StreamingHGRN2

[`StreamingHGRN2`](https://docs.rs/irithyll/latest/irithyll/struct.StreamingHGRN2.html) — hierarchical gated recurrent network (attention variant)

HGRN2 uses per-dimension forget gates with a configurable lower bound, ensuring a minimum
level of memory retention at each gate position. The outer-product state update (`v k^T`)
provides expressivity comparable to GLA. Use for sequences with long-range dependencies where
GLA's data-dependent gating is over-parameterized.

**Paper / origin.** Qin et al. (2024) "HGRN2: Gated Linear RNNs with State Expansion." — [citation
needed for REFERENCES.md anchor; HGRN2 is available via the `hgrn2()` factory in the attention module]

**Math summary.**
```
Gate:    f_t = lower_bound + (1 - lower_bound) * sigmoid(W_f x_t + b_f)
State:   S_t = f_t * S_{t-1} + (1 - f_t) * v_t k_t^T   (outer product update)
Output:  o_t = S_t q_t
```

**Config reference.** `hgrn2(d_model, n_heads, lower_bound)` factory or `StreamingAttentionConfig::builder().mode(AttentionMode::HGRN2 { lower_bound })`

Key parameters:
- `d_model` — model dimension
- `n_heads` — number of heads
- `lower_bound` — minimum forget gate value (prevents catastrophic forgetting)

**Example.**
```rust
use irithyll::attention::hgrn2;
use irithyll::StreamingLearner;

let mut model = hgrn2(8, 2, 0.9);
model.train(&[1.0; 8], 0.5);
```

**Benchmarks.** See [BENCHMARKS.md](BENCHMARKS.md) attention family rows.

---

## Neural Tier — Streaming Linear Attention

All modes share the [`StreamingAttentionModel`](https://docs.rs/irithyll/latest/irithyll/attention/struct.StreamingAttentionModel.html)
wrapper: multi-head recurrent attention + RLS readout. Select the mode via `AttentionMode` enum or
the dedicated factory function. The canonical streaming readout is `o_t = q(x_t) · S_{t-1}` (pre-update
features, never stale, label-independent — see AGENTS.md streaming readout principle).

| Mode | Factory | Architecture | Recommended for |
|------|---------|-------------|-----------------|
| GLA | `gla(d, h)` | Data-dependent scalar gates per channel | General sequential tasks, stable convergence |
| GatedDeltaNet | `delta_net(d, h)` | Delta rule + gating (NVIDIA) | Strongest associative recall |
| DeltaNet | via `AttentionMode::DeltaNet` | Pure delta rule (no extra gate) | Associative lookup, lighter than GatedDeltaNet |
| DeltaProduct | `delta_product(d, h, n)` | n sequential delta steps + Householder | Tunable expressivity |
| RWKV-7 | `rwkv7(d, h)` | Vector decay, vector in-context LR | In-context learning, DPLR transitions |
| HGRN2 | `hgrn2(d, h, lb)` | Lower-bounded forget gates, outer product | Long-range dependencies |
| Hawk | `hawk(d)` | Vector state, single head | Resource-constrained deployments |
| RetNet | `ret_net(d, gamma)` | Fixed exponential decay | Predictable, simple baseline |
| mLSTM | via `AttentionMode::MLSTM` | Matrix LSTM, exponential gating | xLSTM-style streaming |
| RWKV | via `AttentionMode::RWKV` | Time-mixing with scalar decay | Lightweight temporal mixing |
| Log-Linear | `log_linear(d, h, inner, levels)` | Hierarchical Fenwick state, O(log T) | Bridging linear and softmax expressivity |

**Paper citations for all modes.** → [REFERENCES.md §Streaming Linear Attention](REFERENCES.md).

---

### Log-Linear Attention (detail)

[`log_linear()`](https://docs.rs/irithyll/latest/irithyll/attention/fn.log_linear.html) — Han Guo et al. (ICLR 2026) hierarchical Fenwick state

The headline architecture. Wraps any inner linear-attention rule with an O(log T) hierarchical
state indexed by a Fenwick tree. At each level l, the state S^l aggregates the past 2^l tokens
with interpolated lambda weights. This bridges linear-attention efficiency (O(1) per token
update) and softmax expressivity (log-T effective context).

**Paper / origin.** Han Guo, Songlin Yang, Tarushii Goel, Eric P. Xing, Tri Dao, Yoon Kim.
"Log-Linear Attention." ICLR 2026. arXiv:2506.04761. — [citation needed for REFERENCES.md anchor]

**Math summary.**
```
Fenwick state: S_t^l = lambda^l * S_{t-1}^l + k_t v_t^T  for l = 0..max_levels
Query:         o_t   = sum_l weight_l * S_t^l * q_t
               weight_l = lambda_init[l] (learned interpolation)
State memory:  max_levels * d_k * d_v * n_heads  (constant, independent of T)
MQAR headline: recall >= 0.9 at 128 associative pairs
```

**Config reference.** `log_linear(d_model, n_heads, inner, max_levels)` factory.

Key parameters:
- `inner` — any `AttentionMode` (recommend `GatedDeltaNet` for recall, `GLA` for stability)
- `max_levels` — Fenwick depth cap (32 covers ~4G tokens)
- `lambda_init` — per-level interpolation weights (default via `default_lambda_init()`)

**Example.**
```rust
use irithyll::attention::{log_linear, AttentionMode, GatedDeltaMode};
use irithyll::StreamingLearner;

let mut model = log_linear(
    8, 2,
    AttentionMode::GatedDeltaNet { beta_scale: 1.0, gate_mode_delta: GatedDeltaMode::Static },
    32,
);
model.train(&[1.0; 8], 0.5);
let pred = model.predict(&[1.0; 8]);
```

**Benchmarks.** MQAR recall >= 0.9 at 128 pairs required (craft audit gate). See [BENCHMARKS.md](BENCHMARKS.md).

---

## Ensemble Tier

---

### NeuralMoE

[`NeuralMoE`](https://docs.rs/irithyll/latest/irithyll/moe/struct.NeuralMoE.html) — polymorphic mixture of experts with top-k routing

Any `StreamingLearner` can be an expert — mix ESN, Mamba, SpikeNet, SGBT, and attention
models in one ensemble. A linear softmax router, trained online by SGD on cross-entropy
against the best expert, assigns each sample to the top-k experts. DeepSeek-v3-style load
balancing prevents routing collapse. EWMA utilization tracking auto-resets dead experts.

**Paper / origin.** Jacobs et al. (1991) for adaptive mixtures; Shazeer et al. (2017) for
top-k routing; Wang et al. (2024) for auxiliary-loss-free load balancing; Aspis et al. (2025)
for streaming classification with drift. → [REFERENCES.md §Neural MoE](REFERENCES.md).

**Math summary.**
```
Gate:     g_t = softmax(W_router * x_t + bias)
Top-k:    route to k experts with highest g_t[i]
Expert i: y_i = expert_i.predict(x_t)
Output:   y_t = sum_{i in top-k} g_t[i] * y_i / sum_{i in top-k} g_t[i]
Load:     bias[i] -= eps * (utilization[i] - 1/n_experts)  (DeepSeek-v3)
```

**Config reference.** `NeuralMoE::builder()`

Key parameters:
- `expert(model)` — add any `StreamingLearner` as an expert
- `expert_with_warmup(model, n)` — protect expert from elimination during first n samples
- `top_k(k)` — number of experts activated per sample (default: 2)

**Example.**
```rust
use irithyll::{sgbt, esn, spikenet, moe::NeuralMoE, StreamingLearner};

let mut moe = NeuralMoE::builder()
    .expert(sgbt(50, 0.01))
    .expert(sgbt(100, 0.005))
    .expert_with_warmup(esn(50, 0.9), 50)
    .expert_with_warmup(spikenet(32), 20)
    .top_k(2)
    .build();
moe.train(&[1.0, 2.0, 3.0], 4.0);
let pred = moe.predict(&[1.0, 2.0, 3.0]);
```

**Benchmarks.** Strongest on heterogeneous or regime-shifting data. See [BENCHMARKS.md](BENCHMARKS.md).

---

### AdaptiveRandomForest

[`AdaptiveRandomForest`](https://docs.rs/irithyll/latest/irithyll/ensemble/struct.AdaptiveRandomForest.html) — online random forest with concept drift adaptation

Maintains an ensemble of online decision trees built on bootstrap samples (Poisson lambda=6
weighting). When a drift warning is detected on a background tree, a new candidate tree starts
training in parallel. On confirmed drift, the old foreground tree is replaced. Each tree uses
feature subsampling for decorrelation.

**Paper / origin.** Gomes et al. (2017) "Adaptive Random Forests for Evolving Data Stream
Classification." ECML-PKDD 2017. — [citation needed for REFERENCES.md anchor]

**Math summary.**
```
Bootstrap: sample weight w ~ Poisson(lambda=6) per tree per sample
Subsampling: feature fraction f per tree
Drift: ADWIN on per-tree error -> warning -> background tree -> replacement
```

**Config reference.** `ARFConfig::builder(n_trees)`

Key parameters:
- `n_trees` — forest size
- `lambda` — Poisson bootstrap parameter (default: 6.0)
- `feature_fraction` — feature subsampling rate per tree
- `drift_delta`, `warning_delta` — ADWIN thresholds for drift and warning

**Example.**
```rust
use irithyll::ensemble::{AdaptiveRandomForest, ARFConfig};

let config = ARFConfig::builder(10).feature_fraction(0.7).build().unwrap();
let mut model = AdaptiveRandomForest::new(config, || sgbt(10, 0.05));
model.train_one(&[1.0, 2.0], 1.0);
```

**Benchmarks.** <!-- TODO: spec — no dedicated ARF rows in BENCHMARKS.md yet. -->

---

### QuantileRegressorSGBT

[`QuantileRegressorSGBT`](https://docs.rs/irithyll/latest/irithyll/ensemble/struct.QuantileRegressorSGBT.html) — quantile regression via pinball loss

SGBT trained with pinball loss to predict a target quantile (e.g. 0.1 for p10, 0.9 for p90).
Train multiple instances with different quantiles to build a prediction interval. Use for
asymmetric risk or when the full conditional distribution matters.

**Paper / origin.** Koenker & Bassett (1978) for quantile regression; pinball loss is the
gradient of the check function. Built on Gunasekara et al. (2024).

**Math summary.**
```
Pinball loss: L_q(y, f) = q * max(y - f, 0) + (1 - q) * max(f - y, 0)
grad L_q     = -(q * 1[y > f] - (1-q) * 1[y <= f])
```

**Config reference.** `QuantileRegressorSGBT::new(config, quantile)`

**Example.**
```rust
use irithyll::ensemble::QuantileRegressorSGBT;
use irithyll::SGBTConfig;

let config = SGBTConfig::builder().n_steps(50).build().unwrap();
let mut p10 = QuantileRegressorSGBT::new(config.clone(), 0.1);
let mut p90 = QuantileRegressorSGBT::new(config, 0.9);
p10.train(&[1.0], 2.5);
p90.train(&[1.0], 2.5);
```

**Benchmarks.** <!-- TODO: spec -->

---

## Specialized Tier

---

### GaussianNB

[`GaussianNB`](https://docs.rs/irithyll/latest/irithyll/struct.GaussianNB.html) — streaming Gaussian Naive Bayes classifier

Tracks per-class, per-feature Gaussian statistics (mean, variance) incrementally via Welford's
algorithm. At prediction time, computes log-posterior = log-likelihood + log-prior. Use for
text classification, categorical features, or as a fast baseline classifier.

**Paper / origin.** Classical Bayesian classification. Online moment updates via Welford (1962).

**Math summary.**
```
p(x_j | class=k) = N(x_j; mu_{k,j}, sigma_{k,j}^2)
log P(class=k | x) = sum_j log N(x_j; mu_{k,j}, sigma^2_{k,j}) + log pi_k
prediction: argmax_k P(class=k | x)
```

**Config reference.** `gaussian_nb()` factory or `GaussianNB::new()`

Key parameters:
- `var_smoothing` — add to all variances for numerical stability (default: 1e-9)

**Example.**
```rust
use irithyll::{gaussian_nb, StreamingLearner};

let mut model = gaussian_nb();
model.train(&[0.1, 0.9], 1.0);  // class as float
model.train(&[0.9, 0.1], 0.0);
let pred = model.predict(&[0.2, 0.8]);
```

**Benchmarks.** Fastest classifier. See [BENCHMARKS.md](BENCHMARKS.md) binary classification baseline rows.

---

### HalfSpaceTree

[`HalfSpaceTree`](https://docs.rs/irithyll/latest/irithyll/anomaly/struct.HalfSpaceTree.html) — streaming anomaly detection via mass estimation

An ensemble of binary trees where each node randomly selects a feature and a split value
from the observed data range. Anomaly score is the mass estimate: how often a sample lands
in a large leaf (normal) vs a small leaf (anomalous). Scores are windowed; mass estimates
are periodically re-initialized to handle concept drift.

**Paper / origin.** Tan et al. (2011) "Fast Anomaly Detection for Streaming Data." IJCAI 2011.
— [citation needed for REFERENCES.md anchor]

**Math summary.**
```
score(x) = sum_{t=1}^{n_trees} mass_t(x) / n_trees
mass_t(x): number of samples in the leaf where x falls in tree t
Anomaly threshold: samples with score < threshold are flagged
```

**Config reference.** `HSTConfig::builder(n_features)`

Key parameters:
- `n_trees` — ensemble size (default: 25)
- `max_depth` — tree depth
- `window_size` — samples per mass estimation window
- `threshold` — anomaly score threshold

**Example.**
```rust
use irithyll::anomaly::{HalfSpaceTree, HSTConfig};

let config = HSTConfig::new(4).n_trees(25).max_depth(15).window_size(250).build();
let mut detector = HalfSpaceTree::new(config);
detector.update(&[1.0, 2.0, 1.5, 3.0]);
let score = detector.score(&[100.0, 200.0, 150.0, 300.0]);
println!("is_anomaly: {}", score.is_anomaly());
```

**Benchmarks.** <!-- TODO: spec -->

---

### ContinualLearner

[`ContinualLearner`](https://docs.rs/irithyll/latest/irithyll/continual/struct.ContinualLearner.html) — drift-aware wrapper with pluggable continual strategies

Wraps any `StreamingLearner` with an optional drift detector and continual learning strategy.
Strategies include Elastic Weight Consolidation (EWC — regularize against forgetting important
weights), neuron regeneration (periodic random re-initialization of dead units), and parameter
isolation (freeze high-importance parameters). On detected drift, can optionally reset the
inner model or trigger a strategy update.

**Paper / origin.** Kirkpatrick et al. (2017) for EWC; Dohare et al. (2024) for neuron
regeneration / plasticity. → [REFERENCES.md §Plasticity and Continual Learning](REFERENCES.md).

**Config reference.** `ContinualLearner::new(inner_model)` + builder methods

Key parameters:
- `with_drift_detector(detector)` — plug in ADWIN, DDM, or PageHinkley
- `with_reset_on_drift(bool)` — reset inner model on confirmed drift
- EWC config via `ContinualStrategy::EWC { lambda: f64 }`

**Example.**
```rust
use irithyll::continual::ContinualLearner;
use irithyll::drift::adwin::Adwin;
use irithyll::{sgbt, StreamingLearner};

let mut model = ContinualLearner::new(sgbt(50, 0.01))
    .with_drift_detector(Adwin::default())
    .with_reset_on_drift(true);
model.train(&[1.0, 2.0], 3.0);
println!("drift count: {}", model.drift_count());
```

**Benchmarks.** Evaluated on drift recovery benchmarks. See [BENCHMARKS.md](BENCHMARKS.md).

---

### ClassificationWrapper

[`ClassificationWrapper`](https://docs.rs/irithyll/latest/irithyll/struct.ClassificationWrapper.html) — binary/multiclass classifier from any StreamingLearner

Wraps any regression-outputting `StreamingLearner` for classification. Uses bipolar {-1, +1}
targets internally for proper MSE-based discrimination (standard in ESN/reservoir literature).
Binary: threshold output at 0.0. Multiclass: K one-vs-rest heads with stable softmax.

**Config reference.** `binary_classifier(model)` / `multiclass_classifier(model, n_classes)` factories.

**Example.**
```rust
use irithyll::{binary_classifier, esn, StreamingLearner};

let mut clf = binary_classifier(esn(50, 0.9));
clf.train(&[1.0, 2.0], 1.0);  // 1.0 = positive class
clf.train(&[0.1, 0.2], 0.0);  // 0.0 = negative class
let pred = clf.predict(&[1.0, 2.0]);  // 0.0 or 1.0
```

**Benchmarks.** Used in all classification benchmarks wrapping neural models. See [BENCHMARKS.md](BENCHMARKS.md).

---

### ProjectedLearner

[`ProjectedLearner`](https://docs.rs/irithyll/latest/irithyll/projection/struct.ProjectedLearner.html) — online subspace projection + supervised gradient

Wraps any `StreamingLearner` with a PAST-based `SubspaceTracker` that learns a low-rank
projection of the input space online. When the inner model exposes RLS readout weights
(via `readout_weights()`), the projection gradient is supervised by the prediction residual.
Otherwise it falls back to unsupervised PCA (pure PAST). Use for high-dimensional or noisy
inputs where dimensionality reduction should adapt to the target.

**Paper / origin.** Yang (1995) for PAST. → [REFERENCES.md §Projection Learning](REFERENCES.md).

**Math summary.**
```
PAST unsupervised: W_{t+1} = W_t + (x_t - W_t z_t)(z_t / ||z_t||^2)^T
                   where z_t = W_t^T x_t  (projection onto rank-r subspace)
Supervised path:   additional gradient step using prediction residual * readout_weights
Output:            inner_model.train(z_t, y_t)  (trains on projected features)
```

**Config reference.** `ProjectionConfig::builder()`

Key parameters:
- `rank` — projection rank (number of principal components to track)
- `lambda` — PAST forgetting factor (default: 0.998)
- `supervised_lr` — learning rate for supervised projection gradient
- `warmup` — samples to collect before activating projection

Also available via `Factory::projected_mamba(d_in, rank)`, `Factory::projected_ttt(...)`, etc.

**Example.**
```rust
use irithyll::{mamba, StreamingLearner};
use irithyll::projection::{ProjectedLearner, ProjectionConfig};

let config = ProjectionConfig::builder().rank(4).warmup(50).build().unwrap();
let mut model = ProjectedLearner::from_learner(mamba(4, 16), 16, config);
model.train(&[1.0; 16], 0.5);
let pred = model.predict(&[1.0; 16]);
```

**Benchmarks.** See [BENCHMARKS.md](BENCHMARKS.md) high-dimensional input rows.

---

## Preprocessing

All preprocessors implement `StreamingPreprocessor` and compose via `pipe(preprocessor).learner(model)`
or `pipe(preprocessor).pipe(preprocessor2).learner(model)`.

---

### IncrementalNormalizer

[`IncrementalNormalizer`](https://docs.rs/irithyll/latest/irithyll/struct.IncrementalNormalizer.html) — Welford's online standardization

Tracks per-feature mean and variance using Welford's one-pass algorithm. During warmup,
passes features through unchanged. After warmup, outputs `(x - mu) / sigma` per feature.
Variance floor prevents division by zero on constant features. Use as the first stage of
any pipeline where features have heterogeneous scales.

**Math summary.**
```
Welford: delta = x - mean;  mean += delta / n;  M2 += delta * (x - mean)
sigma^2 = M2 / (n - 1)  (or variance_floor if too small)
output  = (x - mean) / sigma
```

**Example.**
```rust
use irithyll::{pipe, normalizer, sgbt, StreamingLearner};

let mut model = pipe(normalizer()).learner(sgbt(50, 0.01));
model.train(&[100.0, 0.001], 42.0);
```

---

### CCIPCA

[`CCIPCA`](https://docs.rs/irithyll/latest/irithyll/struct.CCIPCA.html) — candid covariance-free incremental PCA

O(kd) streaming PCA without computing or storing the covariance matrix. Tracks the top-k
principal components via a sequence of deflated rank-1 updates. Use for streaming
dimensionality reduction before a downstream learner.

**Paper / origin.** Weng, Zhang & Hwang (2003). → [REFERENCES.md §Core Gradient Boosting](REFERENCES.md)
(CCIPCA entry).

**Math summary.**
```
For each component i = 1..k:
  v_i_{t+1} = (1 - l/n) * v_i_t + (l/n) * x_t * (x_t^T v_i_t / ||v_i_t||)
  deflate:    x_t -= (x_t^T u_i) * u_i   where u_i = v_i / ||v_i||
Output: k-dimensional projection z_t = U^T x_t
```

**Example.**
```rust
use irithyll::{pipe, ccipca, normalizer, sgbt, StreamingLearner};

let mut model = pipe(normalizer()).pipe(ccipca(5)).learner(sgbt(50, 0.01));
model.train(&[1.0; 20], 3.0);
```

---

### OnlineFeatureSelector

[`OnlineFeatureSelector`](https://docs.rs/irithyll/latest/irithyll/struct.OnlineFeatureSelector.html) — streaming mutual-information feature selection

Estimates mutual information between each feature and the target online, using a histogram-based
discretization updated incrementally. Selects the top-k features by MI estimate for downstream
learning.

**Config reference.** `OnlineFeatureSelector::new(k_features)`

**Example.**
```rust
use irithyll::preprocessing::OnlineFeatureSelector;
use irithyll::{pipe, sgbt, StreamingLearner};

let mut model = pipe(OnlineFeatureSelector::new(5)).learner(sgbt(50, 0.01));
model.train(&[1.0; 20], 3.0);
```

---

### TargetEncoder

[`TargetEncoder`](https://docs.rs/irithyll/latest/irithyll/preprocessing/struct.TargetEncoder.html) — online target encoding for categorical features

Replaces categorical feature values with their running mean target value, smoothed towards
the global target mean. Prevents high-cardinality categoricals from blowing up feature space.
Operates directly on f64-encoded category indices in the feature vector.

**Math summary.**
```
encoded(cat) = (n_cat * mean_cat + smoothing * global_mean) / (n_cat + smoothing)
```

**Config reference.** `TargetEncoder::new(categorical_indices)` or `TargetEncoder::with_smoothing(indices, s)`

---

### TargetScaler / TargetLog1pTransform

These are target-side preprocessors that normalize the regression target before passing it
to the inner model, then invert the transform on prediction.

- [`TargetScaler`]https://docs.rs/irithyll/latest/irithyll/preprocessing/struct.TargetScaler.html — online Welford standardization of the target
- [`TargetLog1pTransform`]https://docs.rs/irithyll/latest/irithyll/preprocessing/struct.TargetLog1pTransform.html`log1p` / `expm1` transform for heavy-tailed targets

---

## Clustering

Clustering algorithms do not implement `StreamingLearner`; they expose their own `train_one` /
`predict` API returning cluster assignments.

---

### StreamingKMeans

[`StreamingKMeans`](https://docs.rs/irithyll/latest/irithyll/clustering/struct.StreamingKMeans.html) — online k-means with exponential forgetting

MacQueen online k-means updated with exponential forgetting: centroids are pulled towards
new samples weighted by the forgetting factor. Assignment to nearest centroid, then winner
centroid update.

**Math summary.**
```
assignment: c* = argmin_c ||x - centroid_c||^2
update:     centroid_{c*} = (1 - lr) * centroid_{c*} + lr * x
            where lr = 1 - forgetting_factor per sample
```

**Config reference.** `StreamingKMeansConfig::builder(k)`

---

### CluStream

[`CluStream`](https://docs.rs/irithyll/latest/irithyll/clustering/struct.CluStream.html) — micro-cluster streaming with temporal extensions

Aggarwal et al. (2003) CluStream: maintains a fixed number of micro-clusters as online
summaries. Each micro-cluster is a (N, LS, SS, LST, SST) tuple — the cluster feature extended
with temporal statistics. Assignment is to nearest micro-cluster by radius; merging when
capacity is exceeded.

**Paper / origin.** Aggarwal et al. (2003) "A Framework for Clustering Evolving Data Streams."
VLDB 2003. — [citation needed for REFERENCES.md anchor]

**Config reference.** `CluStreamConfig::builder(max_micro_clusters)`

---

### DBStream

[`DBStream`](https://docs.rs/irithyll/latest/irithyll/clustering/struct.DBStream.html) — density-based streaming clustering with decay

Density-based clustering adapted for streams: micro-clusters grow when new points arrive
within `radius`. Shared density between micro-clusters is tracked and decays over time.
Macro-cluster connectivity is derived from shared density above a threshold. Handles
arbitrary cluster shapes and naturally identifies noise points.

**Paper / origin.** Hahsler & Dunham (2010) "Density-Based Projected Clustering of Data
Streams." SIAM SDM 2010. — [citation needed for REFERENCES.md anchor]

**Config reference.** `DBStreamConfig::builder(radius)`

---

## Streaming AutoML

---

### AutoTuner

[`AutoTuner`](https://docs.rs/irithyll/latest/irithyll/automl/struct.AutoTuner.html) — streaming hyperparameter optimization via tournament racing

Implements `StreamingLearner`: trains and predicts like any model, internally running
champion-challenger tournament successive halving in the background. The champion is always
the live predictor; challengers are evaluated prequentially in parallel. ADWIN-triggered
re-racing restarts the tournament with an expanded bracket on detected drift.

**Paper / origin.** Wu et al. (2021) ChaCha for tournament racing; Qi et al. (2023) Discounted
Thompson Sampling for factory selection; Yamanishi (2018) for MDL-inspired complexity
adjustment. → [REFERENCES.md §Streaming AutoML](REFERENCES.md).

**Math summary.**
```
Complexity-adjusted score: score = ewma_error + complexity / n_seen
                           complexity = n_params * log(n_params) (MDL-inspired)
Successive halving:        round_budget samples -> eliminate bottom half -> repeat
Statistical early stopping: Welford z-test (z > 2.0, min 30 samples)
```

**Config reference.** `auto_tune(factory)` / `AutoTuner::builder()`

Key parameters:
- `add_factory(Factory)` — register a model family for the race
- `use_drift_rerace(bool)` — restart tournament on ADWIN drift signal
- `round_budget`, `n_initial` — halving tournament parameters

**Example.**
```rust
use irithyll::{auto_tune, automl::Factory, StreamingLearner};

// Single factory: auto-tune SGBT hyperparameters
let mut tuner = auto_tune(Factory::sgbt(5));

// Multi-factory: race trees vs neural
let mut tuner = AutoTuner::builder()
    .add_factory(Factory::sgbt(5))
    .add_factory(Factory::esn())
    .add_factory(Factory::mamba(5))
    .use_drift_rerace(true)
    .build();
tuner.train(&[1.0, 2.0, 3.0], 4.0);
let pred = tuner.predict(&[1.0, 2.0, 3.0]);
```

---

### Factory

[`Factory`](https://docs.rs/irithyll/latest/irithyll/automl/struct.Factory.html) — unified model factory with hyperparameter search spaces

Provides a hyperparameter search space for each model family and constructs sampled instances
for AutoTuner racing. Also exposes convenience constructors for projected variants.

| Factory method | Model family |
|---------------|-------------|
| `Factory::sgbt(n_rounds)` | SGBT family |
| `Factory::distributional(n_rounds)` | DistributionalSGBT |
| `Factory::esn()` | EchoStateNetwork |
| `Factory::mamba(n_rounds)` | StreamingMamba |
| `Factory::ttt()` | StreamingTTT |
| `Factory::kan()` | StreamingKAN |
| `Factory::attention(mode)` | StreamingAttentionModel |
| `Factory::spike_net()` | SpikeNet |
| `Factory::projected_mamba(d_in, rank)` | ProjectedLearner wrapping Mamba |
| `Factory::projected_ttt(d_in, rank)` | ProjectedLearner wrapping TTT |
| `Factory::projected_esn(d_in, rank)` | ProjectedLearner wrapping ESN |

---

## Drift Detectors

Drift detectors are not `StreamingLearner`s; they are embedded in `SGBTConfig`, `ContinualLearner`,
and `AutoTuner`. All implement a `DriftDetector` trait with `update(error) -> DriftSignal`.

| Detector | Type | Key parameter |
|----------|------|---------------|
| `PageHinkley` | Sequential change-point | `delta` (sensitivity), `threshold` |
| `Adwin` | Adaptive windowing | `delta` (confidence) |
| `DDM` | Drift Detection Method | `warning_level`, `drift_level` |

**Paper citations.** → [REFERENCES.md §Algorithmic Foundations](REFERENCES.md).

---

## Conformal Prediction

Conformal prediction modules augment any point predictor with coverage guarantees. They are
not `StreamingLearner`s; they wrap a fitted model and maintain a nonconformity score buffer.

| Component | Description | Paper |
|-----------|-------------|-------|
| `ConformalPID` | PID-controlled adaptive coverage | Angelopoulos et al. (2023) |
| `OnlinePlattScaling` | Online probability calibration | Gupta & Ramdas (2023) |
| `OnlineTemperatureScaling` | Single-parameter multiclass calibration | [citation needed] |

**Paper citations.** → [REFERENCES.md §Conformal Prediction](REFERENCES.md).

---

## Packed Inference (`irithyll-core`)

After training with the full `irithyll` crate, export to a compact packed binary for
zero-alloc inference on embedded targets.

```rust
use irithyll::export_embedded::export_packed;
use irithyll_core::EnsembleView;

// Export (host)
let packed: Vec<u8> = export_packed(&model, n_features);
std::fs::write("model.bin", &packed).unwrap();

// Infer (embedded, no_std)
let model_bytes: &[u8] = include_bytes!("model.bin");
let view = EnsembleView::from_bytes(model_bytes).unwrap();
let pred: f32 = view.predict(&[1.0, 2.0, 3.0]);
```

Each `PackedNode` is 12 bytes (5 nodes per 64-byte cache line). Single-predict latency:
66 ns at 15.2M predictions/second on x86-64 with a 50-tree depth-4 ensemble.

`SpikeNetFixed` (`no_std`, Q1.14) also available in `irithyll-core` for spiking networks on
bare metal — 64 neurons in 22KB, verified on Cortex-M0+, M3, M4.