Skip to content

Instantly share code, notes, and snippets.

@qdpham
Created February 25, 2022 13:29
Show Gist options
  • Save qdpham/21b30181a8e0dd50cfcbba57b61e9b70 to your computer and use it in GitHub Desktop.
Save qdpham/21b30181a8e0dd50cfcbba57b61e9b70 to your computer and use it in GitHub Desktop.
Fun-inria MOOC scikit-learn Exervice M4.04: Different outputs for linear regression coefficients
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@qdpham
Copy link
Author

qdpham commented Feb 25, 2022

Hi,

Here are the two files reproducing the issue, that we talked about in the forum, about exact same coefficients between LinearRegression and Ridge on my machine.

The first file fun_linear_models_ex_04.ipynb is the code run from the fun-inria server and the second my_linear_models_ex_04.ipynb run from my local machine.

Note that I’ve added a cell for computing the coefficients by hand.
I had an error raised from the fun-inria server, as the determinant is computed at exactly 0, however the `LinearRegression’ still provides results without explicit warning (although we can understand that the coefficients are unreasonable).
On the other hand, the determinant is computed at approximately 0 on my machine and so I could proceed and got somewhat reasonable coefficients.

At the end of the day, I get the same coefficients between LineaarRegression and Ridge (regularized) on my machine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment