Skip to content

Add calibration curve to plotting module #8425

@amueller

Description

@amueller

I think it would be nice to have something like

def plot_calibration_curve(y_true, prob_y_pred, n_bins=5, ax=None):
    prop_true, prop_pred = calibration_curve(y_true, prob_y_pred, n_bins=n_bins)
    if ax is None:
        ax = plt.gca()
    ax.plot([0, 1], [0, 1], ':', c='k')
    ax.plot(prop_pred, prop_true)

    ax.set_xlabel("predicted probability")
    ax.set_ylabel("fraction of positive samples")
    ax.set_aspect("equal")

I got confused for a bit because the order of the return arguments is not the order of the arguments to plot. I think a plot function even just labeling the axes right would decrease mental effort (yes, I'm lazy).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions