question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: regression report

See original GitHub issue

Describe the workflow you want to enable

I’d like an alternative to the wildely used sklearn.metrics.classification_report for regression problems

Describe your proposed solution

I purpose to implement it as sklearn.metrics.regression_report, following code is a draft I code my self to re-use:

from sklearn.metrics import mean_absolute_error, mean_squared_error, max_error, median_absolute_error, r2_score, explained_variance_score
import numpy as np

def regression_report(y_true, y_pred):
    
    error = y_true - y_pred
    percentil = [5,25,50,75,95]
    percentil_value = np.percentile(error, percentil)
    
    metrics = [
        ('mean absolute error', mean_absolute_error(y_true, y_pred)),
        ('median absolute error', median_absolute_error(y_true, y_pred)),
        ('mean squared error', mean_squared_error(y_true, y_pred)),
        ('max error', max_error(y_true, y_pred)),
        ('r2 score', r2_score(y_true, y_pred)),
        ('explained variance score', explained_variance_score(y_true, y_pred))
    ]
    
    print('Metrics for regression:')
    for metric_name, metric_value in metrics:
        print(f'{metric_name:>25s}: {metric_value: >20.3f}')
        
    print('\nPercentiles:')
    for p, pv in zip(percentil, percentil_value):
        print(f'{p: 25d}: {pv:>20.3f}')

Usage example:

>>> from sklearn.metrics import regression_report
>>> regression_report(y_train, y_train_pred)
>>> Metrics for regression:
      mean absolute error:               10.176
    median absolute error:                6.714
       mean squared error:              247.877
                max error:               82.595
                 r2 score:                0.565
 explained variance score:                0.574

Percentiles:
                        5:              -14.780
                       25:               -6.320
                       50:               -0.271
                       75:                7.300
                       95:               34.608

Describe alternatives you’ve considered, if relevant

Relevant metrics and inpout/output format should be discussed by the community according to its interest and usage, and keeping the interfaces as similar as possible to the related classification_report.

Additional context

I’m able to implement and raise a PR if there is interest on it. I’d love to contribute to this library, Just would like to know if there is interest for this and how/which metrics to include in the report

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:8
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
nasserboancommented, Oct 2, 2020

Hello @rola93! Nice addition, have you made any pull request with this code? I’m interested in helping with this implementation.

1reaction
Ratansingh648commented, Oct 2, 2020

Hi @rola93 , @nasserboan I have already started implementing this feature today. Will send a pull request soon. Investigating if some more attributes that are used commonly can be added to this.

Thanks !

Read more comments on GitHub >

github_iconTop Results From Across the Web

Windows 11 Feature Requests - Regression
Hi, I am on windows 11 since 2 weeks. It's great but I 2 very useful features have disappeared. First one : When...
Read more >
How to Request a Feature or Report a Bug in JASP
When you notice JASP cannot execute an important task (e.g., a type of analysis not implemented), you can tell us by issuing a...
Read more >
Who Cares About My Feature Request? | SpringerLink
Our analysis indicates that feature requests from non-IBM employees are less likely to be implemented than feature requests from IBM developers.
Read more >
Feature Request/Bug Report Form - Adobe
You can also use this form to report suspected bugs in Adobe products. We normally do not send personal replies to feature requests...
Read more >
Bug report, feature request, or simply praise? On automatically ...
Request PDF | On Aug 1, 2015, Walid Maalej and others published Bug report, feature request, or simply praise? On automatically classifying ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found