Skip to main content

To find the linear segment of a curve or dataset.

Project description

nunchaku: Dividing data into linear regions

nunchaku is a Python module for dividing data into linear regions. It answers two questions:

  1. how many linear regions best fit the data without overfitting (by Bayesian model comparison);
  2. given the number of linear regions, 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 type

> 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 slope
>>> # compare models with one, two or three linear regions
>>> num_regions, evidences = nc.get_number([1,2,3])
>>> # get the mean and standard deviation of the boundary points
>>> bds, bds_std = nc.get_iboundaries(num_regions)
>>> info_df = nc.get_info(bds)
>>> nc.plot(info_df)

Documentation

Detailed documentation is available on Readthedocs.

Citation

A preprint is coming soon.

Project details


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.8.0.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nunchaku-0.8.0-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file nunchaku-0.8.0.tar.gz.

File metadata

  • Download URL: nunchaku-0.8.0.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.8.15 Linux/5.13.19-2-MANJARO

File hashes

Hashes for nunchaku-0.8.0.tar.gz
Algorithm Hash digest
SHA256 b6413b0cb84d619e3001fbbb2024b6ef0ca01e5f06c43a20ae94219c0a6b4513
MD5 089f1dd93c1c4c9d5de873e5827ba522
BLAKE2b-256 89f90d457f52e7312f50884bba65c472eb79a9f40093f57a2d1d7dbb80644c45

See more details on using hashes here.

File details

Details for the file nunchaku-0.8.0-py3-none-any.whl.

File metadata

  • Download URL: nunchaku-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.8.15 Linux/5.13.19-2-MANJARO

File hashes

Hashes for nunchaku-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 67ce9583e01f96a0c304e3bd5e05c3e78f2cad02964c25999ac8abbb27866cc9
MD5 71c99604be0de2806f1760739196a1a3
BLAKE2b-256 ab7bad7352b8ba873844b82cc9719bb7d160d2477fd7c1f29abf1e61fc9cf0c3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page