ridge_py_hw4a: OLS with Ridge Regression - Python

Description Usage Arguments Value Examples

View source: R/ridge_py_hw4a.R

Description

This function fits linear models with the ridge regression regularization (using the l2 norm). This method is used to reduce overfitting. Language is in Python 3.

Usage

1
ridge_py_hw4a(y, X, lambda_val)

Arguments

y

target/response variable matrix

X

independent variables matrix (contrasts should be taken care of here)

lambda_val

the lambda value (regularization parameter)

Value

the best-fit coefficients with ridge regularization

Examples

1
2
3
4
data(iris)
y <- matrix(iris$Sepal.Length, ncol = 1)
X <- model.matrix( ~ . - Sepal.Length - Species, data = iris)
ridge_py_hw4a(y, X, lambda_val = 1)

brian-d1018/bis557 documentation built on Dec. 17, 2020, 6:21 p.m.