Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Online ml River Optim FTRLProximal

From Leeroopedia


Knowledge Sources
Domains Online_Learning, Optimization
Last Updated 2026-02-08 16:00 GMT

Overview

FTRL-Proximal (Follow The Regularized Leader) is an online optimization algorithm designed for large-scale learning with built-in L1 and L2 regularization.

Description

FTRL-Proximal combines the benefits of both FOBOS (Forward-Backward Splitting) and RDA (Regularized Dual Averaging) algorithms, making it particularly effective for sparse learning problems. The algorithm maintains per-coordinate learning rates like AdaGrad while efficiently handling L1 and L2 regularization. It uses two accumulators: z (the accumulated gradients minus the accumulated changes in weights) and n (the accumulated squared gradients). The L1 regularization naturally produces sparse models by setting many weights to exactly zero, making FTRL-Proximal highly efficient for high-dimensional problems. Originally developed at Google for online ad click prediction, it excels at handling billions of sparse features.

Usage

Import from river.optim and use as an optimizer in any River model. Particularly effective for sparse learning problems with high-dimensional feature spaces.

Code Reference

Source Location

Signature

class FTRLProximal(optim.base.Optimizer):
    def __init__(self, alpha=0.05, beta=1.0, l1=0.0, l2=1.0):
        ...

Import

from river import optim

I/O Contract

Inputs

Name Type Required Description
alpha float No (default=0.05) Learning rate parameter
beta float No (default=1.0) Smoothing parameter for adaptive learning rate
l1 float No (default=0.0) L1 regularization parameter (promotes sparsity)
l2 float No (default=1.0) L2 regularization parameter

Outputs

Name Type Description
optimizer FTRLProximal Configured optimizer instance ready for model training

Usage Examples

from river import datasets
from river import evaluate
from river import linear_model
from river import metrics
from river import optim
from river import preprocessing

# Create FTRL-Proximal optimizer
optimizer = optim.FTRLProximal()

# Use with a linear model
dataset = datasets.Phishing()
model = (
    preprocessing.StandardScaler() |
    linear_model.LogisticRegression(optimizer)
)
metric = metrics.F1()

# Evaluate
score = evaluate.progressive_val_score(dataset, model, metric)
print(score)  # F1: 87.56%

# With strong L1 regularization for sparse models
optimizer = optim.FTRLProximal(
    alpha=0.1,
    beta=1.0,
    l1=1.0,  # Strong L1 for sparsity
    l2=0.5
)

model = linear_model.LogisticRegression(optimizer)

# Ideal for sparse, high-dimensional data
from river import feature_extraction

model = (
    feature_extraction.BagOfWords() |
    linear_model.LogisticRegression(
        optimizer=optim.FTRLProximal(l1=0.5, l2=1.0)
    )
)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment