stable_cart.plot_stability_frontier

stable_cart.plot_stability_frontier(results, ax=None, annotate=True, metric='instability')[source]

Plot one or more model families on the validation-score/stability plane.

The point of putting families on shared axes is that the answer is often “pruning wins”, and a plot that cannot show that is advocacy rather than measurement. Filled markers joined by a line are each family’s Pareto set; hollow markers are the configurations it dominates.

Parameters

results

Mapping of family name to the output of stability_frontier().

ax

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

annotate

Label each frontier point with its parameters. Turn off when the grid is large enough that the labels collide.

metric

'instability' (the quantity selected when constructing the frontier) or 'mape' (Riley and Collins’s mean absolute prediction error).

Returns

Any

The axes.

Raises

ValueError

If metric is not one of the two supported keys.

Examples

>>> import matplotlib
>>> matplotlib.use("Agg")
>>> from sklearn.datasets import make_regression
>>> from sklearn.tree import DecisionTreeRegressor
>>> from stable_cart import plot_stability_frontier, stability_frontier
>>> X, y = make_regression(n_samples=200, n_features=5, random_state=0)
>>> cart = stability_frontier(
...     lambda **kw: DecisionTreeRegressor(random_state=0, **kw),
...     {"max_depth": [2, 5]}, X, y, n_bootstrap=8, random_state=0,
... )
>>> type(plot_stability_frontier({"CART": cart})).__name__
'Axes'
Parameters:
Return type:

Any