Skip to content

Commit e2c7e2c

Browse files
committed
improve default fmt
1 parent 4a2069b commit e2c7e2c

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

examples/model_evaluation/plot_estimator_report.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ def operational_decision_cost(y_true, y_pred, amount):
405405
# More plotting options are available via ``heatmap_kwargs``, which are passed to
406406
# seaborn's heatmap. For example, we can customize the colormap and number format:
407407
cm_display = report.metrics.confusion_matrix()
408-
cm_display.plot(heatmap_kwargs={"cmap": "Greens", "fmt": "d"})
408+
cm_display.plot(heatmap_kwargs={"cmap": "Greens", "fmt": ".2e"})
409409
plt.show()
410410

411411
# %%

skore/src/skore/_sklearn/_plot/metrics/confusion_matrix.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ def __init__(
5151

5252
_default_heatmap_kwargs: dict = {
5353
"cmap": "Blues",
54-
"fmt": ".2f",
5554
"annot": True,
5655
"cbar": True,
5756
}
@@ -126,7 +125,7 @@ def _plot_single_estimator(
126125
self.figure_, self.ax_ = plt.subplots()
127126

128127
heatmap_kwargs_validated = _validate_style_kwargs(
129-
self._default_heatmap_kwargs,
128+
{"fmt": ".2f" if normalize else "d", **self._default_heatmap_kwargs},
130129
heatmap_kwargs or {},
131130
)
132131

skore/tests/unit/displays/confusion_matrix/test_estimator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def test_default_heatmap_kwargs(pyplot, forest_binary_classification_with_train_
189189
assert len(display.ax_.texts) > 0
190190
assert all(isinstance(text, mpl.text.Text) for text in display.ax_.texts)
191191
for text in display.ax_.texts:
192-
assert "." in text.get_text()
192+
assert "." not in text.get_text()
193193
assert len(display.figure_.axes) == 2
194194

195195

0 commit comments

Comments
 (0)