Feature request: regression report
See original GitHub issueDescribe 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:
- Created 3 years ago
- Reactions:8
- Comments:6 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hello @rola93! Nice addition, have you made any pull request with this code? I’m interested in helping with this implementation.
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 !