Skip to content

Commit

Permalink
[BUG] fix plot_crossplot_std for predict_var return (#71)
Browse files Browse the repository at this point in the history
This PR fixes an unreported bug where `plot_crossplot_std` would crash
for for a `predict_var` return (as opposed to a full distributional
prediction).

This is fixed, and a test is added.
  • Loading branch information
fkiraly authored Sep 10, 2023
1 parent 54a73a1 commit 5e855e0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion skpro/utils/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,10 @@ def plot_crossplot_std(y_true, y_pred, ax=None):

from matplotlib import pyplot

if hasattr(y_pred, "_tags"):
if hasattr(y_pred, "_tags") and not isinstance(y_pred, pd.DataFrame):
y_var = y_pred.var()
else:
y_var = y_pred

y_std = np.sqrt(y_var)

Expand Down
3 changes: 3 additions & 0 deletions skpro/utils/tests/test_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ def test_plot_crossplot_std():

plot_crossplot_std(y, y_pred)

y_pred_var = reg_proba.predict_var(X)
plot_crossplot_std(y, y_pred_var)


@pytest.mark.skipif(
not _check_soft_dependencies("matplotlib", severity="none"),
Expand Down

0 comments on commit 5e855e0

Please sign in to comment.