pub fn ridge_regression(
y_json: &str,
x_vars_json: &str,
_variable_names: &str,
lambda: f64,
standardize: bool,
) -> StringExpand description
Performs Ridge regression via WASM.
Ridge regression adds an L2 penalty to the coefficients, which helps with multicollinearity and overfitting. The intercept is never penalized.
§Arguments
y_json- JSON array of response variable valuesx_vars_json- JSON array of predictor arraysvariable_names- JSON array of variable nameslambda- Regularization strength (>= 0, typical range 0.01 to 100)standardize- Whether to standardize predictors (recommended: true)
§Returns
JSON string containing:
lambda- Lambda value usedintercept- Intercept coefficientcoefficients- Slope coefficientsfitted_values- Predictions on training dataresiduals- Residuals (y - fitted_values)df- Effective degrees of freedom
§Errors
Returns a JSON error object if parsing fails, lambda is negative, or domain check fails.