Skip to content

Commit

Permalink
swapped out class pm.Data to just pm.Data
Browse files Browse the repository at this point in the history
  • Loading branch information
Dekermanjian committed Jul 31, 2024
1 parent 2df0716 commit bc7ab3c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions examples/fundamentals/data_container.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"In this next model, we create a {class}`pm.Data` container to hold the observations, and pass this container to the `observed`. We also make a {class}`pm.Data` container to hold the `x` data:"
"In this next model, we create a `pm.Data` container to hold the observations, and pass this container to the `observed`. We also make a `pm.Data` container to hold the `x` data:"
]
},
{
Expand Down Expand Up @@ -793,7 +793,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Because we used a {class}`pm.Data` container, the data now appears in our probabilistic graph. It is downstream from `obs` (since the `obs` variable \"causes\" the data), shaded in gray (because it is observed), and has a special rounded square shape to emphasize that it is data. We also see that `x_data` has been added to the graph."
"Because we used a `pm.Data` container, the data now appears in our probabilistic graph. It is downstream from `obs` (since the `obs` variable \"causes\" the data), shaded in gray (because it is observed), and has a special rounded square shape to emphasize that it is data. We also see that `x_data` has been added to the graph."
]
},
{
Expand Down Expand Up @@ -1509,7 +1509,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"As noted above, {class}`pm.Data` gives you the ability to give named labels to the dimensions of your data. This is done by passing a dictionary of `dimension: coordinate` key-value pairs to the `coords` argument of {class}`pymc.Model` when you create your model.\n",
"As noted above, `pm.Data` gives you the ability to give named labels to the dimensions of your data. This is done by passing a dictionary of `dimension: coordinate` key-value pairs to the `coords` argument of {class}`pymc.Model` when you create your model.\n",
"\n",
"For more explanation about dimensions, coordinates and their big benefits, we encourage you to take a look at the {ref}`ArviZ documentation <arviz:xarray_for_arviz>`.\n",
"\n",
Expand Down Expand Up @@ -1826,7 +1826,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"When we use {class}`pm.Data`, the data are internally represented as a pytensor {class}`pytensor.tensor.sharedvar.TensorSharedVariable`."
"When we use `pm.Data`, the data are internally represented as a pytensor {class}`pytensor.tensor.sharedvar.TensorSharedVariable`."
]
},
{
Expand Down Expand Up @@ -2527,7 +2527,7 @@
"\n",
"One small detail to pay attention to in this case is that the shapes of the input data (`x`) and output data (`obs`) must be the same. When we make out-of-sample predictions, we typically change only the input data, the shape of which may not be the same as the training observations. Naively changing only one will result in a shape error. There are two solutions:\n",
"\n",
"1. Use a {class}`pm.Data` for the `x` data and the `y` data, and use `pm.set_data` to change `y` to something of the same shape as the test inputs. \n",
"1. Use a `pm.Data` for the `x` data and the `y` data, and use `pm.set_data` to change `y` to something of the same shape as the test inputs. \n",
"2. Tell PyMC that the shape of the `obs` should always be the shape of the input data.\n",
"\n",
"In the next model, we use option 2. This way, we don't need to pass dummy data to `y` every time we want to change `x`."
Expand Down
10 changes: 5 additions & 5 deletions examples/fundamentals/data_container.myst.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Furthermore, inside `idata`, PyMC has automatically saved the observed (endogeno
idata.observed_data
```

In this next model, we create a {class}`pm.Data` container to hold the observations, and pass this container to the `observed`. We also make a {class}`pm.Data` container to hold the `x` data:
In this next model, we create a `pm.Data` container to hold the observations, and pass this container to the `observed`. We also make a `pm.Data` container to hold the `x` data:

```{code-cell} ipython3
with pm.Model() as no_data_model:
Expand All @@ -108,7 +108,7 @@ with pm.Model() as no_data_model:
idata = pm.sample(random_seed=RANDOM_SEED)
```

Because we used a {class}`pm.Data` container, the data now appears in our probabilistic graph. It is downstream from `obs` (since the `obs` variable "causes" the data), shaded in gray (because it is observed), and has a special rounded square shape to emphasize that it is data. We also see that `x_data` has been added to the graph.
Because we used a `pm.Data` container, the data now appears in our probabilistic graph. It is downstream from `obs` (since the `obs` variable "causes" the data), shaded in gray (because it is observed), and has a special rounded square shape to emphasize that it is data. We also see that `x_data` has been added to the graph.

```{code-cell} ipython3
pm.model_to_graphviz(no_data_model)
Expand Down Expand Up @@ -138,7 +138,7 @@ df_data.index.name = "date"
df_data.head()
```

As noted above, {class}`pm.Data` gives you the ability to give named labels to the dimensions of your data. This is done by passing a dictionary of `dimension: coordinate` key-value pairs to the `coords` argument of {class}`pymc.Model` when you create your model.
As noted above, `pm.Data` gives you the ability to give named labels to the dimensions of your data. This is done by passing a dictionary of `dimension: coordinate` key-value pairs to the `coords` argument of {class}`pymc.Model` when you create your model.

For more explanation about dimensions, coordinates and their big benefits, we encourage you to take a look at the {ref}`ArviZ documentation <arviz:xarray_for_arviz>`.

Expand Down Expand Up @@ -193,7 +193,7 @@ Coordinates are also used by `arviz` when making plots. Here we pass `legend=Tru
axes = az.plot_trace(idata, var_names=["europe_mean_temp", "expected_city_temp"], legend=True);
```

When we use {class}`pm.Data`, the data are internally represented as a pytensor {class}`pytensor.tensor.sharedvar.TensorSharedVariable`.
When we use `pm.Data`, the data are internally represented as a pytensor {class}`pytensor.tensor.sharedvar.TensorSharedVariable`.

```{code-cell} ipython3
type(data)
Expand Down Expand Up @@ -277,7 +277,7 @@ A common task in machine learning is to predict values for unseen data, and the

One small detail to pay attention to in this case is that the shapes of the input data (`x`) and output data (`obs`) must be the same. When we make out-of-sample predictions, we typically change only the input data, the shape of which may not be the same as the training observations. Naively changing only one will result in a shape error. There are two solutions:

1. Use a {class}`pm.Data` for the `x` data and the `y` data, and use `pm.set_data` to change `y` to something of the same shape as the test inputs.
1. Use a `pm.Data` for the `x` data and the `y` data, and use `pm.set_data` to change `y` to something of the same shape as the test inputs.
2. Tell PyMC that the shape of the `obs` should always be the shape of the input data.

In the next model, we use option 2. This way, we don't need to pass dummy data to `y` every time we want to change `x`.
Expand Down

0 comments on commit bc7ab3c

Please sign in to comment.