# Ridge Regression

[Permalink](https://github.com/sparkingdark/AwesomeML-algo-book/blob/60503b9f93f645ca1346d9013f86009d5a0b3869/docs/ridge_regression.md)

Cannot retrieve contributors at this time

## Ridge regression

### Regression

`Ridge` regression addresses some of the problems of `ordinary_least_squares` by imposing a penalty on the size of the coefficients. The ridge coefficients minimize a penalized residual sum of squares:

![](https://1850381135-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MYhBtC6jOcNx0VAoSUq%2F-MYhBxC9qaPCyqD0mq1v%2F-MYhCZN0VhFmWDBOMskJ%2Fimage.png?alt=media\&token=2019194b-2df3-4bbd-8527-585ba255d8cf)

The complexity paramete controls the amount of shrinkage the larger the value of , the greater the amount of shrinkage and thus the coefficients become more robust to collinearity.

![](https://1850381135-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MYhBtC6jOcNx0VAoSUq%2F-MYhBxC9qaPCyqD0mq1v%2F-MYhCeVfsSrjK2whMtUL%2Fimage.png?alt=media\&token=48f6556e-7e62-460e-af17-105be286b4e8)

As with other linear models, `Ridge` will take in its `fit` method arrays X, y and will store the coefficients `w` of the linear model in its `coef_` member:

```
    >>> from sklearn import linear_model
    >>> reg = linear_model.Ridge(alpha=.5)
    >>> reg.fit([[0, 0], [0, 0], [1, 1]], [0, .1, 1])
    Ridge(alpha=0.5)
    >>> reg.coef_
    array([0.34545455, 0.34545455])
    >>> reg.intercept_
    0.13636...
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sparkingdebo.gitbook.io/awesome-ml-book/ridge-regression.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
