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)
Metadata
Release files for linear-segment 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| linear_segment-1.2.0.tar.gz | 272.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| linear_segment-1.2.0-cp311-cp311-macosx_14_0_x86_64.whl | CPython 3.11 | CPython 3.11 | macOS 14.0+ x86-64 | Details |
Total release size: 680.4 kB
Release files / linear_segment-1.2.0.tar.gz
| Download URL | linear_segment-1.2.0.tar.gz |
|---|---|
| Size | 272.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8f5d13251aafd5815d0b9910399dfdc61d39f678440e6892dd84eb56a6dad1bc
|
|
BLAKE2b-256 checksum How to use checksums |
f9fc9c16d6cf7fae002ac883735376c54598c4f4ab6625d7d1aabe2e7d302de8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.11.3 Darwin/23.5.0
|
Release files / linear_segment-1.2.0-cp311-cp311-macosx_14_0_x86_64.whl
| Download URL | linear_segment-1.2.0-cp311-cp311-macosx_14_0_x86_64.whl |
|---|---|
| Size | 407.8 kB |
| Tags | CPython 3.11 macOS 14.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
83df1e7d032c1871fb533f4d3b0db9cf116633d80ceb61953c8100bbd457cfe1
|
|
BLAKE2b-256 checksum How to use checksums |
351d15c56ac0306736a8cc59728034d0b7f0cabf60869d7f9a4b5ba92a0e0423
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.11.3 Darwin/23.5.0
|