traffic-anomaly 0.0.0__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.
- traffic_anomaly-0.0.0/LICENSE +21 -0
- traffic_anomaly-0.0.0/MANIFEST.in +1 -0
- traffic_anomaly-0.0.0/PKG-INFO +52 -0
- traffic_anomaly-0.0.0/README.md +38 -0
- traffic_anomaly-0.0.0/pyproject.toml +25 -0
- traffic_anomaly-0.0.0/setup.cfg +4 -0
- traffic_anomaly-0.0.0/src/traffic_anomaly/__init__.py +7 -0
- traffic_anomaly-0.0.0/src/traffic_anomaly/data/sample_data.parquet +0 -0
- traffic_anomaly-0.0.0/src/traffic_anomaly/data/sample_data_groups.parquet +0 -0
- traffic_anomaly-0.0.0/src/traffic_anomaly/decompose.py +77 -0
- traffic_anomaly-0.0.0/src/traffic_anomaly/find_anomaly.py +77 -0
- traffic_anomaly-0.0.0/src/traffic_anomaly/sample_data.py +14 -0
- traffic_anomaly-0.0.0/src/traffic_anomaly.egg-info/PKG-INFO +52 -0
- traffic_anomaly-0.0.0/src/traffic_anomaly.egg-info/SOURCES.txt +15 -0
- traffic_anomaly-0.0.0/src/traffic_anomaly.egg-info/dependency_links.txt +1 -0
- traffic_anomaly-0.0.0/src/traffic_anomaly.egg-info/requires.txt +2 -0
- traffic_anomaly-0.0.0/src/traffic_anomaly.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Shawn Strasser
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
recursive-include src/traffic_anomaly/data *.parquet
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: traffic_anomaly
|
|
3
|
+
Version: 0.0.0
|
|
4
|
+
Summary: Robust decomposition and anomaly detection on multiple time series for any SQL backend. Designed for traffic data.
|
|
5
|
+
Author-email: Shawn Strasser <shawn.strasser@odot.oregon.gov>
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Requires-Python: >=3.7
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: duckdb<0.10.2,>=0.9.1
|
|
13
|
+
Requires-Dist: ibis-framework
|
|
14
|
+
|
|
15
|
+
# Traffic Anomaly
|
|
16
|
+
|
|
17
|
+
`traffic_anomaly` is a production ready Python package for robust decomposition and anomaly detection on multiple time series at once. It uses Ibis to integrate with any SQL backend in a production pipeline, or run locally with the included DuckDB backend.
|
|
18
|
+
|
|
19
|
+
Designed for real world messy traffic data (volumes, travel times), `traffic_anomaly` uses medians to decompose time series into trend, daily, weekly, and residual components. Anomalies are then classified, and Median Absolute Deviation may be used for further robustness. Missing data are handled, and time periods without sufficient data can be thrown out. Check out `example.ipynb` in this repository for a demo.
|
|
20
|
+
|
|
21
|
+
This package does not produce plots but here's one anyway:
|
|
22
|
+
|
|
23
|
+

|
|
24
|
+
|
|
25
|
+
# Installation
|
|
26
|
+
|
|
27
|
+
Note: Ibis and DuckDB are dependencies and will be installed automatically.
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install traffic_anomaly
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
# Considerations
|
|
34
|
+
|
|
35
|
+
The seasonal components are not allowed to change over time, therefore, it is important to limit the number of weeks included in the model, especially if there is yearly seasonality (and there is). The recommended use for application over a long date range is to run the model incrementally over a rolling window of about 6 weeks.
|
|
36
|
+
|
|
37
|
+
Because traffic data anomalies usually skew higher, forecasts made by this model are systemically low because in a right tailed distribution the median will be lower than the mean. This is by design, as the model is meant primarily for anomaly detection and not forecasting.
|
|
38
|
+
|
|
39
|
+
# Notes On Anomaly Detection
|
|
40
|
+
|
|
41
|
+
`traffic_anomaly` can classify two separate types of anomalies:
|
|
42
|
+
|
|
43
|
+
1. Entity-Level Anomalies are detected for individual entities based on their own historical patterns, without considering the group context.
|
|
44
|
+
2. Group-Level Anomalies are detected for entities when compared to the behavior of other entities within the same group. Group-level anomalies are more rare because in order to be considered for classification as a group-level anomaly, a time period must also have been classified as an entity-level anomaly.
|
|
45
|
+
|
|
46
|
+
Why is that needed? Well, say you're data is vehicle travel times within a city and there is a snow storm. Travel times across the city drop, and if you're looking at roadway segments in isolation, everything is an anomaly. That's nice, but what if you're only interested in things that are broken? That's where group-level anomalies come in. They are more rare, but they are more likely to be actionable. Probably not much you can do about that snow storm...
|
|
47
|
+
|
|
48
|
+
# Future Plans/Support
|
|
49
|
+
It would be nice to add support for Holidays and a yearly component... please help?
|
|
50
|
+
|
|
51
|
+
### Change Point Detection
|
|
52
|
+
I have working code from the `ruptures` package but it's not integrated here yet, and it's slower than molasses. I'll get to it eventually.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Traffic Anomaly
|
|
2
|
+
|
|
3
|
+
`traffic_anomaly` is a production ready Python package for robust decomposition and anomaly detection on multiple time series at once. It uses Ibis to integrate with any SQL backend in a production pipeline, or run locally with the included DuckDB backend.
|
|
4
|
+
|
|
5
|
+
Designed for real world messy traffic data (volumes, travel times), `traffic_anomaly` uses medians to decompose time series into trend, daily, weekly, and residual components. Anomalies are then classified, and Median Absolute Deviation may be used for further robustness. Missing data are handled, and time periods without sufficient data can be thrown out. Check out `example.ipynb` in this repository for a demo.
|
|
6
|
+
|
|
7
|
+
This package does not produce plots but here's one anyway:
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
# Installation
|
|
12
|
+
|
|
13
|
+
Note: Ibis and DuckDB are dependencies and will be installed automatically.
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install traffic_anomaly
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
# Considerations
|
|
20
|
+
|
|
21
|
+
The seasonal components are not allowed to change over time, therefore, it is important to limit the number of weeks included in the model, especially if there is yearly seasonality (and there is). The recommended use for application over a long date range is to run the model incrementally over a rolling window of about 6 weeks.
|
|
22
|
+
|
|
23
|
+
Because traffic data anomalies usually skew higher, forecasts made by this model are systemically low because in a right tailed distribution the median will be lower than the mean. This is by design, as the model is meant primarily for anomaly detection and not forecasting.
|
|
24
|
+
|
|
25
|
+
# Notes On Anomaly Detection
|
|
26
|
+
|
|
27
|
+
`traffic_anomaly` can classify two separate types of anomalies:
|
|
28
|
+
|
|
29
|
+
1. Entity-Level Anomalies are detected for individual entities based on their own historical patterns, without considering the group context.
|
|
30
|
+
2. Group-Level Anomalies are detected for entities when compared to the behavior of other entities within the same group. Group-level anomalies are more rare because in order to be considered for classification as a group-level anomaly, a time period must also have been classified as an entity-level anomaly.
|
|
31
|
+
|
|
32
|
+
Why is that needed? Well, say you're data is vehicle travel times within a city and there is a snow storm. Travel times across the city drop, and if you're looking at roadway segments in isolation, everything is an anomaly. That's nice, but what if you're only interested in things that are broken? That's where group-level anomalies come in. They are more rare, but they are more likely to be actionable. Probably not much you can do about that snow storm...
|
|
33
|
+
|
|
34
|
+
# Future Plans/Support
|
|
35
|
+
It would be nice to add support for Holidays and a yearly component... please help?
|
|
36
|
+
|
|
37
|
+
### Change Point Detection
|
|
38
|
+
I have working code from the `ruptures` package but it's not integrated here yet, and it's slower than molasses. I'll get to it eventually.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "traffic_anomaly"
|
|
3
|
+
version = "0.0.0"
|
|
4
|
+
authors = [
|
|
5
|
+
{ name="Shawn Strasser", email="shawn.strasser@odot.oregon.gov" },
|
|
6
|
+
]
|
|
7
|
+
description = "Robust decomposition and anomaly detection on multiple time series for any SQL backend. Designed for traffic data."
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
requires-python = ">=3.7"
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Programming Language :: Python :: 3",
|
|
12
|
+
"License :: OSI Approved :: MIT License",
|
|
13
|
+
"Operating System :: OS Independent",
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
dependencies = [
|
|
17
|
+
"duckdb>=0.9.1,<0.10.2",
|
|
18
|
+
"ibis-framework",
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
[tools.setuptools]
|
|
22
|
+
include_package_data = true
|
|
23
|
+
package_data = {"traffic_anomaly" = ["data/*"]}
|
|
24
|
+
|
|
25
|
+
|
|
Binary file
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import ibis
|
|
2
|
+
from ibis import _
|
|
3
|
+
|
|
4
|
+
def median_decompose(data,
|
|
5
|
+
freq_minutes,
|
|
6
|
+
rolling_window_days,
|
|
7
|
+
drop_days=0,
|
|
8
|
+
min_rolling_window_samples=0,
|
|
9
|
+
min_time_of_day_samples=0,
|
|
10
|
+
return_sql=False
|
|
11
|
+
):
|
|
12
|
+
"""
|
|
13
|
+
Decomposes a time series dataset into rolling median, seasonal (day and week), and residual components.
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
data (pd.DataFrame or ibis.expr.types.TableExpr): The time series data to decompose.
|
|
17
|
+
freq_minutes (int): Frequency of the time series data in minutes. Default is 60.
|
|
18
|
+
rolling_window_days (int): Number of days to use for the rolling window. Default is 7.
|
|
19
|
+
drop_days (int): Number of days to drop from the beginning of the dataset. Default is 7.
|
|
20
|
+
min_rolling_window_samples (int): Minimum number of samples required in the rolling window. Default is 56.
|
|
21
|
+
min_time_of_day_samples (int): Minimum number of samples required for each time of day. Default is 7.
|
|
22
|
+
|
|
23
|
+
Returns:
|
|
24
|
+
pd.DataFrame: The decomposed time series data. If return_sql is True, returns the SQL query string instead.
|
|
25
|
+
|
|
26
|
+
"""
|
|
27
|
+
# Check if df_or_table is an Ibis table
|
|
28
|
+
if isinstance(data, ibis.Expr):
|
|
29
|
+
table = data
|
|
30
|
+
else:
|
|
31
|
+
try:
|
|
32
|
+
table = ibis.memtable(data)
|
|
33
|
+
except Exception as e:
|
|
34
|
+
raise ValueError('Invalid data type. Please provide a valid Ibis table or Pandas DataFrame.')
|
|
35
|
+
|
|
36
|
+
window = ibis.window(
|
|
37
|
+
group_by=table.id,
|
|
38
|
+
order_by=table.timestamp,
|
|
39
|
+
preceding=ibis.interval(hours=(24 * rolling_window_days) - 1),
|
|
40
|
+
following=0
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
result = (
|
|
44
|
+
table
|
|
45
|
+
.mutate(
|
|
46
|
+
rolling_row_count=_.count().over(window).cast('int16'),
|
|
47
|
+
median=_.value.median().over(window).cast('float32')
|
|
48
|
+
)
|
|
49
|
+
.filter(_.timestamp >= _.timestamp.min() + ibis.interval(days=drop_days))
|
|
50
|
+
.mutate(
|
|
51
|
+
detrend=_.value - _.median,
|
|
52
|
+
time_of_day=((_.timestamp.hour() * 60 + _.timestamp.minute()) / freq_minutes + 1).cast('int16'),
|
|
53
|
+
day_of_week=_.timestamp.day_of_week.index(),
|
|
54
|
+
)
|
|
55
|
+
.group_by([_.id, _.time_of_day])
|
|
56
|
+
.mutate(season_day=_.detrend.median().cast('float32'), time_of_day_count=_.count().cast('int16'))
|
|
57
|
+
.group_by([_.id, _.day_of_week, _.time_of_day])
|
|
58
|
+
.mutate(season_week=(_.detrend - _.season_day).median().cast('float32'))
|
|
59
|
+
.mutate(resid=_.detrend - _.season_day - _.season_week)
|
|
60
|
+
.filter(_.rolling_row_count >= min_rolling_window_samples, _.time_of_day_count >= min_time_of_day_samples)
|
|
61
|
+
.select(
|
|
62
|
+
_.timestamp,
|
|
63
|
+
_.id,
|
|
64
|
+
_.value,
|
|
65
|
+
_.median,
|
|
66
|
+
_.season_day,
|
|
67
|
+
_.season_week,
|
|
68
|
+
_.resid,
|
|
69
|
+
)
|
|
70
|
+
.order_by([_.timestamp, _.id])
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
if return_sql:
|
|
74
|
+
return ibis.to_sql(result)
|
|
75
|
+
else:
|
|
76
|
+
return result.execute()
|
|
77
|
+
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import ibis
|
|
2
|
+
from ibis import _
|
|
3
|
+
|
|
4
|
+
def find_anomaly(decomposed_data, threshold=3.0, MAD=False, return_sql=False):
|
|
5
|
+
"""
|
|
6
|
+
Detect anomalies in the decomposed time series data.
|
|
7
|
+
|
|
8
|
+
Args:
|
|
9
|
+
decomposed_data (pd.DataFrame or ibis.expr.types.TableExpr): The time series data to decompose.
|
|
10
|
+
threshold (float): The threshold z-score for anomaly detection (default: 3.0).
|
|
11
|
+
|
|
12
|
+
Returns:
|
|
13
|
+
pandas.DataFrame: The detected anomalies. If return_sql is True, returns the SQL query string instead.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
NOTES: Entity-Level Anomalies are detected for individual entities based on their own historical patterns, without considering the group context.
|
|
17
|
+
Group-Level Anomalies are detected for entities when compared to the behavior of other entities within the same group.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
# Check if df_or_table is an Ibis table
|
|
21
|
+
if isinstance(decomposed_data, ibis.Expr):
|
|
22
|
+
table = decomposed_data
|
|
23
|
+
else:
|
|
24
|
+
try:
|
|
25
|
+
table = ibis.memtable(decomposed_data)
|
|
26
|
+
except Exception as e:
|
|
27
|
+
raise ValueError('Invalid data type. Please provide a valid Ibis table or Pandas DataFrame.')
|
|
28
|
+
|
|
29
|
+
# Assert that id and resid columns exist in the table
|
|
30
|
+
assert 'id' in table.columns, 'id column not found in the table.'
|
|
31
|
+
assert 'resid' in table.columns, 'resid column not found in the table.'
|
|
32
|
+
|
|
33
|
+
epsilon = 1e-8
|
|
34
|
+
|
|
35
|
+
if MAD:
|
|
36
|
+
# Calculate the Median Absolute Deviation (MAD)
|
|
37
|
+
result = (
|
|
38
|
+
table
|
|
39
|
+
.group_by('id').mutate(MAD=_.resid.abs().median())
|
|
40
|
+
.mutate(anomaly=_.resid / (2 * _.MAD + epsilon) > threshold)
|
|
41
|
+
.drop('MAD')
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
else:
|
|
45
|
+
result = (
|
|
46
|
+
table
|
|
47
|
+
.group_by('id')
|
|
48
|
+
.mutate(anomaly=(_.resid - _.resid.mean()) / (_.resid.std() + epsilon) > threshold)
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
# Check if `group` column exists in the table
|
|
52
|
+
if 'group' in result.columns:
|
|
53
|
+
# Check that timestamp column exists in the table
|
|
54
|
+
assert 'timestamp' in result.columns, 'timestamp column not found in the table.'
|
|
55
|
+
if MAD:
|
|
56
|
+
result = (
|
|
57
|
+
result
|
|
58
|
+
.group_by(['timestamp', 'group']).mutate(MAD=_.resid.abs().median())
|
|
59
|
+
.mutate(anomaly=(_.resid / (2 * _.MAD + epsilon) > threshold) & _.anomaly)
|
|
60
|
+
.drop('MAD')
|
|
61
|
+
)
|
|
62
|
+
else:
|
|
63
|
+
result = (
|
|
64
|
+
result
|
|
65
|
+
.group_by(['timestamp', 'group'])
|
|
66
|
+
.mutate(anomaly=(
|
|
67
|
+
((_.resid - _.resid.mean()) / (_.resid.std() + epsilon) > threshold) &
|
|
68
|
+
(_.anomaly)
|
|
69
|
+
))
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
result = result.order_by([_.timestamp, _.id])
|
|
73
|
+
|
|
74
|
+
if return_sql:
|
|
75
|
+
return ibis.to_sql(result)
|
|
76
|
+
else:
|
|
77
|
+
return result.execute()
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# sample_data.py inside the package
|
|
2
|
+
import pandas as pd
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
# Assuming this file is in the same directory as the `data` directory
|
|
6
|
+
data_dir = os.path.join(os.path.dirname(__file__), 'data')
|
|
7
|
+
|
|
8
|
+
class SampleData:
|
|
9
|
+
def __init__(self):
|
|
10
|
+
self.data = pd.read_parquet(os.path.join(data_dir, 'sample_data.parquet'))
|
|
11
|
+
self.groups = pd.read_parquet(os.path.join(data_dir, 'sample_data_groups.parquet'))
|
|
12
|
+
|
|
13
|
+
# Create an instance of the class
|
|
14
|
+
sample_data = SampleData()
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: traffic_anomaly
|
|
3
|
+
Version: 0.0.0
|
|
4
|
+
Summary: Robust decomposition and anomaly detection on multiple time series for any SQL backend. Designed for traffic data.
|
|
5
|
+
Author-email: Shawn Strasser <shawn.strasser@odot.oregon.gov>
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Requires-Python: >=3.7
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: duckdb<0.10.2,>=0.9.1
|
|
13
|
+
Requires-Dist: ibis-framework
|
|
14
|
+
|
|
15
|
+
# Traffic Anomaly
|
|
16
|
+
|
|
17
|
+
`traffic_anomaly` is a production ready Python package for robust decomposition and anomaly detection on multiple time series at once. It uses Ibis to integrate with any SQL backend in a production pipeline, or run locally with the included DuckDB backend.
|
|
18
|
+
|
|
19
|
+
Designed for real world messy traffic data (volumes, travel times), `traffic_anomaly` uses medians to decompose time series into trend, daily, weekly, and residual components. Anomalies are then classified, and Median Absolute Deviation may be used for further robustness. Missing data are handled, and time periods without sufficient data can be thrown out. Check out `example.ipynb` in this repository for a demo.
|
|
20
|
+
|
|
21
|
+
This package does not produce plots but here's one anyway:
|
|
22
|
+
|
|
23
|
+

|
|
24
|
+
|
|
25
|
+
# Installation
|
|
26
|
+
|
|
27
|
+
Note: Ibis and DuckDB are dependencies and will be installed automatically.
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install traffic_anomaly
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
# Considerations
|
|
34
|
+
|
|
35
|
+
The seasonal components are not allowed to change over time, therefore, it is important to limit the number of weeks included in the model, especially if there is yearly seasonality (and there is). The recommended use for application over a long date range is to run the model incrementally over a rolling window of about 6 weeks.
|
|
36
|
+
|
|
37
|
+
Because traffic data anomalies usually skew higher, forecasts made by this model are systemically low because in a right tailed distribution the median will be lower than the mean. This is by design, as the model is meant primarily for anomaly detection and not forecasting.
|
|
38
|
+
|
|
39
|
+
# Notes On Anomaly Detection
|
|
40
|
+
|
|
41
|
+
`traffic_anomaly` can classify two separate types of anomalies:
|
|
42
|
+
|
|
43
|
+
1. Entity-Level Anomalies are detected for individual entities based on their own historical patterns, without considering the group context.
|
|
44
|
+
2. Group-Level Anomalies are detected for entities when compared to the behavior of other entities within the same group. Group-level anomalies are more rare because in order to be considered for classification as a group-level anomaly, a time period must also have been classified as an entity-level anomaly.
|
|
45
|
+
|
|
46
|
+
Why is that needed? Well, say you're data is vehicle travel times within a city and there is a snow storm. Travel times across the city drop, and if you're looking at roadway segments in isolation, everything is an anomaly. That's nice, but what if you're only interested in things that are broken? That's where group-level anomalies come in. They are more rare, but they are more likely to be actionable. Probably not much you can do about that snow storm...
|
|
47
|
+
|
|
48
|
+
# Future Plans/Support
|
|
49
|
+
It would be nice to add support for Holidays and a yearly component... please help?
|
|
50
|
+
|
|
51
|
+
### Change Point Detection
|
|
52
|
+
I have working code from the `ruptures` package but it's not integrated here yet, and it's slower than molasses. I'll get to it eventually.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
README.md
|
|
4
|
+
pyproject.toml
|
|
5
|
+
src/traffic_anomaly/__init__.py
|
|
6
|
+
src/traffic_anomaly/decompose.py
|
|
7
|
+
src/traffic_anomaly/find_anomaly.py
|
|
8
|
+
src/traffic_anomaly/sample_data.py
|
|
9
|
+
src/traffic_anomaly.egg-info/PKG-INFO
|
|
10
|
+
src/traffic_anomaly.egg-info/SOURCES.txt
|
|
11
|
+
src/traffic_anomaly.egg-info/dependency_links.txt
|
|
12
|
+
src/traffic_anomaly.egg-info/requires.txt
|
|
13
|
+
src/traffic_anomaly.egg-info/top_level.txt
|
|
14
|
+
src/traffic_anomaly/data/sample_data.parquet
|
|
15
|
+
src/traffic_anomaly/data/sample_data_groups.parquet
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
traffic_anomaly
|