ageron / ageron/handson-ml3

[QUESTION] why in chapter 4 code example in colab A is not Identity matrix?

Open
#72 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
14.1k
Forks
5.3k
PR merge metrics
No merged PRs in 30d

Description

Thanks for helping us improve this project!

**Before you create this issue**
Please make sure you are using the latest updated code and libraries: see https://github.com/ageron/handson-ml3/blob/main/INSTALL.md#update-this-project-and-its-libraries

Also please make sure to read the FAQ (https://github.com/ageron/handson-ml3#faq) and search for existing issues (both open and closed), as your question may already have been answered: https://github.com/ageron/handson-ml3/issues

**Describe what is unclear to you**
Hi
for the closed form of regularization in regression Equation 4-9 is discussed in the book
it is mentioned that A is an identity matrix
there is one part in the Colab of the chapter for the closed form but A is defined as [0, 0][0, 1].
Is there any special reason for that or am I missing something
I saw the np.ones is used for X_b
but I still don't get why A is not defined as [1, 0][0,1]

**To Reproduce**
If the question relates to a specific piece of code, please copy the code that fails here, using code blocks like this:

```python
alpha = 0.1
A = np.array([[0., 0.], [0., 1.]])
X_b = np.c_[np.ones(m), X]
np.linalg.inv(X_b.T @ X_b + alpha * A) @ X_b.T @ y
```

**Expected behavior**
If applicable, a clear and concise description of what you expected to happen.

**Screenshots**
![image](https://user-images.githubusercontent.com/53435529/233630587-4a53b821-4fb9-4627-84bd-836ae81b74c0.png)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.