feat(skore): Create a "custom" metrics registry under each report#2277
Draft
thomass-dev wants to merge 14 commits intomainfrom
Draft
feat(skore): Create a "custom" metrics registry under each report#2277thomass-dev wants to merge 14 commits intomainfrom
thomass-dev wants to merge 14 commits intomainfrom
Conversation
Contributor
Contributor
Collaborator
Author
from sklearn.datasets import make_regression
from sklearn.linear_model import LinearRegression
from sklearn.metrics import get_scorer
from sklearn.model_selection import train_test_split
from skore._sklearn._metric.registry import NewEstimatorReport
X, y = make_regression(random_state=42)
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)
report = NewEstimatorReport(
LinearRegression(),
X_train=X_train,
y_train=y_train,
X_test=X_test,
y_test=y_test,
)
def my_business_metric(*args, **kwargs):
return 1
report.metrics.append(get_scorer("explained_variance"))
report.metrics.append("neg_mean_squared_error")
report.metrics.append(my_business_metric)
print(report.metrics)
print(report.metrics.r2())
print(report.metrics.explained_variance_score())
print(report.metrics.mean_squared_error())
print(report.metrics.my_business_metric()) |
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Caution
Just a notebook for reflection for now.
Points to cover:
__call__in each metric subclass to provide a more user-friendly APIr2calling_r2r2 = R2(); help(r2)Closes https://github.com/probabl-ai/skore-hub/issues/940.