handson-ml3 icon indicating copy to clipboard operation
handson-ml3 copied to clipboard

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

Open ArezooAalipanah opened this issue 1 year ago • 0 comments

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:

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

ArezooAalipanah avatar Apr 21 '23 12:04 ArezooAalipanah