Skip to content

fit_intercept in ridge could be improved #16394

Closed

Description

@Dpananos

Describe the issue linked to the documentation

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.

Activity

  1. phil-cork commented on Feb 11, 2020

    @phil-cork

    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?

  2. Dpananos commented on Feb 11, 2020

    @Dpananos
    Author

    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.

  3. glemaitre commented on Feb 14, 2020

    @glemaitre
    Member

    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.

  4. Dpananos commented on Feb 18, 2020

    @Dpananos
    Author

    Clarifying that:

    • Specifying fit_intercept=True fits the intercept but does not include it in the optimization
    • X and y are expected to be centered instead of the data

    would go a long way, IMO

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions