Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Make the progress bar disappear at the end of their execution #1255

Merged
merged 7 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions skore/src/skore/sklearn/_cross_validation/metrics_accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ def report_metrics(
>>> X, y = load_breast_cancer(return_X_y=True)
>>> classifier = LogisticRegression(max_iter=10_000)
>>> report = CrossValidationReport(classifier, X=X, y=y, cv_splitter=2)
Processing cross-validation ...
>>> report.metrics.report_metrics(
... scoring=["precision", "recall"], pos_label=1, aggregate=["mean", "std"]
... )
Expand Down Expand Up @@ -211,7 +210,6 @@ def accuracy(self, *, data_source="test", aggregate=None):
>>> X, y = load_breast_cancer(return_X_y=True)
>>> classifier = LogisticRegression(max_iter=10_000)
>>> report = CrossValidationReport(classifier, X=X, y=y, cv_splitter=2)
Processing cross-validation ...
>>> report.metrics.accuracy()
Compute metric for each split ...
Metric Accuracy (↗︎)
Expand Down Expand Up @@ -291,7 +289,6 @@ def precision(
>>> X, y = load_breast_cancer(return_X_y=True)
>>> classifier = LogisticRegression(max_iter=10_000)
>>> report = CrossValidationReport(classifier, X=X, y=y, cv_splitter=2)
Processing cross-validation ...
>>> report.metrics.precision()
Compute metric for each split ...
Metric Precision (↗︎)
Expand Down Expand Up @@ -375,7 +372,6 @@ def recall(
>>> X, y = load_breast_cancer(return_X_y=True)
>>> classifier = LogisticRegression(max_iter=10_000)
>>> report = CrossValidationReport(classifier, X=X, y=y, cv_splitter=2)
Processing cross-validation ...
>>> report.metrics.recall()
Compute metric for each split ...
Metric Recall (↗︎)
Expand Down Expand Up @@ -421,7 +417,6 @@ def brier_score(self, *, data_source="test", aggregate=None):
>>> X, y = load_breast_cancer(return_X_y=True)
>>> classifier = LogisticRegression(max_iter=10_000)
>>> report = CrossValidationReport(classifier, X=X, y=y, cv_splitter=2)
Processing cross-validation ...
>>> report.metrics.brier_score()
Compute metric for each split ...
Metric Brier score (↘︎)
Expand Down Expand Up @@ -507,7 +502,6 @@ def roc_auc(
>>> X, y = load_breast_cancer(return_X_y=True)
>>> classifier = LogisticRegression(max_iter=10_000)
>>> report = CrossValidationReport(classifier, X=X, y=y, cv_splitter=2)
Processing cross-validation ...
>>> report.metrics.roc_auc()
Compute metric for each split ...
Metric ROC AUC (↗︎)
Expand Down Expand Up @@ -554,7 +548,6 @@ def log_loss(self, *, data_source="test", aggregate=None):
>>> X, y = load_breast_cancer(return_X_y=True)
>>> classifier = LogisticRegression(max_iter=10_000)
>>> report = CrossValidationReport(classifier, X=X, y=y, cv_splitter=2)
Processing cross-validation ...
>>> report.metrics.log_loss()
Compute metric for each split ...
Metric Log loss (↘︎)
Expand Down Expand Up @@ -611,7 +604,6 @@ def r2(
>>> X, y = load_diabetes(return_X_y=True)
>>> regressor = Ridge()
>>> report = CrossValidationReport(regressor, X=X, y=y, cv_splitter=2)
Processing cross-validation ...
>>> report.metrics.r2()
Compute metric for each split ...
Metric R² (↗︎)
Expand Down Expand Up @@ -669,7 +661,6 @@ def rmse(
>>> X, y = load_diabetes(return_X_y=True)
>>> regressor = Ridge()
>>> report = CrossValidationReport(regressor, X=X, y=y, cv_splitter=2)
Processing cross-validation ...
>>> report.metrics.rmse()
Compute metric for each split ...
Metric RMSE (↘︎)
Expand Down Expand Up @@ -745,7 +736,6 @@ def custom_metric(
>>> X, y = load_diabetes(return_X_y=True)
>>> regressor = Ridge()
>>> report = CrossValidationReport(regressor, X=X, y=y, cv_splitter=2)
Processing cross-validation ...
>>> report.metrics.custom_metric(
... metric_function=mean_absolute_error,
... response_method="predict",
Expand Down Expand Up @@ -975,7 +965,6 @@ def roc(self, *, data_source="test", pos_label=None, ax=None):
>>> X, y = load_breast_cancer(return_X_y=True)
>>> classifier = LogisticRegression(max_iter=10_000)
>>> report = CrossValidationReport(classifier, X=X, y=y, cv_splitter=2)
Processing cross-validation ...
>>> display = report.metrics.plot.roc()
Computing predictions for display ...
>>> display.plot(roc_curve_kwargs={"color": "tab:red"})
Expand Down Expand Up @@ -1026,7 +1015,6 @@ def precision_recall(self, *, data_source="test", pos_label=None, ax=None):
>>> X, y = load_breast_cancer(return_X_y=True)
>>> classifier = LogisticRegression(max_iter=10_000)
>>> report = CrossValidationReport(classifier, X=X, y=y, cv_splitter=2)
Processing cross-validation ...
>>> display = report.metrics.plot.precision_recall()
Computing predictions for display ...
>>> display.plot()
Expand Down Expand Up @@ -1101,7 +1089,6 @@ def prediction_error(
>>> X, y = load_diabetes(return_X_y=True)
>>> regressor = Ridge()
>>> report = CrossValidationReport(regressor, X=X, y=y, cv_splitter=2)
Processing cross-validation ...
>>> display = report.metrics.plot.prediction_error(
... kind="actual_vs_predicted"
... )
Expand Down
3 changes: 0 additions & 3 deletions skore/src/skore/sklearn/_cross_validation/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ class CrossValidationReport(_BaseReport, DirNamesMixin):
>>> estimator = LogisticRegression()
>>> from skore import CrossValidationReport
>>> report = CrossValidationReport(estimator, X=X, y=y, cv_splitter=2)
Processing cross-validation ...
"""

_ACCESSOR_CONFIG = {
Expand Down Expand Up @@ -181,7 +180,6 @@ def clear_cache(self):
>>> X, y = load_breast_cancer(return_X_y=True)
>>> classifier = LogisticRegression(max_iter=10_000)
>>> report = CrossValidationReport(classifier, X=X, y=y, cv_splitter=2)
Processing cross-validation ...
>>> report.cache_predictions()
Cross-validation predictions ...
Caching predictions ...
Expand Down Expand Up @@ -216,7 +214,6 @@ def cache_predictions(self, response_methods="auto", n_jobs=None):
>>> X, y = load_breast_cancer(return_X_y=True)
>>> classifier = LogisticRegression(max_iter=10_000)
>>> report = CrossValidationReport(classifier, X=X, y=y, cv_splitter=2)
Processing cross-validation ...
>>> report.cache_predictions()
Cross-validation predictions ...
Caching predictions ...
Expand Down
4 changes: 4 additions & 0 deletions skore/src/skore/utils/_progress_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
def progress_decorator(description):
"""Decorate class methods to add a progress bar.

This decorator adds a Rich progress bar to class methods, displaying progress
during execution. The progress bar automatically disappears after completion.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lint job is failing because you have trailing space here.

Suggested change
during execution. The progress bar automatically disappears after completion.
during execution. The progress bar automatically disappears after completion.

Parameters
----------
description : str or callable
Expand Down Expand Up @@ -43,6 +46,7 @@ def wrapper(*args, **kwargs):
),
TextColumn("[orange1]{task.percentage:>3.0f}%"),
expand=False,
transient=True,
)
progress.start()

Expand Down
Loading