Skip to content

chore(skore/estimator-report): Clean some parts of the metrics accessor#2331

Merged
thomass-dev merged 9 commits intoprobabl-ai:mainfrom
auguste-probabl:push-ulwvtwwypxsp
Feb 6, 2026
Merged

chore(skore/estimator-report): Clean some parts of the metrics accessor#2331
thomass-dev merged 9 commits intoprobabl-ai:mainfrom
auguste-probabl:push-ulwvtwwypxsp

Conversation

@auguste-probabl
Copy link
Collaborator

In preparation for a larger refactor of _MetricsAccessor

@thomass-dev
Copy link
Collaborator

thomass-dev commented Jan 23, 2026

Please note that #2277 will result in significant changes to the metrics accessor.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 23, 2026

Documentation preview @ 43d7163

@github-actions
Copy link
Contributor

github-actions bot commented Jan 23, 2026

Coverage

Coverage Report for skore/
FileStmtsMissCoverMissing
skore/src/skore
   __init__.py250100% 
   _config.py310100% 
   _login.py140100% 
   exceptions.py440%4, 15, 19, 23
skore/src/skore/_sklearn
   __init__.py60100% 
   _base.py1991492%46, 59, 128, 131, 184, 187–188, 190–193, 226, 229–230
   feature_names.py260100% 
   find_ml_task.py610100% 
   types.py28196%30
skore/src/skore/_sklearn/_comparison
   __init__.py70100% 
   inspection_accessor.py32196%131
   metrics_accessor.py188298%178, 258
   report.py1200100% 
   utils.py570100% 
skore/src/skore/_sklearn/_cross_validation
   __init__.py90100% 
   data_accessor.py45295%137, 140
   inspection_accessor.py210100% 
   metrics_accessor.py190199%252
   report.py140199%525
skore/src/skore/_sklearn/_estimator
   __init__.py90100% 
   data_accessor.py66198%82
   inspection_accessor.py83297%326, 340
   metrics_accessor.py370598%427, 431, 446, 476, 1749
   report.py167298%450–451
skore/src/skore/_sklearn/_plot
   __init__.py30100% 
   base.py107694%63–64, 266–268, 272
   utils.py121298%273–274
skore/src/skore/_sklearn/_plot/data
   __init__.py20100% 
   table_report.py175199%657
skore/src/skore/_sklearn/_plot/inspection
   __init__.py00100% 
   coefficients.py2000100% 
   permutation_importance.py1490100% 
   utils.py90100% 
skore/src/skore/_sklearn/_plot/metrics
   __init__.py60100% 
   confusion_matrix.py156199%546
   metrics_summary_display.py80100% 
   precision_recall_curve.py1080100% 
   prediction_error.py1510100% 
   roc_curve.py1130100% 
skore/src/skore/_sklearn/train_test_split
   __init__.py00100% 
   train_test_split.py580100% 
skore/src/skore/_sklearn/train_test_split/warning
   __init__.py80100% 
   high_class_imbalance_too_few_examples_warning.py19194%83
   high_class_imbalance_warning.py200100% 
   random_state_unset_warning.py100100% 
   shuffle_true_warning.py90100% 
   stratify_is_set_warning.py100100% 
   time_based_column_warning.py210100% 
   train_test_split_warning.py30100% 
skore/src/skore/_utils
   __init__.py6266%8, 13
   _accessor.py107397%38, 207, 251
   _cache.py370100% 
   _environment.py270100% 
   _fixes.py80100% 
   _index.py50100% 
   _logger.py22481%15–17, 19
   _measure_time.py100100% 
   _parallel.py38392%23, 33, 124
   _patch.py211242%30, 35–39, 42–43, 46–47, 58, 60
   _progress_bar.py460100% 
   _repr_html.py80100% 
   _show_versions.py380100% 
   _testing.py60198%102
skore/src/skore/project
   __init__.py20100% 
   _summary.py75198%119
   _widget.py1870100% 
   project.py560100% 
TOTAL41177398% 

Tests Skipped Failures Errors Time
1475 5 💤 0 ❌ 0 🔥 10m 15s ⏱️

Copy link
Collaborator

@thomass-dev thomass-dev left a comment

Choose a reason for hiding this comment

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

IMO, this PR looks like a PR that changes only the "styling code". This should be avoided when possible, or included in other changes when really needed.

Otherwise, we could do the same thing for all parts of the code...

Comment on lines 556 to 561
if isinstance(score, list) and len(score) == 1:
score = score[0]
if isinstance(score, list) and "classification" in self._parent._ml_task:
score = dict(
zip(self._parent._estimator.classes_.tolist(), score, strict=False)
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use if/elif when the condition are exclusive. Same for your change on line 554.

Copy link
Collaborator Author

@auguste-probabl auguste-probabl Feb 5, 2026

Choose a reason for hiding this comment

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

@GaetandeCast @thomass-dev I've simplified the conditional but the conditions are not quite exclusive enough to go further. Please advise.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

reverted as I misunderstood what array.item() does (I thought it gave you the element of a 1-element array, but it also converts numpy-typed numbers to native types).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@thomass-dev please give it another look

@thomass-dev thomass-dev changed the title refactor: Various refactorings chore(skore/estimator-report): Clean some parts of the metrics accessor Jan 27, 2026
@auguste-probabl
Copy link
Collaborator Author

IMO, this PR looks like a PR that changes only the "styling code". This should be avoided when possible, or included in other changes when really needed.

I did these changes while working on a larger refactor, and I wanted to make it as simple to review and merge as possible

Copy link
Collaborator

@GaetandeCast GaetandeCast left a comment

Choose a reason for hiding this comment

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

I'm not against cleaning up the code even if it does not impact functionality. There is just one change I'm not convinced by.

@GaetandeCast
Copy link
Collaborator

So I'm ok with this, although I agree with @thomass-dev 's remark about exclusive if/if statements.

Copy link
Collaborator

@thomass-dev thomass-dev left a comment

Choose a reason for hiding this comment

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

LGTM now, thanks.

@thomass-dev thomass-dev enabled auto-merge February 6, 2026 14:48
@thomass-dev thomass-dev disabled auto-merge February 6, 2026 14:48
@thomass-dev thomass-dev merged commit bf47400 into probabl-ai:main Feb 6, 2026
35 checks passed
Sharkyii pushed a commit to Sharkyii/skore that referenced this pull request Feb 9, 2026
…or (probabl-ai#2331)

In preparation for a larger refactor of `_MetricsAccessor`
Sharkyii pushed a commit to Sharkyii/skore that referenced this pull request Feb 11, 2026
…or (probabl-ai#2331)

In preparation for a larger refactor of `_MetricsAccessor`
Sharkyii pushed a commit to Sharkyii/skore that referenced this pull request Feb 12, 2026
…or (probabl-ai#2331)

In preparation for a larger refactor of `_MetricsAccessor`
Sharkyii pushed a commit to Sharkyii/skore that referenced this pull request Feb 12, 2026
…or (probabl-ai#2331)

In preparation for a larger refactor of `_MetricsAccessor`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants