Hi @cluhmann
I am trying to use my model to plot the predictive error with below code but I see some weird probability values in Y axis, kindly advice on this
import matplotlib.pyplot as plt
predictors_out_of_sample = np.random.normal(0,1,size=21).astype('int64')
outcomes_out_of_sample = np.random.binomial( 1,predictors_out_of_sample.mean().astype('int64'),size=21)
with m:
# update values of predictors:
pm.set_data({"data": predictors_out_of_sample})
# use the updated values and predict outcomes and probabilities:
posterior_predictive = pm.sample_posterior_predictive(
ptrace1, var_names=["obs"], random_seed=15
)
model_preds = posterior_predictive["obs"]
_, ax = plt.subplots(figsize=(12, 6))
# uncertainty about the estimates:
ax.plot(
[predictors_out_of_sample, predictors_out_of_sample],
az.hdi(model_preds).T,
lw=6,
color="#00204C",
alpha=0.8,
)
# expected probability of success:
ax.plot(
predictors_out_of_sample,
model_preds.mean(0),
"o",
ms=5,
color="#FFE945",
alpha=0.8,
label="Expected prob.",
)
# actual outcomes:
ax.scatter(
x=predictors_out_of_sample,
y=outcomes_out_of_sample,
marker="x",
color="#A69C75",
alpha=0.8,
label="Observed outcomes",
)
# true probabilities:
x = np.linspace(predictors_out_of_sample.min() - 0.1, predictors_out_of_sample.max() + 0.1,num=21)
ax.plot(
x,
predictors_out_of_sample,
lw=2,
ls="--",
color="#565C6C",
alpha=0.8,
label="True prob.",
)
ax.set_xlabel("Predictor")
ax.set_ylabel("Prob. of succes")
ax.set_title("Out-of-sample Predictions")
ax.legend(fontsize=10, frameon=True, framealpha=0.5);
Kindly advice on this
