Skip to content

Commit 9029dab

Browse files
release/v1.0.0rc1: updating version numbers
1 parent 21fb101 commit 9029dab

52 files changed

Lines changed: 6560 additions & 2306 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cmdstanpy/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""PyPi Version"""
22

3-
__version__ = '0.9.77'
3+
__version__ = '1.0.0rc1'
-4.97 KB
Binary file not shown.
4.12 KB
Loading

docs/_modules/cmdstanpy/model.html

Lines changed: 356 additions & 270 deletions
Large diffs are not rendered by default.

docs/_modules/cmdstanpy/stanfit.html

Lines changed: 294 additions & 346 deletions
Large diffs are not rendered by default.

docs/_modules/cmdstanpy/utils.html

Lines changed: 333 additions & 196 deletions
Large diffs are not rendered by default.

docs/_modules/index.html

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
<head>
66
<meta charset="utf-8" />
77
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
8-
<title>Overview: module code &#8212; CmdStanPy 0.9.77 documentation</title>
8+
<title>Overview: module code &#8212; CmdStanPy 1.0.0rc1 documentation</title>
99

10-
<link href="../_static/css/theme.css" rel="stylesheet" />
11-
<link href="../_static/css/index.c5995385ac14fb8791e8eb36b4908be2.css" rel="stylesheet" />
10+
<link href="../_static/css/theme.css" rel="stylesheet">
11+
<link href="../_static/css/index.ff1ffe594081f20da1ef19478df9384b.css" rel="stylesheet">
1212

1313

1414
<link rel="stylesheet"
@@ -26,7 +26,7 @@
2626
<link rel="stylesheet" type="text/css" href="../_static/css/project-template.css" />
2727
<link rel="stylesheet" type="text/css" href="../_static/copybutton.css" />
2828

29-
<link rel="preload" as="script" href="../_static/js/index.1c5a1a01449ed65a7b51.js">
29+
<link rel="preload" as="script" href="../_static/js/index.be7d3bbb2ef33a8344ce.js">
3030

3131
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
3232
<script src="../_static/jquery.js"></script>
@@ -39,7 +39,10 @@
3939
<link rel="search" title="Search" href="../search.html" />
4040

4141
<meta name="viewport" content="width=device-width, initial-scale=1" />
42-
<meta name="docsearch:language" content="en" />
42+
<meta name="docsearch:language" content="None">
43+
44+
45+
<!-- Google Analytics -->
4346

4447
<link rel="stylesheet" href="_static/basic.css" type="text/css" />
4548

@@ -55,7 +58,7 @@
5558
<div id="navbar-start">
5659

5760
<!-- This will display the version of the docs -->
58-
<a class='navbar-brand' href='index.html'>CmdStanPy 0.9.77</a>
61+
<a class='navbar-brand' href='index.html'>CmdStanPy 1.0.0rc1</a>
5962

6063
</div>
6164

@@ -173,31 +176,29 @@ <h1>All modules for which code is available</h1>
173176
</div>
174177

175178

176-
<div class='prev-next-bottom'>
177-
178-
179-
</div>
179+
<!-- Previous / next buttons -->
180+
<div class='prev-next-area'>
181+
</div>
180182

181183
</main>
182184

183185

184186
</div>
185187
</div>
186188

187-
<script src="../_static/js/index.1c5a1a01449ed65a7b51.js"></script>
188-
189-
<footer class="footer mt-5 mt-md-0">
189+
<script src="../_static/js/index.be7d3bbb2ef33a8344ce.js"></script>
190+
<footer class="footer mt-5 mt-md-0">
190191
<div class="container">
191192

192193
<div class="footer-item">
193194
<p class="copyright">
194-
&copy; Copyright 2021, Stan Development Team.<br/>
195+
&copy; Copyright 2021, Stan Development Team.<br>
195196
</p>
196197
</div>
197198

198199
<div class="footer-item">
199200
<p class="sphinx-version">
200-
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.1.2.<br/>
201+
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.2.0.<br>
201202
</p>
202203
</div>
203204

docs/_sources/examples.rst.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ __________________
77
examples/MCMC Sampling.ipynb
88
examples/Maximum Likelihood Estimation.ipynb
99
examples/Variational Inference.ipynb
10+
examples/VI as Sampler Inits.ipynb
1011
examples/Run Generated Quantities.ipynb
12+
examples/Using External C++.ipynb
13+

docs/_sources/examples/MCMC Sampling.ipynb.txt

Lines changed: 96 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,40 @@
2424
"processor cores available."
2525
]
2626
},
27+
{
28+
"cell_type": "markdown",
29+
"metadata": {},
30+
"source": [
31+
"## Prerequisites\n",
32+
"\n",
33+
"\n",
34+
"CmdStanPy displays progress bars during sampling via use of package [tqdm](https://github.com/tqdm/tqdm).\n",
35+
"In order for these to display properly, you must have the \n",
36+
"[ipywidgets](https://ipywidgets.readthedocs.io/en/latest/index.html) package installed,\n",
37+
"and depending on your version of Jupyter or JupyterLab, you must enable it via command:"
38+
]
39+
},
40+
{
41+
"cell_type": "code",
42+
"execution_count": null,
43+
"metadata": {},
44+
"outputs": [],
45+
"source": [
46+
"!jupyter nbextension enable --py widgetsnbextension"
47+
]
48+
},
49+
{
50+
"cell_type": "markdown",
51+
"metadata": {},
52+
"source": [
53+
"For more information, see the the\n",
54+
"[installation instructions](https://ipywidgets.readthedocs.io/en/latest/user_install.html#), \n",
55+
"also [this tqdm GitHub issue](https://github.com/tqdm/tqdm/issues/394#issuecomment-384743637).\n",
56+
"\n",
57+
"\n",
58+
" "
59+
]
60+
},
2761
{
2862
"cell_type": "markdown",
2963
"metadata": {},
@@ -45,15 +79,14 @@
4579
"outputs": [],
4680
"source": [
4781
"import os\n",
48-
"from cmdstanpy.model import CmdStanModel\n",
49-
"from cmdstanpy.utils import cmdstan_path\n",
82+
"from cmdstanpy import CmdStanModel, cmdstan_path\n",
5083
" \n",
5184
"bernoulli_dir = os.path.join(cmdstan_path(), 'examples', 'bernoulli')\n",
52-
"bernoulli_path = os.path.join(bernoulli_dir, 'bernoulli.stan')\n",
53-
"bernoulli_data = os.path.join(bernoulli_dir, 'bernoulli.data.json')\n",
85+
"stan_file = os.path.join(bernoulli_dir, 'bernoulli.stan')\n",
86+
"data_file = os.path.join(bernoulli_dir, 'bernoulli.data.json')\n",
5487
"\n",
5588
"# instantiate, compile bernoulli model\n",
56-
"bernoulli_model = CmdStanModel(stan_file=bernoulli_path)"
89+
"model = CmdStanModel(stan_file=stan_file)"
5790
]
5891
},
5992
{
@@ -72,7 +105,7 @@
72105
"outputs": [],
73106
"source": [
74107
"# run CmdStan's sample method, returns object `CmdStanMCMC`\n",
75-
"bern_fit = bernoulli_model.sample(data=bernoulli_data)"
108+
"fit = model.sample(data=data_file)"
76109
]
77110
},
78111
{
@@ -91,8 +124,8 @@
91124
"metadata": {},
92125
"outputs": [],
93126
"source": [
94-
"print('sampler diagnostic variables:\\n{}'.format(bern_fit.metadata.method_vars_cols.keys()))\n",
95-
"print('stan model variables:\\n{}'.format(bern_fit.metadata.stan_vars_cols.keys()))"
127+
"print('sampler diagnostic variables:\\n{}'.format(fit.metadata.method_vars_cols.keys()))\n",
128+
"print('stan model variables:\\n{}'.format(fit.metadata.stan_vars_cols.keys()))"
96129
]
97130
},
98131
{
@@ -101,7 +134,7 @@
101134
"metadata": {},
102135
"outputs": [],
103136
"source": [
104-
"bern_fit.summary()"
137+
"fit.summary()"
105138
]
106139
},
107140
{
@@ -117,8 +150,8 @@
117150
"metadata": {},
118151
"outputs": [],
119152
"source": [
120-
"print(bern_fit.draws().shape)\n",
121-
"bern_fit.draws_pd().head()"
153+
"print(fit.draws().shape)\n",
154+
"fit.draws_pd().head()"
122155
]
123156
},
124157
{
@@ -134,14 +167,14 @@
134167
"metadata": {},
135168
"outputs": [],
136169
"source": [
137-
"bern_fit.draws_xr()"
170+
"fit.draws_xr()"
138171
]
139172
},
140173
{
141174
"cell_type": "markdown",
142175
"metadata": {},
143176
"source": [
144-
"The ``bern_fit`` object records the command, the return code,\n",
177+
"The ``fit`` object records the command, the return code,\n",
145178
"and the paths to the sampler output csv and console files.\n",
146179
"The string representation of this object displays the CmdStan commands and\n",
147180
"the location of the output files.\n",
@@ -160,7 +193,7 @@
160193
"metadata": {},
161194
"outputs": [],
162195
"source": [
163-
"bern_fit"
196+
"fit"
164197
]
165198
},
166199
{
@@ -178,10 +211,52 @@
178211
"cell_type": "markdown",
179212
"metadata": {},
180213
"source": [
181-
"## Running a data-generating model using `fixed_param=True`\n",
214+
"### Sampler Progress\n",
215+
"\n",
216+
"Your model make take a long time to fit. The `sample` method provides two arguments:\n",
217+
" \n",
218+
"- visual progress bar: `show_progress=True`\n",
219+
"- stream CmdStan ouput to the console - `show_console=True`\n",
220+
" \n",
221+
"To illustrate how progress bars work, we will run the bernoulli model. Since the progress bars are only visible while the sampler is running and the bernoulli model takes no time at all to fit, we run this model for 200K iterations, in order to see the progress bars in action."
222+
]
223+
},
224+
{
225+
"cell_type": "code",
226+
"execution_count": null,
227+
"metadata": {},
228+
"outputs": [],
229+
"source": [
230+
"fit = model.sample(data=data_file, iter_warmup=100000, iter_sampling=100000, show_progress=True)\n"
231+
]
232+
},
233+
{
234+
"cell_type": "markdown",
235+
"metadata": {},
236+
"source": [
237+
"The Stan language `print` statement can be use to monitor the Stan program state.\n",
238+
"In order to see this information as the sampler is running, use the `show_console=True` argument.\n",
239+
"This will stream all CmdStan messages to the terminal while the sampler is running.\n"
240+
]
241+
},
242+
{
243+
"cell_type": "code",
244+
"execution_count": null,
245+
"metadata": {},
246+
"outputs": [],
247+
"source": [
248+
"fit = model.sample(data=data_file, chains=2, parallel_chains=1, show_console=True)\n",
249+
"\n"
250+
]
251+
},
252+
{
253+
"cell_type": "markdown",
254+
"metadata": {},
255+
"source": [
256+
"## Running a data-generating model\n",
182257
"\n",
183258
"In this example we use the CmdStan example model\n",
184-
"[bernoulli_datagen.stan](https://github.com/stan-dev/cmdstanpy/blob/master/docs/notebooks/bernoulli_datagen.stan)\n",
259+
"[data_filegen.stan](https://github.com/stan-dev/cmdstanpy/blob/master/docs/notebooks/data_filegen.stan)\n",
185260
"to generate a simulated dataset given fixed data values."
186261
]
187262
},
@@ -191,10 +266,10 @@
191266
"metadata": {},
192267
"outputs": [],
193268
"source": [
194-
"datagen_model = CmdStanModel(stan_file='bernoulli_datagen.stan')\n",
269+
"model_datagen = CmdStanModel(stan_file='bernoulli_datagen.stan')\n",
195270
"datagen_data = {'N':300, 'theta':0.3}\n",
196-
"sim_data = datagen_model.sample(data=datagen_data, fixed_param=True)\n",
197-
"sim_data.summary()"
271+
"fit_sim = model_datagen.sample(data=datagen_data, fixed_param=True)\n",
272+
"fit_sim.summary()"
198273
]
199274
},
200275
{
@@ -210,7 +285,7 @@
210285
"metadata": {},
211286
"outputs": [],
212287
"source": [
213-
"drawset_pd = sim_data.draws_pd()\n",
288+
"drawset_pd = fit_sim.draws_pd()\n",
214289
"drawset_pd.columns\n",
215290
"\n",
216291
"# restrict to columns over new outcomes of N Bernoulli trials\n",
@@ -238,7 +313,7 @@
238313
"name": "python",
239314
"nbconvert_exporter": "python",
240315
"pygments_lexer": "ipython3",
241-
"version": "3.9.5"
316+
"version": "3.8.5"
242317
}
243318
},
244319
"nbformat": 4,

docs/_sources/examples/Maximum Likelihood Estimation.ipynb.txt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5-
"metadata": {},
65
"source": [
76
"# Maximum Likelihood Estimation\n",
87
"\n",
@@ -11,11 +10,11 @@
1110
"a Newton optimizer, and two related quasi-Newton algorithms, BFGS and L-BFGS.\n",
1211
"The L-BFGS algorithm is the default optimizer.\n",
1312
"Newton’s method is the least efficient of the three, but has the advantage of setting its own stepsize."
14-
]
13+
],
14+
"metadata": {}
1515
},
1616
{
1717
"cell_type": "markdown",
18-
"metadata": {},
1918
"source": [
2019
"In this example we use the CmdStan example model\n",
2120
"[bernoulli.stan](https://github.com/stan-dev/cmdstanpy/blob/master/test/data/bernoulli.stan)\n",
@@ -32,30 +31,31 @@
3231
"- `optimized_params_pd`\n",
3332
"\n",
3433
"In the following example, we instantiate a model and do optimization using the default CmdStan settings:"
35-
]
34+
],
35+
"metadata": {}
3636
},
3737
{
3838
"cell_type": "code",
3939
"execution_count": null,
40-
"metadata": {},
41-
"outputs": [],
4240
"source": [
4341
"import os\n",
4442
"from cmdstanpy import CmdStanModel, cmdstan_path\n",
4543
" \n",
4644
"bernoulli_dir = os.path.join(cmdstan_path(), 'examples', 'bernoulli')\n",
47-
"bernoulli_path = os.path.join(bernoulli_dir, 'bernoulli.stan')\n",
48-
"bernoulli_data = os.path.join(bernoulli_dir, 'bernoulli.data.json')\n",
45+
"stan_file = os.path.join(bernoulli_dir, 'bernoulli.stan')\n",
46+
"data_file = os.path.join(bernoulli_dir, 'bernoulli.data.json')\n",
4947
"\n",
5048
"# instantiate, compile bernoulli model\n",
51-
"bernoulli_model = CmdStanModel(stan_file=bernoulli_path)\n",
49+
"model = CmdStanModel(stan_file=stan_file)\n",
5250
"\n",
5351
"# run CmdStan's otpimize method, returns object `CmdStanMLE`\n",
54-
"mle = bernoulli_model.optimize(data=bernoulli_data)\n",
52+
"mle = model.optimize(data=data_file)\n",
5553
"print(mle.column_names)\n",
5654
"print(mle.optimized_params_dict)\n",
5755
"mle.optimized_params_pd"
58-
]
56+
],
57+
"outputs": [],
58+
"metadata": {}
5959
}
6060
],
6161
"metadata": {
@@ -79,4 +79,4 @@
7979
},
8080
"nbformat": 4,
8181
"nbformat_minor": 4
82-
}
82+
}

0 commit comments

Comments
 (0)