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
fit_intercept in Ridge says "(i.e. data is expected to be centered)", but the "data" is ambiguous. From some experimentation, it seems that the "data" is the y in the regression problem. This is confusing because most resources say penalized models should not be fit with an intercept, so users may be tempted to pass fit_intercept=False, producing undesirable results.
Suggest a potential alternative/fix
Explicitly reference what data is assumed to be centered when fit_intercept=False and explain that when fit_intercept=True that it is not used in the optimization, in accordance with resources on the topic.
I can handle this if I have interpreted what fit_intercept=False does.
Hi @Dpananos, we were just looking at this documentation as well while working on missing attributes for Bayesian Ridge. Are you looking for help on this issue or interested in collaborating on updating the documentation to remove some of the ambiguity?
Collaborating is an excellent idea! I would appreciate input from maintainers and devs on this one, and would like to help out where possible. I have a small class of approx 50 students whom can serve as a sample for any changes.
So let's clarify a bit about what is going on in the implementation.
With dense input, all solvers are able to fit the intercept without imposing a penalty on it. Indeed, the data (X and y) are internally centred and the coef_ is computed. Then, coef_ are rescaled using the centring information (X_scale) and intercept_ is computed using this information as well (X_offset and y_offset).
In the sparse case, this is more challenging since one do not want to center the data and thus compute the X_offset and y_offset as required in the dense case. Basically, there is only a single solver which can accommodate to fit the intercept in this case which is the sparse coordinate descent sparse_cg. Again, it will not penalize the intercept.
Finally, when the documentation stipulates to center the data with fit_intercept=False, it asks to centre both X and y such that there is not intercept. If not, you are still forcing to have a solution to pass by the origin with data that are not centred on it. As @agramfort mentioned to IRL, it is an issue in low-dimensional space while maybe not much an issue in high-dimensional space.
This said. We could improve the documentation by stating that both X and y are expected to be centred such that the intercept is indeed null.
Activity
phil-cork commentedon Feb 11, 2020
Hi @Dpananos, we were just looking at this documentation as well while working on missing attributes for Bayesian Ridge. Are you looking for help on this issue or interested in collaborating on updating the documentation to remove some of the ambiguity?
Dpananos commentedon Feb 11, 2020
Collaborating is an excellent idea! I would appreciate input from maintainers and devs on this one, and would like to help out where possible. I have a small class of approx 50 students whom can serve as a sample for any changes.
glemaitre commentedon Feb 14, 2020
So let's clarify a bit about what is going on in the implementation.
Xandy) are internally centred and thecoef_is computed. Then,coef_are rescaled using the centring information (X_scale) andintercept_is computed using this information as well (X_offsetandy_offset).X_offsetandy_offsetas required in the dense case. Basically, there is only a single solver which can accommodate to fit the intercept in this case which is the sparse coordinate descentsparse_cg. Again, it will not penalize the intercept.Finally, when the documentation stipulates to center the data with
fit_intercept=False, it asks to centre bothXandysuch that there is not intercept. If not, you are still forcing to have a solution to pass by the origin with data that are not centred on it. As @agramfort mentioned to IRL, it is an issue in low-dimensional space while maybe not much an issue in high-dimensional space.This said. We could improve the documentation by stating that both
Xandyare expected to be centred such that the intercept is indeed null.Dpananos commentedon Feb 18, 2020
Clarifying that:
fit_intercept=Truefits the intercept but does not include it in the optimizationXandyare expected to be centered instead of thedatawould go a long way, IMO