MCPcopy Create free account
hub / github.com/dmlc/xgboost / plot_band

Function plot_band

demo/guide-python/prediction_intervals.py:150–172  ·  view source on GitHub ↗
(
        ax: "plt.Axes", pred: np.ndarray, title: str, center_label: str
    )

Source from the content-addressed store, hash-verified

148 fig, axes = plt.subplots(2, 1, figsize=(10, 12), sharex=True, sharey=True)
149
150 def plot_band(
151 ax: "plt.Axes", pred: np.ndarray, title: str, center_label: str
152 ) -> None:
153 ax.plot(grid, f(grid), "g:", linewidth=3, label=r"$f(x) = x\,\sin(x)$")
154 ax.plot(
155 features,
156 target,
157 "b.",
158 markersize=5,
159 alpha=0.35,
160 label="Test observations",
161 )
162 ax.plot(grid, pred[:, 1], "r-", label=center_label)
163 ax.plot(grid, predictions["mean"], "m--", label="Squared-error mean")
164 ax.plot(grid, pred[:, 0], "k-")
165 ax.plot(grid, pred[:, 2], "k-")
166 ax.fill_between(
167 grid.ravel(), pred[:, 0], pred[:, 2], alpha=0.3, label="90% band"
168 )
169 ax.set_title(title)
170 ax.set_ylabel("$y$")
171 ax.set_ylim(-10, 25)
172 ax.legend(loc="upper left")
173
174 plot_band(
175 axes[0],

Callers 1

Calls 1

fFunction · 0.70

Tested by

no test coverage detected