Python package for Bayesian Change Point and Circular Binary Segmentation
Project description
Linear Segmentation
linear_segmentation using Bayesian Change Point Segmentation or Circular Binary segmentation.
Install
If you dont already have numpy and scipy installed, it is best to download
Anaconda
, a python distribution that has them included.
https://continuum.io/downloads
Dependencies can be installed by:
pip install -r requirements.txt
PyPI install, presuming you have all its requirements installed:
pip install linear_segment
Usage
from linear_segment import segment
import numpy as np
# Create data
np.random.seed(10)
T = 50
x = np.zeros(T)
x[10:20] = 1.0
x[30:40] = 1.0
labels = np.repeat("a", T) # "a" is a dummy label
# Calculate segments
segments = segment(x, labels, method="online_both", cutoff=0.3, offset=5)
print(segments)
LabeledIntervalArray
(0-10, a)
(10-20, a)
(20-30, a)
(30-40, a)
(40-50, a)
segments = segment(x, labels, method="cbs", shuffles=200, p=0.05)
print(segments)
LabeledIntervalArray
(0-10, a)
(10-20, a)
(20-30, a)
(30-40, a)
(40-50, a)
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
linear_segment-1.2.0.tar.gz
(272.5 kB
view hashes)
Built Distribution
Close
Hashes for linear_segment-1.2.0-cp311-cp311-macosx_14_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83df1e7d032c1871fb533f4d3b0db9cf116633d80ceb61953c8100bbd457cfe1 |
|
MD5 | 8916c5f827079342fb4275949fe6d43d |
|
BLAKE2b-256 | 351d15c56ac0306736a8cc59728034d0b7f0cabf60869d7f9a4b5ba92a0e0423 |