pytrendy 1.2.0.dev1__tar.gz → 1.2.0.dev3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pytrendy-1.2.0.dev1 → pytrendy-1.2.0.dev3}/PKG-INFO +3 -4
- {pytrendy-1.2.0.dev1 → pytrendy-1.2.0.dev3}/README.md +2 -3
- {pytrendy-1.2.0.dev1 → pytrendy-1.2.0.dev3}/pyproject.toml +1 -1
- {pytrendy-1.2.0.dev1 → pytrendy-1.2.0.dev3}/pytrendy/detect_trends.py +15 -7
- {pytrendy-1.2.0.dev1 → pytrendy-1.2.0.dev3}/pytrendy/post_processing/segments_refine/__init__.py +1 -2
- {pytrendy-1.2.0.dev1 → pytrendy-1.2.0.dev3}/pytrendy/post_processing/segments_refine/abrupt_shaving.py +2 -3
- {pytrendy-1.2.0.dev1 → pytrendy-1.2.0.dev3}/pytrendy/post_processing/segments_refine/artifact_cleanup.py +1 -2
- {pytrendy-1.2.0.dev1 → pytrendy-1.2.0.dev3}/LICENSE +0 -0
- {pytrendy-1.2.0.dev1 → pytrendy-1.2.0.dev3}/pytrendy/__init__.py +0 -0
- {pytrendy-1.2.0.dev1 → pytrendy-1.2.0.dev3}/pytrendy/io/__init__.py +0 -0
- {pytrendy-1.2.0.dev1 → pytrendy-1.2.0.dev3}/pytrendy/io/data/classes_signals.csv +0 -0
- {pytrendy-1.2.0.dev1 → pytrendy-1.2.0.dev3}/pytrendy/io/data/series_synthetic.csv +0 -0
- {pytrendy-1.2.0.dev1 → pytrendy-1.2.0.dev3}/pytrendy/io/data_loader.py +0 -0
- {pytrendy-1.2.0.dev1 → pytrendy-1.2.0.dev3}/pytrendy/io/plot_pytrendy.py +0 -0
- {pytrendy-1.2.0.dev1 → pytrendy-1.2.0.dev3}/pytrendy/io/results_pytrendy.py +0 -0
- {pytrendy-1.2.0.dev1 → pytrendy-1.2.0.dev3}/pytrendy/post_processing/__init__.py +0 -0
- {pytrendy-1.2.0.dev1 → pytrendy-1.2.0.dev3}/pytrendy/post_processing/segments_analyse.py +0 -0
- {pytrendy-1.2.0.dev1 → pytrendy-1.2.0.dev3}/pytrendy/post_processing/segments_get.py +0 -0
- {pytrendy-1.2.0.dev1 → pytrendy-1.2.0.dev3}/pytrendy/post_processing/segments_refine/gradual_expand_contract.py +0 -0
- {pytrendy-1.2.0.dev1 → pytrendy-1.2.0.dev3}/pytrendy/post_processing/segments_refine/segment_grouping.py +0 -0
- {pytrendy-1.2.0.dev1 → pytrendy-1.2.0.dev3}/pytrendy/post_processing/segments_refine/trend_classify.py +0 -0
- {pytrendy-1.2.0.dev1 → pytrendy-1.2.0.dev3}/pytrendy/post_processing/segments_refine/update_neighbours.py +0 -0
- {pytrendy-1.2.0.dev1 → pytrendy-1.2.0.dev3}/pytrendy/process_signals.py +0 -0
- {pytrendy-1.2.0.dev1 → pytrendy-1.2.0.dev3}/pytrendy/simpledtw.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pytrendy
|
|
3
|
-
Version: 1.2.0.
|
|
3
|
+
Version: 1.2.0.dev3
|
|
4
4
|
Summary: Trend Detection in Python. Applicable for real-world industry use cases in time series.
|
|
5
5
|
License: MIT License
|
|
6
6
|
|
|
@@ -73,6 +73,8 @@ Description-Content-Type: text/markdown
|
|
|
73
73
|
|
|
74
74
|
PyTrendy is a robust solution for identifying and analyzing trends in time series. Unlike other trend detection packages, it is robust to noisy & flat segments, and handles for gradual & abrupt trend cases with a high precision. It aims to be the best package for trend detection in python.
|
|
75
75
|
|
|
76
|
+
**Read more in the documentation:** [russellsb.github.io/pytrendy/main](https://russellsb.github.io/pytrendy/main/)
|
|
77
|
+
|
|
76
78
|
## Features
|
|
77
79
|
|
|
78
80
|

|
|
@@ -120,7 +122,4 @@ time_index
|
|
|
120
122
|
-------------------------------------------------------------------------------
|
|
121
123
|
```
|
|
122
124
|
|
|
123
|
-
---
|
|
124
|
-
|
|
125
|
-
**Read more in the full documentation:** [russellsb.github.io/pytrendy/main](https://russellsb.github.io/pytrendy/main/)
|
|
126
125
|
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
|
|
17
17
|
PyTrendy is a robust solution for identifying and analyzing trends in time series. Unlike other trend detection packages, it is robust to noisy & flat segments, and handles for gradual & abrupt trend cases with a high precision. It aims to be the best package for trend detection in python.
|
|
18
18
|
|
|
19
|
+
**Read more in the documentation:** [russellsb.github.io/pytrendy/main](https://russellsb.github.io/pytrendy/main/)
|
|
20
|
+
|
|
19
21
|
## Features
|
|
20
22
|
|
|
21
23
|

|
|
@@ -63,6 +65,3 @@ time_index
|
|
|
63
65
|
-------------------------------------------------------------------------------
|
|
64
66
|
```
|
|
65
67
|
|
|
66
|
-
---
|
|
67
|
-
|
|
68
|
-
**Read more in the full documentation:** [russellsb.github.io/pytrendy/main](https://russellsb.github.io/pytrendy/main/)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "pytrendy"
|
|
3
|
-
version = "1.2.0.
|
|
3
|
+
version = "1.2.0.dev3"
|
|
4
4
|
description = "Trend Detection in Python. Applicable for real-world industry use cases in time series."
|
|
5
5
|
authors = [
|
|
6
6
|
{ name = "Russell Sammut Bonnici", email = "r.sammutbonnici@gmail.com" },
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""**End-to-End Trend Detection**"""
|
|
2
2
|
|
|
3
|
+
import warnings
|
|
3
4
|
import pandas as pd
|
|
4
5
|
from .process_signals import process_signals
|
|
5
6
|
from .post_processing.segments_get import get_segments
|
|
@@ -39,8 +40,7 @@ def detect_trends(df: pd.DataFrame, date_col: str, value_col: str, plot=True, me
|
|
|
39
40
|
method_params (dict, optional):
|
|
40
41
|
Optional parameters to customize detection heuristics. Supported keys:
|
|
41
42
|
|
|
42
|
-
- **
|
|
43
|
-
- **abrupt_padding** (`int`): Number of days to pad around abrupt transitions. Only referenced when `is_abrupt_padded` is `True`. Defaults to `28`.
|
|
43
|
+
- **abrupt_padding** (`int`): Number of days to pad around abrupt transitions. Defaults to `0`.
|
|
44
44
|
- **avoid_noise** (`bool`): Whether to avoid noisy segments in trend detection. Defaults to `True`.
|
|
45
45
|
debug (bool, optional):
|
|
46
46
|
If `True` will run in debug mode, outputting various additional plots and print statements. Only recommended for developers of pytrendy.
|
|
@@ -55,14 +55,22 @@ def detect_trends(df: pd.DataFrame, date_col: str, value_col: str, plot=True, me
|
|
|
55
55
|
df[date_col] = pd.to_datetime(df[date_col])
|
|
56
56
|
df.set_index(date_col, inplace=True)
|
|
57
57
|
df = df[[value_col]]
|
|
58
|
+
|
|
59
|
+
if method_params is None:
|
|
60
|
+
method_params = {} # Avoid mutable default argument by accepting None and constructing a new dict here
|
|
61
|
+
|
|
62
|
+
# Trigger deprecation warning if old parameter is used
|
|
63
|
+
if 'is_abrupt_padded' in method_params:
|
|
64
|
+
warnings.warn(
|
|
65
|
+
"'is_abrupt_padded' in method_params is deprecated. "
|
|
66
|
+
"Use 'abrupt_padding' only instead, which is 0 by default. Set to the number of days to pad by (e.g. 28).",
|
|
67
|
+
DeprecationWarning,
|
|
68
|
+
stacklevel=2,
|
|
69
|
+
)
|
|
58
70
|
|
|
59
71
|
# Configures trend detection heuristics
|
|
60
|
-
# Avoid mutable default argument by accepting None and constructing a new dict here
|
|
61
|
-
if method_params is None:
|
|
62
|
-
method_params = {}
|
|
63
72
|
method_params = {
|
|
64
|
-
'
|
|
65
|
-
'abrupt_padding': method_params.get('abrupt_padding', 28),
|
|
73
|
+
'abrupt_padding': method_params.get('abrupt_padding', 0),
|
|
66
74
|
'avoid_noise': method_params.get('avoid_noise', True),
|
|
67
75
|
}
|
|
68
76
|
|
{pytrendy-1.2.0.dev1 → pytrendy-1.2.0.dev3}/pytrendy/post_processing/segments_refine/__init__.py
RENAMED
|
@@ -29,8 +29,7 @@ def refine_segments(df: pd.DataFrame, value_col: str, segments: list[dict], meth
|
|
|
29
29
|
segments (list): Initial segment list from detection.
|
|
30
30
|
method_params (dict): Optional parameters for abrupt padding and control. Supported keys:
|
|
31
31
|
|
|
32
|
-
- **
|
|
33
|
-
- **abrupt_padding** (`int`): Number of days to pad. Defaults to `28`.
|
|
32
|
+
- **abrupt_padding** (`int`): Number of days to pad. Defaults to `0`.
|
|
34
33
|
|
|
35
34
|
Returns:
|
|
36
35
|
list: Final refined segment list.
|
|
@@ -22,8 +22,7 @@ def shave_abrupt_trends(df: pd.DataFrame, value_col: str, segments: list[dict],
|
|
|
22
22
|
segments (list): List of segment dictionaries with `'trend_class': 'abrupt'`.
|
|
23
23
|
method_params (dict): Optional parameters for padding and control. Supported keys:
|
|
24
24
|
|
|
25
|
-
- **
|
|
26
|
-
- **abrupt_padding** (`int`): Number of days to pad. Defaults to `28`.
|
|
25
|
+
- **abrupt_padding** (`int`): Number of days to pad. Defaults to `0`.
|
|
27
26
|
|
|
28
27
|
Returns:
|
|
29
28
|
list: Refined segment list with adjusted abrupt boundaries.
|
|
@@ -124,7 +123,7 @@ def shave_abrupt_trends(df: pd.DataFrame, value_col: str, segments: list[dict],
|
|
|
124
123
|
|
|
125
124
|
# Second pass to pad segments if specified
|
|
126
125
|
segments_padded = deepcopy(segments_refined)
|
|
127
|
-
if method_params.get('
|
|
126
|
+
if method_params.get('abrupt_padding', 0) >= 0:
|
|
128
127
|
|
|
129
128
|
meta_df = pd.DataFrame(segments_refined) # metadata df, to filter by datetime easily
|
|
130
129
|
meta_df['start'] = pd.to_datetime(meta_df['start'])
|
|
@@ -18,8 +18,7 @@ def clean_artifacts(df: pd.DataFrame, value_col: str, segments_refined: list[dic
|
|
|
18
18
|
segments_refined (list): List of segment dictionaries potentially with artifacts from post-processing.
|
|
19
19
|
method_params (dict): Optional parameters for cleanup behavior. Supported keys:
|
|
20
20
|
|
|
21
|
-
- **
|
|
22
|
-
- **abrupt_padding** (`int`): Padding window in days used by abrupt refinement; included for pipeline consistency. Defaults to `28`.
|
|
21
|
+
- **abrupt_padding** (`int`): Padding window in days used by abrupt refinement; included for pipeline consistency. Defaults to `0`.
|
|
23
22
|
- **avoid_noise** (`bool`): Whether to avoid noisy segments in trend detection. Defaults to `True`.
|
|
24
23
|
inverse_only (bool): If True, only perform inverse checks and skip other artifact cleanups. Useful for final cleanup pass after flat fill ins.
|
|
25
24
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|