cuthbert 0.1.2__tar.gz → 0.1.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cuthbert-0.1.2 → cuthbert-0.1.3}/PKG-INFO +1 -1
- cuthbert-0.1.3/README.md +131 -0
- cuthbert-0.1.3/hatch_build.py +35 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/pyproject.toml +4 -6
- cuthbert-0.1.2/README.md +0 -1
- {cuthbert-0.1.2 → cuthbert-0.1.3}/.gitignore +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/README.md +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/__init__.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/discrete/README.md +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/discrete/__init__.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/discrete/filter.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/discrete/smoother.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/discrete/types.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/ensemble_kalman/README.md +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/ensemble_kalman/__init__.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/ensemble_kalman/ensemble_kalman_filter.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/ensemble_kalman/ensemble_rts_smoother.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/ensemble_kalman/types.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/factorial/README.md +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/factorial/__init__.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/factorial/discrete.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/factorial/filtering.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/factorial/gaussian.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/factorial/smc.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/factorial/types.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/factorial/utils.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/filtering.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/gaussian/README.md +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/gaussian/__init__.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/gaussian/kalman.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/gaussian/moments/__init__.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/gaussian/moments/associative_filter.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/gaussian/moments/filter.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/gaussian/moments/non_associative_filter.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/gaussian/moments/smoother.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/gaussian/moments/types.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/gaussian/taylor/__init__.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/gaussian/taylor/associative_filter.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/gaussian/taylor/filter.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/gaussian/taylor/non_associative_filter.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/gaussian/taylor/smoother.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/gaussian/taylor/types.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/gaussian/types.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/gaussian/utils.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/inference.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/smc/README.md +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/smc/__init__.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/smc/backward_sampler.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/smc/marginal_particle_filter.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/smc/particle_filter.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/smc/types.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/smoothing.py +0 -0
- {cuthbert-0.1.2 → cuthbert-0.1.3}/cuthbert/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: cuthbert
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: State-space model inference with JAX
|
|
5
5
|
Author-email: Sam Duffield <s@mduffield.com>, Sahel Iqbal <sahel13miqbal@proton.me>, Adrien Corenflos <adrien.corenflos.stats@gmail.com>
|
|
6
6
|
License: Apache-2.0
|
cuthbert-0.1.3/README.md
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
<!-- --8<-- [start:intro] -->
|
|
2
|
+
<div align="center">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/state-space-models/cuthbert/main/docs/assets/cuthbert.png" alt="cuthbert logo"></img>
|
|
4
|
+
</div>
|
|
5
|
+
|
|
6
|
+
A JAX library for state-space model inference
|
|
7
|
+
(filtering, smoothing, static parameter estimation).
|
|
8
|
+
|
|
9
|
+
> Disclaimer: The name `cuthbert` was chosen as a playful nod to the well-known
|
|
10
|
+
> caterpillar cake rivalry between Aldi and M&S in the UK, as the classic state-space
|
|
11
|
+
> model diagram looks vaguely like a caterpillar. However, this software project
|
|
12
|
+
> has no formal connection to Aldi, M&S, or any food products (notwithstanding the coffee drunk during its writeup).
|
|
13
|
+
> `cuthbert` is simply a fun name for this state-space model library and should not be interpreted as an
|
|
14
|
+
> endorsement, association, or affiliation with any brand or animal themed baked goods.
|
|
15
|
+
|
|
16
|
+
[](https://discord.gg/W9BA4Aj7Rx)
|
|
17
|
+
[](https://github.com/state-space-models/cuthbert)
|
|
18
|
+
[](https://pypi.org/project/cuthbert/)
|
|
19
|
+
[](https://state-space-models.github.io/cuthbert/)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
If you want to jump right in, check out our [examples](https://state-space-models.github.io/cuthbert/examples).
|
|
23
|
+
Maybe a [simple Kalman filter for tracking](https://state-space-models.github.io/cuthbert/examples/kalman_tracking)
|
|
24
|
+
or a [factorial state-space model for modelling international football](https://state-space-models.github.io/cuthbert/examples/factorial_football).
|
|
25
|
+
<!-- --8<-- [end:intro] -->
|
|
26
|
+
|
|
27
|
+
<!-- --8<-- [start:goals] -->
|
|
28
|
+
### Goals
|
|
29
|
+
- Simple, flexible and performant interface for state-space model inference.
|
|
30
|
+
- Decoupling of model specification and inference. `cuthbert` is built to swap between
|
|
31
|
+
different **inference** methods without be tied to a specific model specification.
|
|
32
|
+
- Compose with the [JAX ecosystem](#ecosystem) for extensive external tools.
|
|
33
|
+
- Functional API: The only classes in `cuthbert` are `NamedTuple`s and `Protocol`s.
|
|
34
|
+
All functions are pure and work seamlessly with `jax.grad`, `jax.jit`, `jax.vmap` etc.
|
|
35
|
+
- Methods for filtering: $p(x_t \mid y_{1:t}, \theta)$.
|
|
36
|
+
- Methods for smoothing: $p(x_{0:T} \mid y_{1:T}, \theta)$ or $p(x_{t} \mid y_{1:T}, \theta)$.
|
|
37
|
+
- Methods for static parameter estimation: $p(\theta \mid y_{1:T})$
|
|
38
|
+
or $\text{argmax} p(y_{1:T} \mid \theta)$.
|
|
39
|
+
- This includes support for forward-backward/Baum-Welch, particle filtering/sequential Monte Carlo,
|
|
40
|
+
Kalman filtering (+ extended/unscented/ensemble), expectation-maximization and more!
|
|
41
|
+
|
|
42
|
+
### Non-goals
|
|
43
|
+
- Tools for defining models and distributions. `cuthbert` is not a probabilistic programming language (PPL).
|
|
44
|
+
But can easily compose with [`dynamax`](https://github.com/probml/dynamax), [`distrax`](https://github.com/google-deepmind/distrax), [`numpyro`](https://github.com/pyro-ppl/numpyro) and [`pymc`](https://github.com/pymc-devs/pymc) in a similar way to how [`blackjax` does](https://blackjax-devs.github.io/blackjax/).
|
|
45
|
+
- ["SMC Samplers"](https://www.stats.ox.ac.uk/~doucet/delmoral_doucet_jasra_sequentialmontecarlosamplersJRSSB.pdf) which sample from a posterior
|
|
46
|
+
distribution which is not (necessarily) a state-space model - [`blackjax` is great for this](https://github.com/blackjax-devs/blackjax/tree/main/blackjax/smc).
|
|
47
|
+
<!-- --8<-- [end:goals] -->
|
|
48
|
+
|
|
49
|
+
<!-- --8<-- [start:codebase_structure] -->
|
|
50
|
+
### Codebase structure
|
|
51
|
+
|
|
52
|
+
The codebase is structured as follows:
|
|
53
|
+
|
|
54
|
+
- `cuthbert`: The main package with unified interface for filtering and smoothing.
|
|
55
|
+
- `cuthbertlib`: A collection of atomic, smaller-scoped tools useful for state-space model inference,
|
|
56
|
+
that represent the building blocks that power the main `cuthbert` package.
|
|
57
|
+
<!-- --8<-- [end:codebase_structure] -->
|
|
58
|
+
- `docs`: Source code for the documentation for `cuthbert` and `cuthbertlib`.
|
|
59
|
+
- `pkg`: Packaging configuration for publishing `cuthbert` and `cuthbertlib` to PyPI.
|
|
60
|
+
- `tests`: Tests for the `cuthbert` and `cuthbertlib` packages.
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
<!-- --8<-- [start:installation] -->
|
|
64
|
+
## Installation
|
|
65
|
+
|
|
66
|
+
`cuthbert` depends on JAX, so you'll need to [install JAX](https://docs.jax.dev/en/latest/installation.html) for the available hardware (CPU, GPU, or TPU).
|
|
67
|
+
For example, on computers with NVIDIA GPUs:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pip install -U "jax[cuda13]"
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### From PyPI
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
pip install -U cuthbert
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Installing `cuthbert` will also install `cuthbertlib`.
|
|
80
|
+
You can also install `cuthbertlib` on its own:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
pip install -U cuthbertlib
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Local development (uv)
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
git clone https://github.com/state-space-models/cuthbert.git
|
|
90
|
+
cd cuthbert
|
|
91
|
+
uv sync --package cuthbert --extra tests
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Local development (pip)
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
git clone https://github.com/state-space-models/cuthbert.git
|
|
98
|
+
cd cuthbert
|
|
99
|
+
pip install -e ./pkg/cuthbertlib
|
|
100
|
+
pip install -e "./pkg/cuthbert[tests]"
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
<!-- --8<-- [end:installation] -->
|
|
104
|
+
|
|
105
|
+
<!-- --8<-- [start:ecosystem] -->
|
|
106
|
+
## Ecosystem
|
|
107
|
+
- `cuthbert` is built on top of [`jax`](https://github.com/google/jax) and composes
|
|
108
|
+
easily with other JAX packages, e.g. [`optax`](https://github.com/google-deepmind/optax)
|
|
109
|
+
for optimization, [`flax`](https://github.com/google/flax) for neural networks, and
|
|
110
|
+
[`blackjax`](https://github.com/blackjax-devs/blackjax) for (SG)MCMC as well as the PPLs
|
|
111
|
+
mentioned [above](#non-goals).
|
|
112
|
+
- What about [`dynamax`](https://github.com/probml/dynamax)?
|
|
113
|
+
- `dynamax` is a great library for state-space model specification and inference with
|
|
114
|
+
discrete or Gaussian state-space models. `cuthbert` is focused on inference
|
|
115
|
+
with arbitrary state-space models via e.g. SMC that is not supported in `dynamax`.
|
|
116
|
+
However as they are both built on [`jax`](https://github.com/google/jax)
|
|
117
|
+
they can be used together! A `dynamax`
|
|
118
|
+
model can be passed to `cuthbert` for inference.
|
|
119
|
+
- And [`particles`](https://github.com/nchopin/particles)?
|
|
120
|
+
- [`particles`](https://github.com/nchopin/particles) and the accompanying book
|
|
121
|
+
[Sequential Monte Carlo Methods in Practice](https://link.springer.com/book/10.1007/978-3-030-47845-2)
|
|
122
|
+
are wonderful learning materials for state-space models and SMC.
|
|
123
|
+
`cuthbert` is more focused on performance and composability with the JAX ecosystem.
|
|
124
|
+
- Much of the code in `cuthbert` is built on work from [`sqrt-parallel-smoothers`](https://github.com/EEA-sensors/sqrt-parallel-smoothers), [`mocat`](https://github.com/SamDuffield/mocat) and [`abile`](https://github.com/SamDuffield/abile).
|
|
125
|
+
<!-- --8<-- [end:ecosystem] -->
|
|
126
|
+
|
|
127
|
+
## Contributing
|
|
128
|
+
|
|
129
|
+
We're always looking for contributions!
|
|
130
|
+
Check out the [contributing guide](CONTRIBUTING.md) for more information.
|
|
131
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""Hatch build hook that packages the top-level `cuthbert` source dir."""
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class CustomBuildHook(BuildHookInterface):
|
|
9
|
+
"""Include the source package in wheels and resolve the README symlink in sdists."""
|
|
10
|
+
|
|
11
|
+
def initialize(self, version, build_data):
|
|
12
|
+
"""Adjust the files of the artifact being built."""
|
|
13
|
+
force_include = build_data["force_include"]
|
|
14
|
+
if self.target_name == "sdist":
|
|
15
|
+
# An sdist stores symlinks as links, and the README link points
|
|
16
|
+
# outside the archive, so ship the file it points at instead.
|
|
17
|
+
for source in [s for s in force_include if Path(s).is_symlink()]:
|
|
18
|
+
target = Path(source).resolve()
|
|
19
|
+
if not target.exists():
|
|
20
|
+
raise RuntimeError(f"Symlink {source} points at missing {target}")
|
|
21
|
+
force_include[str(target)] = force_include.pop(source)
|
|
22
|
+
return
|
|
23
|
+
# Editable installs reach the source through a .pth file (dev-mode-dirs);
|
|
24
|
+
# a copy in site-packages would shadow the working tree.
|
|
25
|
+
if self.target_name != "wheel" or version == "editable":
|
|
26
|
+
return
|
|
27
|
+
# A wheel built from the sdist: the sdist already holds the package.
|
|
28
|
+
if Path(self.root, "PKG-INFO").is_file():
|
|
29
|
+
return
|
|
30
|
+
# A wheel built from the workspace: the source sits two levels up.
|
|
31
|
+
name = self.metadata.name
|
|
32
|
+
source = Path(self.root, "..", "..", name)
|
|
33
|
+
if not source.is_dir():
|
|
34
|
+
raise RuntimeError(f"Cannot find the {name} source dir at {source}")
|
|
35
|
+
force_include[str(source)] = name
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
[build-system]
|
|
2
|
-
requires = ["hatchling"]
|
|
2
|
+
requires = ["hatchling>=1.19"]
|
|
3
3
|
build-backend = "hatchling.build"
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "cuthbert"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.3"
|
|
8
8
|
description = "State-space model inference with JAX"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -37,12 +37,10 @@ cuthbertlib = { workspace = true }
|
|
|
37
37
|
[tool.hatch.build]
|
|
38
38
|
dev-mode-dirs = ["../.."]
|
|
39
39
|
|
|
40
|
+
[tool.hatch.build.hooks.custom]
|
|
41
|
+
|
|
40
42
|
[tool.hatch.build.targets.wheel]
|
|
41
43
|
packages = ["cuthbert"]
|
|
42
44
|
|
|
43
|
-
[tool.hatch.build.targets.wheel.force-include]
|
|
44
|
-
"../../cuthbert" = "cuthbert"
|
|
45
|
-
|
|
46
45
|
[tool.hatch.build.targets.sdist.force-include]
|
|
47
46
|
"../../cuthbert" = "cuthbert"
|
|
48
|
-
"../../README.md" = "README.md"
|
cuthbert-0.1.2/README.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
../../README.md
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|