Skip to content

ML.REGRESSION.RIDGE

Creates a Ridge Regression object.

Syntax

ML.REGRESSION.RIDGE(alpha, fit_intercept)

Arguments

Name Type Default Description
alpha float 1.0 Regularization strength; must be a positive float. Larger values specify stronger regularization.
fit_intercept Any TRUE Whether to calculate the intercept for this model. If set to False, no intercept will be used in calculations (i.e., data is expected to be centered).

Returns

A Ridge Regression model handle, ready to pass into ML.FIT.

When to use

Reach for ridge regression when ordinary linear regression overfits — usually because two or more of your features are highly correlated, or because you have only slightly more rows than columns. Ridge shrinks all coefficients toward zero with an L2 penalty, producing a more stable fit without zeroing any feature out.

Compared to the alternatives in this namespace:

  • Use ML.REGRESSION.LINEAR when there is no multicollinearity and you want the unregularized fit.
  • Use ridge when features are correlated and you want all of them in the model, just dampened.
  • Use ML.REGRESSION.LASSO when you instead want only the most useful features to survive (others get coefficient 0).
  • Use ML.REGRESSION.ELASTIC_NET when you want a blend of the two.

Examples

Fit a ridge model with the default alpha=1.0 on features in A2:E100 and the target in F2:F100:

=ML.REGRESSION.RIDGE()
=ML.FIT(H1, A2:E100, F2:F100)
=ML.PREDICT(H2, A101:E110)

Increase alpha to apply stronger shrinkage when you suspect heavy overfitting:

=ML.REGRESSION.RIDGE(10)

Set alpha=0 to recover ordinary least squares (equivalent to ML.REGRESSION.LINEAR):

=ML.REGRESSION.RIDGE(0)

Remarks

  • alpha is the regularization strength. Larger alpha = more shrinkage. Defaults to 1.0. Try a small grid like 0.01, 0.1, 1, 10, 100 and pick the value that minimizes test error.
  • Scale your features first (e.g. with ML.PREPROCESSING.STANDARD_SCALER) — Ridge applies the same penalty to every coefficient, so unequal feature scales bias the result.
  • Ridge keeps all features in the model with non-zero coefficients. If you want automatic feature selection, use ML.REGRESSION.LASSO.

See also