Skip to content

add RMSLE to sklearn.metrics.SCORERS.keys() #21686

Closed

Description

@rozeappletree

Describe the workflow you want to enable

  • add RMSLE as one of avaliable metrics with cv functions and others

Describe your proposed solution

Na

Describe alternatives you've considered, if relevant

Na

Additional context

Na

Activity

  1. rozeappletree commented on Nov 16, 2021

    @rozeappletree
    Author

    Is it good to have?

  2. adrinjalali commented on Nov 16, 2021

    @adrinjalali
    Member
  3. lorentzenchr commented on Nov 17, 2021

    @lorentzenchr
    Member

    I'm +0 on this one. There's no harm in adding it. But I already have my doubts about MSLE which we already have.

    As info, not for discussion: My doubts stem from the fact that it is not clear to me what functional of the predictive distribution we get when minimizing MSLE. For instance, minimizing squared error gives the conditional expectation E[Y|X], minimizing absolute error gives the conditional median Median[Y|X] (given that the correct model is among the models under consideration when minimizing).

    @INF800 I would help a little if your feature request would contain a bit more information and a motivation/use case why it is important (for you) to add this feature.

  4. rozeappletree commented on Nov 17, 2021

    @rozeappletree
    Author

    The use case is pretty simple. RMSLE is one of widely used losses and having it available 9ut of the box would be good to have but not seem necessary as you suggested.

    But getting it out of the box is good to have in terms of developer experience.

    I raised this PR because we have both
    neg_mean_squared_error and neg_root_mean_squared_error implementations available. Can't we use the same rationale to implement RMSLE along with MSLE.

  5. lorentzenchr commented on Nov 19, 2021

    @lorentzenchr
    Member

    The motivation for RMSE is to have a metric with the same unit (meter, seconds, money) as the target y which makes it easier to read and interpret. MSLE is on the unit of the square of the log of the unit of the target, i.e. taking the square root does not really make it better (log unit vs square log unit).
    Additionally, adding it also adds maintenance costs.

    All you need in user code is:

    import numpy as np
    from sklearn.metrics import make_scorer, mean_squared_log_error 
    
    def rmsle(y_true, y_pred):
        return np.sqrt(mean_squared_log_error(y_true, y_pred))
    
    rmsle_scorer = make_scorer(rmsle, greater_is_better=False)
  6. rozeappletree commented on Nov 19, 2021

    @rozeappletree
    Author

    The motivation for RMSE is to have a metric with the same unit (meter, seconds, money) as the target y which makes it easier to read and interpret. MSLE is on the unit of the square of the log of the unit of the target, i.e. taking the square root does not really make it better (log unit vs square log unit). Additionally, adding it also adds maintenance costs.

    All you need in user code is:

    import numpy as np
    from sklearn.metrics import make_scorer, mean_squared_log_error 
    
    def rmsle(y_true, y_pred):
        return np.sqrt(mean_squared_log_error(y_true, y_pred))
    
    rmsle_scorer = make_scorer(rmsle, greater_is_better=False)

    +1 makes sense.

  7. lorentzenchr commented on Nov 20, 2021

    @lorentzenchr
    Member

    One more suggestion: If you are interested in estimating the expectation E[Y|X], and if your target y is positive, you may be interested in using mean_gamma_deviance. Among a certain set of meaningful scoring functions, it has the unique property of being scale invariant: Multiplying y_pred and y_true by the same positive number does not change the score. It therefore has no unit (or unit 1).

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