Package for automated signal segmentation, trend classification and analysis.
Project description
trend_classifier
Automated signal segmentation, trend classification and analysis.
Quick Start
from trend_classifier import Segmenter
seg = Segmenter(x=x_data, y=y_data, n=20)
seg.calculate_segments()
seg.plot_segments()
Installation
pip install trend-classifier
With optional dependencies:
pip install trend-classifier[pelt] # PELT algorithm (ruptures)
pip install trend-classifier[optimization] # Hyperparameter tuning (optuna)
pip install trend-classifier[all] # All extras
Features
-
Multiple detection algorithms:
sliding_window- Original algorithm, interpretable, good for most casesbottom_up- Merge-based, control exact segment countpelt- Optimal segmentation via ruptures library
-
Rich segment information: slope, offset, volatility, trend consistency
-
DataFrame export:
seg.segments.to_dataframe() -
Visualization:
plot_segments(),plot_segment() -
Configurable: Fine-tune sensitivity with
alpha,beta, window size
Example with Stock Data
import yfinance as yf
from trend_classifier import Segmenter
# Download data
df = yf.download("AAPL", start="2020-01-01", end="2023-01-01", progress=False)
# Segment and visualize
seg = Segmenter(df=df, column="Close", n=20)
seg.calculate_segments()
seg.plot_segments()
# Export to DataFrame
seg.segments.to_dataframe()
Using Different Detectors
from trend_classifier import Segmenter
# PELT algorithm (requires: pip install trend-classifier[pelt])
seg = Segmenter(x=x, y=y, detector="pelt", detector_params={"penalty": 10})
seg.calculate_segments()
# Bottom-up with target segment count
seg = Segmenter(x=x, y=y, detector="bottom_up", detector_params={"max_segments": 10})
seg.calculate_segments()
Segment Properties
Each segment contains:
| Property | Description |
|---|---|
start, stop |
Index range |
slope |
Trend direction and steepness |
std |
Volatility (after detrending) |
reason_for_new_segment |
Why segment boundary was placed |
segment = seg.segments[0]
print(f"Slope: {segment.slope:.4f}, Volatility: {segment.std:.4f}")
Documentation
Full documentation with tutorials and API reference:
https://izikeros.github.io/trend_classifier/
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file trend_classifier-0.3.1.tar.gz.
File metadata
- Download URL: trend_classifier-0.3.1.tar.gz
- Upload date:
- Size: 21.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3d4074f54fa86ab67429282a027f788e0eba02ba18cba7b898272eeb2a11ef6
|
|
| MD5 |
426d1c50da00500c24217857a4698f29
|
|
| BLAKE2b-256 |
373e4cdade251db80c5c6a39af5d696dbe790053d5363c9496d6b40800080421
|
File details
Details for the file trend_classifier-0.3.1-py3-none-any.whl.
File metadata
- Download URL: trend_classifier-0.3.1-py3-none-any.whl
- Upload date:
- Size: 23.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c120cd197d0d9cc2d4e7a706bc3c9b888c7265c0bff3193867cb7b2346d653c
|
|
| MD5 |
c8b02f9f6d395b9f3e92e772a3bf1694
|
|
| BLAKE2b-256 |
84d4d99a825ed1dd6c5e8749247f89e76e8ddf1abc62746bfc6ead50db08f391
|