You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Versions
Colab with the default provisioned runtime:
OS: N/A
Python: 3.10.12
TensorFlow: N/A
Scikit-Learn: 1.6.0
Numpy: 1.26.4
Additional context
A cursory research of issues in sklearn GitHub and some experimentation has led me to conclude that LinearRegression() and Ridge handle coef_ dimensions differently in the recent versions of sklearn.
Here's a Python example demonstrating the difference:
Clearly, (1,1) is not the same as (1,). So it seems that when the same input containing a single target is given to both LinearRegression() and Ridge, they handle the coef_ dimensions differently.
I understand that the repo provides an Anaconda environment definition in environment.yml as well as the requirements.txt file containing the right package versions but to the best of my knowledge this information cannot be used to modify the environment in Colab easily, and since Colab is the environment recommended in the README file I thought it might be worth to mention this issue here.
The text was updated successfully, but these errors were encountered:
I also filed an issue in scikit-learn/scikit-learn#30624 repo to confirm whether this difference in behaviour between LinearRegression and Ridge classes is a feature and not a bug.
Thinking logically, the values of your y parameters are 2D, so I would expect Ridge.coef_ to be 2D as well (with n_targets = 1, of course) but this is not what happens.
Describe the bug
The first notebook throws an error in Colab. I think this is due to a more recent
sklearn
version used there.I researched the issue and found a solution but am not sure how it should be implemented to make sure that it works across all supported environments.
To Reproduce
Run the first notebook in Colab.
File name:
01_the_machine_learning_landscape.ipynb
The offending line of code is:
The error:
To make this code work in Colab I had to replace 2D indexing with 1D for
ridge.coef_
:Then everything worked as expected.
Versions
Colab with the default provisioned runtime:
Additional context
A cursory research of issues in
sklearn
GitHub and some experimentation has led me to conclude thatLinearRegression()
andRidge
handlecoef_
dimensions differently in the recent versions ofsklearn
.Here's a Python example demonstrating the difference:
Clearly,
(1,1)
is not the same as(1,)
. So it seems that when the same input containing a single target is given to bothLinearRegression()
andRidge
, they handle thecoef_
dimensions differently.I understand that the repo provides an Anaconda environment definition in
environment.yml
as well as therequirements.txt
file containing the right package versions but to the best of my knowledge this information cannot be used to modify the environment in Colab easily, and since Colab is the environment recommended in the README file I thought it might be worth to mention this issue here.The text was updated successfully, but these errors were encountered: