himalaya.ridge.solve_ridge_svd

himalaya.ridge.solve_ridge_svd(X, Y, alpha=1.0, method='svd', fit_intercept=False, negative_eigenvalues='zeros', n_targets_batch=None, warn=True)[source]

Solve ridge regression using SVD decomposition.

Solve the ridge regression:

b* = argmin_B ||X @ b - Y||^2 + alpha ||b||^2
Parameters
Xarray of shape (n_samples, n_features)

Input features.

Yarray of shape (n_samples, n_targets)

Target data.

alphafloat, or array of shape (n_targets, )

Regularization parameter.

methodstr in {“svd”}

Method used to diagonalize the input feature matrix.

fit_interceptboolean

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

negative_eigenvaluesstr in {“nan”, “error”, “zeros”}

If the decomposition leads to negative eigenvalues (wrongly emerging from float32 errors): - “error” raises an error. - “zeros” remplaces them with zeros. - “nan” returns nans if the regularization does not compensate twice the smallest negative value, else it ignores the problem.

n_targets_batchint or None

Size of the batch for over targets during cross-validation. Used for memory reasons. If None, uses all n_targets at once.

warnbool

If True, warn if the number of samples is smaller than the number of features.

Returns
weightsarray of shape (n_features, n_targets)

Ridge coefficients.

interceptarray of shape (n_targets,)

Intercept. Only returned when fit_intercept is True.