-
Notifications
You must be signed in to change notification settings - Fork 97
refactor: Refactor confusion matrix #1759
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
base: main
Are you sure you want to change the base?
Conversation
|
[automated comment] Please update your PR with main, so that the |
9e30d04 to
62080ea
Compare
62080ea to
e59f761
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In terms of API, we should remove sample_weight (we are not currently supporting it).
For the parameter display_labels, include_values, normalize and value_format, they should be only used in .plot of the display.
| y_true=y, | ||
| y_pred=y_pred, | ||
| sample_weight=sample_weight, | ||
| cm = sklearn_confusion_matrix( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To follow the other display api, we should implement a _compute_data_for_display class method in the display. Basically, it will replace the previous from_predictions.
|
|
||
| from skore.sklearn._plot.base import Display | ||
| from skore.sklearn._plot.style import StyleDisplayMixin | ||
| from skore.sklearn._plot.utils import HelpDisplayMixin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not decorate __init__ but the plot method (cf. RocCurveDisplay for a concrete example)
|
|
||
|
|
||
| class ConfusionMatrixDisplay(Display): | ||
| class ConfusionMatrixDisplay(StyleDisplayMixin, HelpDisplayMixin): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
display_labels, include_values, normalize and value_format should not be part of the constructor. They are way to change the plot and thus should be parameter of this plot method.
|
Actually, the design is a bit more tricky. I need to think a bit more about the design: |
Makes sense, I was on a long vacay, will look into this soon :) |
…rit from StyleDisplay and HelpDisplay mixins
e59f761 to
bd2ecd7
Compare
================================================== FAILURES ===================================================
____________________________________________ [xdoctest] Project:0 _____________________________________________
* REASON: SystemError
DOCTEST DEBUG INFO
XDoc "/Users/m_warid/Desktop/dev/repos/skore/skore/src/skore/project/project.py::Project:0", line 35 <- wrt doctest
File "/Users/m_warid/Desktop/dev/repos/skore/skore/src/skore/project/project.py", line 129, <- wrt source file
DOCTEST PART BREAKDOWN
Passed Parts:
1 >>> from sklearn.datasets import make_classification, make_regression
2 >>> from sklearn.linear_model import LinearRegression, LogisticRegression
3 >>> from sklearn.model_selection import train_test_split
4 >>> from skore.sklearn import EstimatorReport
5 >>>
6 >>> X, y = make_classification(random_state=42)
7 >>> X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)
8 >>> classifier = LogisticRegression(max_iter=10)
9 >>> classifier_report = EstimatorReport(
10 >>> classifier,
11 >>> X_train=X_train,
12 >>> y_train=y_train,
13 >>> X_test=X_test,
14 >>> y_test=y_test,
15 >>> )
16 >>>
17 >>> X, y = make_regression(random_state=42)
18 >>> X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)
19 >>> regressor = LinearRegression()
20 >>> regressor_report = EstimatorReport(
21 >>> regressor,
22 >>> X_train=X_train,
23 >>> y_train=y_train,
24 >>> X_test=X_test,
25 >>> y_test=y_test,
26 >>> )
Failed Part:
30 >>> from pathlib import Path
31 >>> from tempfile import TemporaryDirectory
32 >>> from skore import Project
33 >>>
34 >>> tmpdir = TemporaryDirectory().name
35 >>> local_project = Project("my-xp", workspace=Path(tmpdir))
Remaining Parts:
39 >>> local_project.put("my-simple-classification", classifier_report)
40 >>> local_project.put("my-simple-regression", regressor_report)
44 >>> summary = local_project.summarize()
45 >>> summary = summary.query("ml_task.str.contains('regression') and (rmse < 67)")
46 >>> reports = summary.reports()
DOCTEST TRACEBACK
Traceback (most recent call last):
File "/Users/m_warid/Desktop/dev/esoc/skore/displayAllMetrics/lib/python3.10/site-packages/xdoctest/doctest_example.py", line 868, in run
exec(code, test_globals)
File "<doctest:/Users/m_warid/Desktop/dev/repos/skore/skore/src/skore/project/project.py::Project:0>", line rel: 35, abs: 129, in <module>
>>> local_project = Project("my-xp", workspace=Path(tmpdir))
File "/Users/m_warid/Desktop/dev/repos/skore/skore/src/skore/project/project.py", line 199, in __init__
mode, name, plugin, parameters = Project.__setup_plugin(name)
File "/Users/m_warid/Desktop/dev/repos/skore/skore/src/skore/project/project.py", line 152, in __setup_plugin
raise SystemError("No project plugin found, please install at least one.")
SystemError: No project plugin found, please install at least one.
DOCTEST REPRODUCTION
CommandLine:
pytest /Users/m_warid/Desktop/dev/repos/skore/skore/src/skore/project/project.py::Project:0
/Users/m_warid/Desktop/dev/repos/skore/skore/src/skore/project/project.py:129: SystemError
-------------------------------------------- Captured stdout call ---------------------------------------------
====== <exec> ======
* DOCTEST : /Users/m_warid/Desktop/dev/repos/skore/skore/src/skore/project/project.py::Project:0, line 95 <- wrt source file
=========================================== short test summary info ===========================================
FAILED src/skore/project/project.py::Project:0Is this a new addition to the testing suite? I had to run |
|
|
|
@waridrox please re-run |
Thanks for the tip @thomass-dev, maybe worthwhile adding this to local development docs... |
|
@waridrox, do you want to continue this PR, or should we take it over and iterate from here? |
|
Hi @MarieSacksick, I was waiting on some thoughts from @glemaitre on how to proceed about... |
Following up on #1757
CC: @glemaitre