<jupyter_start><jupyter_text>https://docs.pymc.io/notebooks/api_quickstart.html4.1-Predicting-on-hold-out-dataIn many cases you want to predict on unseen / hold-out data. This is especially relevant in Probabilistic Machine Learning and Bayesian Deep Learning. While we plan to improve the API in this regard, this can currently be achieved with a theano.shared variable. These are theano tensors whose values can be changed later. Otherwise they can be passed into PyMC3 just like any other numpy array or tensor.This distinction is significant since internally all models in PyMC3 are giant symbolic expressions. When you pass data directly into a model, you are giving Theano permission to treat this data as a constant and optimize it away as it sees fit. If you need to change this data later you might not have a way to point at it in the symbolic expression. Using theano.shared offers a way to point to a place in that symbolic expression, and change what is there.  Try this theano version showed<jupyter_code>import theano
import pymc3 as pm
import numpy as np

x = np.random.randn(100)
y = x > 0

x_shared = theano.shared(x)
y_shared = theano.shared(y)

with pm.Model() as model:
    coeff = pm.Normal('x', mu=0, sd=1)
    logistic = pm.math.sigmoid(coeff * x_shared)
    pm.Bernoulli('obs', p=logistic, observed=y_shared)
    trace = pm.sample(50000)
pm.traceplot(trace, combined=True)
x_shared.set_value([-1, 0, 1.])
y_shared.set_value([0, 0, 0]) # dummy values

with model:
    post_pred = pm.sample_ppc(trace, samples=500)
post_pred['obs'].mean(axis=0)<jupyter_output><empty_output><jupyter_text>Without the theano stuff?<jupyter_code>x = np.random.randn(100)
y = x > 0

with pm.Model() as model:
    coeff = pm.Normal('x', mu=0, sd=1)
    logistic = pm.math.sigmoid(coeff * x)
    pm.Bernoulli('obs', p=logistic, observed=y)
    trace = pm.sample()
pm.traceplot(trace)

with model:
    post_pred = pm.sample_ppc(trace, samples=500)
post_pred['obs'].mean(axis=0)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09566517189835576, 'fraction_numerical': 0.017937219730941704, 'mean_word_length': 4.656338028169014, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '177231', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 677, 'n_tokens_neox': 648, 'n_words': 234, 'path': 'Logit/pymc3 example 4.1 - Predicting on holdout data.ipynb', 'repo_name': 'balarsen/pymc_learning', 'size': '2007'}