himalaya.ridge.Ridge

class himalaya.ridge.Ridge(alpha=1, fit_intercept=False, solver='svd', solver_params=None, force_cpu=False)[source]

Ridge regression.

Solve the ridge regression:

b* = argmin_b ||X @ b - Y||^2 + alpha ||b||^2.
Parameters
alphafloat, or array of shape (n_targets, )

L2 regularization parameter.

fit_interceptboolean

Whether to fit an intercept. If False, X and Y must be zero-mean over samples.

solverstr

Algorithm used during the fit, in {“svd”}.

solver_paramsdict or None

Additional parameters for the solver. See more details in the docstring of the function: Ridge.ALL_SOLVERS[solver]

force_cpubool

If True, computations will be performed on CPU, ignoring the current backend. If False, use the current backend.

Examples

>>> from himalaya.ridge import Ridge
>>> import numpy as np
>>> n_samples, n_features, n_targets = 10, 5, 3
>>> X = np.random.randn(n_samples, n_features)
>>> Y = np.random.randn(n_samples, n_targets)
>>> model = Ridge()
>>> model.fit(X, Y)
Ridge()
Attributes
coef_array of shape (n_features) or (n_features, n_targets)

Ridge coefficients.

intercept_float or array of shape (n_targets, )

Intercept. Only present if fit_intercept is True.

n_features_in_int

Number of features used during the fit.

dtype_str

Dtype of input data.

Methods

fit(X[, y])

Fit the model.

get_params([deep])

Get parameters for this estimator.

predict(X)

Predict using the model.

score(X, y)

Return the coefficient of determination R^2 of the prediction.

set_params(**params)

Set the parameters of this estimator.