Skip to content

Commit 5a115f0

Browse files
Fixing: Doc Warnings (#483)
* Dealing indentation problems (and probably others), 268~ left * Critical error fixed. 267~ left * Fixing files with 2 possible references (cross-reference). 204~ warnings left * Fixin glossary problems (and others). ~153 warnings left * Fixing Unknown interpreted text error. 151~ warnings left * fixing cross-reference target not found like. 124~ warnings left * fixing local id not found like. 104~ warnings left * fixing duplicate citation like. ~60 warnings left... * solving various. 48~ left * fixing various. 42~ left * All warnings fixed, of which some are just hiden in conf.py because they can not be fixed, its normal to have them or are not related to the documentations build
1 parent 13667bf commit 5a115f0

Some content is hidden

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

66 files changed

+581
-617
lines changed

docs/algorithms.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
# Algorithms
22

3+
(fit)=
34
## Fit
45

5-
In this section we describe how to fit a `leaspy` model with your data. Leaspy uses the [MCMC-SAEM algorithm](./glossary.md#mcmc-saem) to fit a model by jointly estimating the fixed effects and the distribution of the random effects. It is particularly well suited to this kind of models where the likelihood involves latent variables and is not available in closed form.
6+
In this section we describe how to fit a `leaspy` model with your data. Leaspy uses the {term}`MCMC-SAEM algorithm <MCMC-SAEM>` to fit a model by jointly estimating the fixed effects and the distribution of the random effects. It is particularly well suited to this kind of models where the likelihood involves latent variables and is not available in closed form.
67

78
The algorithm is an adaptation of the Expectation-Maximisation (EM) algorithm that relies on an iterative procedure that alternates between the following main steps:
89

9-
- Expectation/Stochastic Approximation Step: the algorithm uses [Markov Chain Monte Carlo (MCMC)](./glossary.md#mcmc) to generate samples of the latent variables (random effects) conditional on the current parameter estimates. In particular, Gibbs sampling is employed, which iteratively updates each latent variable conditional on the current values of the others, allowing efficient exploration of the latent space. To avoid convergence to local maxima, a temperature scheme is applied: the sampling distribution is initially “flattened” during the burn-in phase, to allow exploration of a wider range of values, and the temperature is gradually reduced over iterations so that the chain focuses increasingly on high-likelihood regions. The sufficient statistics of the complete-data log-likelihood are then computed using a stochastic approximation scheme.
10+
- Expectation/Stochastic Approximation Step: the algorithm uses {term}`Markov Chain Monte Carlo (MCMC) <MCMC>` to generate samples of the latent variables (random effects) conditional on the current parameter estimates. In particular, Gibbs sampling is employed, which iteratively updates each latent variable conditional on the current values of the others, allowing efficient exploration of the latent space. To avoid convergence to local maxima, a temperature scheme is applied: the sampling distribution is initially “flattened” during the burn-in phase, to allow exploration of a wider range of values, and the temperature is gradually reduced over iterations so that the chain focuses increasingly on high-likelihood regions. The sufficient statistics of the complete-data log-likelihood are then computed using a stochastic approximation scheme.
1011
- Maximization Step: Given the updated sufficient statistics, the fixed effects and variance components are re-estimated by maximizing the approximate complete-data log-likelihood.
1112

1213
By iterating these steps, the MCMC-SAEM algorithm converges to the maximum likelihood estimates of the model parameters.
1314

15+
(prerequisites)=
1416
### Prerequisites
1517

16-
Depending on the model you want to fit, you need a dataframe with a specific structure (see [logistic](./models.md#logistic-data), [joint](./models.md#joint-data), and [mixture](./models.md#mixture-data) models).
18+
Depending on the model you want to fit, you need a dataframe with a specific structure (see [logistic](logistic-data), [joint](joint-data), and [mixture](mixture-data) models).
1719

1820
### Running Task
1921

@@ -25,7 +27,7 @@ Let's use the logistic model as an example.
2527
from leaspy.models import LogisticModel
2628
```
2729

28-
We need to specify the arguments `name`, `dimension` (the number of outcomes $K$ in your dataset) and the `obs_models` (valid choices for the logistic model are 'gaussian-diagonal' to estimate one noise coefficient per outcome or 'gaussian-scalar' to estimate one noise coefficient for all the outcomes). When we fit a multivariate model we also need to specify `source_dimension` that corresponds to the degrees of freedom of intermarker spacing parameters. We refer you to the [mathematical background section](./mathematics.md#individual-trajectory--spatial-random-effects) for more details. We generally suggest a number of sources close to the square root of the number of outcomes ($\sqrt{dimension}$).
30+
We need to specify the arguments `name`, `dimension` (the number of outcomes $K$ in your dataset) and the `obs_models` (valid choices for the logistic model are 'gaussian-diagonal' to estimate one noise coefficient per outcome or 'gaussian-scalar' to estimate one noise coefficient for all the outcomes). When we fit a multivariate model we also need to specify `source_dimension` that corresponds to the degrees of freedom of intermarker spacing parameters. We refer you to the [mathematical background section](individual-trajectory-spatial-random-effects) for more details. We generally suggest a number of sources close to the square root of the number of outcomes ($\sqrt{dimension}$).
2931

3032
You can also add a `seed` or control other arguments for the output and the logs like `save_periodicity`, `path`, etc.
3133

@@ -34,7 +36,7 @@ model = LogisticModel(name="my-model", source_dimension=1, dimension=2, obs_mode
3436
model.fit(data_leaspy, "mcmc_saem", n_iter=20000, seed=42)
3537
```
3638

37-
Note that the joint and mixture models require additional model-specific arguments. Please refer to their respective documentation for details: [joint model](./models.md#model-summary) and [mixture model](./models.md#id20).
39+
Note that the joint and mixture models require additional model-specific arguments. Please refer to their respective documentation for details: [joint model](joint-model-summary) and [mixture model](mixture-model-summary).
3840

3941
### Output
4042

@@ -93,7 +95,7 @@ GS-200 1.152407 -0.171888 76.504517 0.770118
9395
[200 rows x 4 columns]
9496
```
9597

96-
- __More of a bayesian one:__ random effects are estimated using a Gibbs sampler with an option on the burn-in phase and temperature scheme (see [fit description](##Fit)). Currently, the package enables to extract the mean or the mode of the posterior distribution. They can be used with the same procedure using `mean_posterior` or `mode_posterior` flag.
98+
- __More of a bayesian one:__ random effects are estimated using a Gibbs sampler with an option on the burn-in phase and temperature scheme (see [fit description](#fit)). Currently, the package enables to extract the mean or the mode of the posterior distribution. They can be used with the same procedure using `mean_posterior` or `mode_posterior` flag.
9799

98100
```python
99101
>>> personalize_settings = AlgorithmSettings("mean_posterior", seed=0)
@@ -246,9 +248,3 @@ Refer to the docstring for further details.
246248
- not enough patients
247249
- parameters don't converge
248250
- score don't progress -->
249-
250-
## References
251-
252-
```{bibliography}
253-
:filter: docname in docnames
254-
```

docs/conf.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,23 @@ def find_var(varname: str, *py_file_paths):
124124
# List of patterns, relative to source directory, that match files and
125125
# directories to ignore when looking for source files.
126126
# This pattern also affects html_static_path and html_extra_path.
127-
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
127+
128+
exclude_patterns = [
129+
"_build",
130+
"Thumbs.db",
131+
".DS_Store",
132+
"auto_examples/*.py",
133+
"auto_examples/*.ipynb",
134+
"auto_examples/*.py.md5",
135+
"auto_examples/*.codeobj.json",
136+
]
137+
138+
show_warning_types = True
139+
140+
suppress_warnings = [
141+
"config.cache", # sphinx_gallery_conf unpicklable
142+
# "autoapi", # only if you decide to silence AutoAPI warnings too
143+
]
128144

129145
# The name of the Pygments (syntax highlighting) style to use.
130146
highlight_language = "python3"
@@ -158,15 +174,8 @@ def find_var(varname: str, *py_file_paths):
158174
# further. For a list of options available for each theme, see the
159175
# documentation.
160176
html_theme_options = {
161-
"canonical_url": "",
162-
"analytics_id": "",
163-
"display_version": True,
164177
"collapse_navigation": True,
165-
"sticky_navigation": True,
166178
"navigation_depth": 4,
167-
"includehidden": True,
168-
"titles_only": False,
169-
"prev_next_buttons_location": None,
170179
# Logo and description
171180
# 'description': 'LEArning Spatiotemporal Patterns in Python',
172181
# 'logo_name': 'false',

0 commit comments

Comments
 (0)