MLRidge: Ridge Regression Solver

MLRidgeR Documentation

Ridge Regression Solver

Description

Solves the ridge regression problem \min_\beta \|y - X\beta\|^2 + \lambda \|\beta\|^2 for a single regularization value. Dispatches internally between primal (n \ge p) and dual (n < p) Cholesky paths.

Details

Wraps the C++ MLRidge::solve(X, y, lambda) static method.

Methods

Public methods


MLRidge$solve()

Solve ridge regression for a single lambda.

Usage
MLRidge$solve(X, y, lambda, n_threads = NULL)
Arguments
X

A numeric matrix (n x p), or an mmap_matrix (bound zero-copy; "readonly" suffices).

y

Numeric response vector of length n.

lambda

Non-negative regularization parameter.

n_threads

Integer, the thread budget of the matrix products (NULL, the default: the library's default budget, trex_get_num_threads(), initially 1).

Returns

Coefficient vector of length p.


MLRidge$clone()

The objects of this class are cloneable with this method.

Usage
MLRidge$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

References

A. E. Hoerl and R. W. Kennard, "Ridge Regression: Biased Estimation for Nonorthogonal Problems," Technometrics, vol. 42, no. 1, pp. 80-86, 2000 (Reprint of the 1970 article in the Special 40th Anniversary Issue).

See Also

Other ML methods: MLElasticNet, MLElasticNetCV, MLLpNormScaler, MLPCA, MLRidgeCV, MLSVD, MLZScoreScaler, ml_agglomerative_cluster(), ml_cut_tree(), ml_distance_metric, ml_linkage_method

Examples

set.seed(42)
n <- 40; p <- 5
X <- matrix(rnorm(n * p), n, p)
beta_true <- c(1, -2, 0, 0.5, 0)
y <- X %*% beta_true + rnorm(n, sd = 0.1)
solver <- MLRidge$new()
beta_hat <- solver$solve(X, y, lambda = 0.01)


TRexSelector documentation built on Nov. 20, 2026, 5:09 p.m.