Escalator
escalator is a small "change point detection" Python library allowing to detect stagnation in the values of a signal, sort of horizontal steps.
Unlike all the change point algorithms I found, this one doesn't try to to find the moment where the change happens, but search for when the stagnation periods start and end.
Inspired by the ruptures library.
Installation
pip install escalator-nyandams
Example
EscalatorRush parameters:
- cost: the cost function
- min_step_size: the minimal size of a step
- max_dist: distance at which we consider a point isn't in the current step
- jump: ignore some indexes during the fitting of the data, the highest, the more indexes you'll jump over. Improve the speed of execution but reduce the execution time.
- cache_size: number of elements in the step at which moment we decide to use a cached value of the mean of the step instead of the cost function. Improve a lot the performances. On the worst case with 50000 elements 129 seconds without cache, 0.8s with a simple cache of 100.
import step_detection as esc
signal: list = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 30, 31, 29, 30, 30, 29, 32, 45, 70, 70, 71, 69, 72, 70, 70, 70, 75, 78, 85, 85, 90, 95, 100, 100, 100, 101, 100, 101, 100, 100, 100, 99, 100, 100]
cost = esc.DistanceMedianCost()
algo = esc.EscalatorRush(cost=cost, min_step_size=3, max_dist=2, jump=1, cache_size=100).fit(signal)
stair_steps = algo.predict()
# [(0, 10, 0.0), (11, 18, 29.833333333333332), (19, 27, 70.28571428571429), (33, 45, 100.0909090909091)]
If steps are really close to each others, you can regroup them to have better results:
import step_detection as esc
...
stair_steps = esc.group_steps(steps=stair_steps, signal=signal, gap=2 , dist=1)
You can then plot easily the result with your favorite package.
Metadata
Release files for escalator-nyandams 0.0.13
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| escalator-nyandams-0.0.13.tar.gz | 373.7 kB | Details |
Release files / escalator-nyandams-0.0.13.tar.gz
| Download URL | escalator-nyandams-0.0.13.tar.gz |
|---|---|
| Size | 373.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
df379e83f1ec383eeb95d3a4382cd8fc640770346458670ef66878f86051842f
|
|
BLAKE2b-256 checksum How to use checksums |
c45fb8096751d527c848e0983e31971fa204ea49e8468471e8d4ca2b830caf48
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.4.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.7
|