stable_cart.plot_mape_by_prediction

stable_cart.plot_mape_by_prediction(result, ax=None, n_bins=20, class_label=None)[source]

Show instability as a function of predicted value: who the model is unsure about.

Averaged over everyone, instability is a single number that hides its own distribution. Binned against the original prediction it answers the question a user actually has — whether the movement is spread evenly or concentrated in the range where decisions get made.

Parameters

result

Output of bootstrap_predictions().

ax

Axes to draw on. A new figure is created when omitted.

n_bins

Number of equal-count bins along the predicted-value axis. Equal-count rather than equal-width, so a sparse tail cannot produce a bin of two points and a dramatic-looking mean. A tree predicts one value per leaf, so when there are fewer distinct predictions than bins the distinct values are used directly — otherwise one leaf is split across two bins and the difference between them is noise drawn as signal.

class_label

Class whose original-fit probability defines the horizontal axis when result contains probability vectors. Required for probability audits. The vertical statistic still measures the full vector.

Returns

Any

The axes.

Raises

ValueError

If n_bins is below 2, or probability vectors are supplied without one valid class_label.

Parameters:
Return type:

Any