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.1.tar.gz
(641.3 kB
view details)
Built Distribution
File details
Details for the file linear_segment-1.2.1.tar.gz
.
File metadata
- Download URL: linear_segment-1.2.1.tar.gz
- Upload date:
- Size: 641.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.3 Darwin/23.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 596dda0deb2c69e57f0d22bfb4f0145709086cfdd4dcd6cef01360d76d71cc95 |
|
MD5 | 90f93a8d67381f9274cbbd5cda7c1ab3 |
|
BLAKE2b-256 | 2b5c5f79733fd34c4a868575e56d9874208dac8b702716b32cdfc6c3d9f38729 |
File details
Details for the file linear_segment-1.2.1-cp312-cp312-macosx_14_0_x86_64.whl
.
File metadata
- Download URL: linear_segment-1.2.1-cp312-cp312-macosx_14_0_x86_64.whl
- Upload date:
- Size: 911.7 kB
- Tags: CPython 3.12, macOS 14.0+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.3 Darwin/23.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8fb48f4084fe912648bcd9fcb16f0dab78450b146bc197b4ce18a144af358418 |
|
MD5 | 85fc8e80ca12968cb857b858c923a844 |
|
BLAKE2b-256 | 557d7b5eb34ae5e7ac7ee7da16be4e8ffedcc760bc10cb8c82243098b5cc53ce |