Dividing data into linear segments.
Project description
nunchaku: Dividing data into linear segments
nunchaku
is a Python module for dividing data into linear segments.
It answers two questions:
- how many linear segments best fit the data without overfitting (by Bayesian model comparison);
- given the number of linear segments, where the boundaries between them are (by finding the posterior of the boundaries).
Installation
For users, type in terminal
> pip install nunchaku
For developers, create a virtual environment and then install with Poetry:
> git clone https://git.ecdf.ed.ac.uk/s1856140/nunchaku.git
> cd nunchaku
> poetry install --with dev
Quickstart
Data x
is a list or a 1D Numpy array, sorted ascendingly; the data y
is a list or a Numpy array, with each row being one replicate of measurement.
>>> from nunchaku.nunchaku import nunchaku, get_example_data
>>> x, y = get_example_data()
>>> nc = nunchaku(x, y, prior=[-5,5]) # load data and set prior of gradient
>>> # compare models with 1, 2, 3 and 4 linear segments
>>> numseg, evidences = nc.get_number(max_num=4)
>>> # get the mean and standard deviation of the boundary points
>>> bds, bds_std = nc.get_iboundaries(numseg)
>>> # get the information of all segments
>>> info_df = nc.get_info(bds)
>>> # plot the data and the segments
>>> nc.plot(info_df)
Documentation
Detailed documentation is available on Readthedocs.
Citation
A preprint is coming soon.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
nunchaku-0.10.0.tar.gz
(13.8 kB
view hashes)
Built Distribution
nunchaku-0.10.0-py3-none-any.whl
(14.5 kB
view hashes)
Close
Hashes for nunchaku-0.10.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2599127380c3a2b52cbb462cc2b97200fa65aa52e843f4d42d39b222746b9f88 |
|
MD5 | 5e66b366a492366165e985772188402b |
|
BLAKE2b-256 | a389574a24dc7ed0e38a1bbb2b3b5c5c7ca34e11973a7662b59f89de8405a7f3 |