ts-data-generator 0.2.2__tar.gz → 0.2.4__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.
- {ts_data_generator-0.2.2 → ts_data_generator-0.2.4}/.github/workflows/ci.yaml +6 -6
- {ts_data_generator-0.2.2 → ts_data_generator-0.2.4}/.github/workflows/test.yml +4 -8
- ts_data_generator-0.2.4/PKG-INFO +159 -0
- ts_data_generator-0.2.4/README.md +136 -0
- ts_data_generator-0.2.4/notebooks/aggregate.ipynb +545 -0
- ts_data_generator-0.2.4/notebooks/sample.ipynb +1812 -0
- {ts_data_generator-0.2.2 → ts_data_generator-0.2.4}/pyproject.toml +2 -2
- {ts_data_generator-0.2.2 → ts_data_generator-0.2.4}/src/ts_data_generator/cli.py +24 -21
- {ts_data_generator-0.2.2 → ts_data_generator-0.2.4}/src/ts_data_generator/data_gen.py +212 -150
- {ts_data_generator-0.2.2 → ts_data_generator-0.2.4}/src/ts_data_generator/schema/models.py +62 -27
- {ts_data_generator-0.2.2 → ts_data_generator-0.2.4}/src/ts_data_generator/utils/functions.py +26 -17
- {ts_data_generator-0.2.2 → ts_data_generator-0.2.4}/src/ts_data_generator/utils/trends.py +40 -26
- ts_data_generator-0.2.4/tests/test_generator.py +263 -0
- {ts_data_generator-0.2.2 → ts_data_generator-0.2.4}/uv.lock +1126 -1124
- ts_data_generator-0.2.2/PKG-INFO +0 -95
- ts_data_generator-0.2.2/README.md +0 -72
- ts_data_generator-0.2.2/notebooks/sample.ipynb +0 -1768
- ts_data_generator-0.2.2/poetry.lock +0 -1734
- ts_data_generator-0.2.2/tests/test_generator.py +0 -187
- {ts_data_generator-0.2.2 → ts_data_generator-0.2.4}/.gitignore +0 -0
- {ts_data_generator-0.2.2 → ts_data_generator-0.2.4}/.python-version +0 -0
- {ts_data_generator-0.2.2 → ts_data_generator-0.2.4}/LICENSE +0 -0
- {ts_data_generator-0.2.2 → ts_data_generator-0.2.4}/etc/data/sample.csv +0 -0
- {ts_data_generator-0.2.2 → ts_data_generator-0.2.4}/notebooks/image.png +0 -0
- {ts_data_generator-0.2.2 → ts_data_generator-0.2.4}/notebooks/imputer.ipynb +0 -0
- {ts_data_generator-0.2.2 → ts_data_generator-0.2.4}/src/ts_data_generator/__init__.py +0 -0
- {ts_data_generator-0.2.2 → ts_data_generator-0.2.4}/src/ts_data_generator/schema/__init__.py +0 -0
- {ts_data_generator-0.2.2 → ts_data_generator-0.2.4}/src/ts_data_generator/schema/converter.py +0 -0
- {ts_data_generator-0.2.2 → ts_data_generator-0.2.4}/src/ts_data_generator/utils/__init__.py +0 -0
- {ts_data_generator-0.2.2 → ts_data_generator-0.2.4}/src/ts_data_generator/utils.py +0 -0
- {ts_data_generator-0.2.2 → ts_data_generator-0.2.4}/tests/__init__.py +0 -0
- {ts_data_generator-0.2.2 → ts_data_generator-0.2.4}/tests/test_constructor.py +0 -0
|
@@ -80,21 +80,21 @@ jobs:
|
|
|
80
80
|
uses: actions/setup-python@v5
|
|
81
81
|
with:
|
|
82
82
|
python-version: "3.11"
|
|
83
|
-
- name: Install
|
|
83
|
+
- name: Install UV
|
|
84
84
|
run: |
|
|
85
|
-
curl -
|
|
85
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
86
86
|
echo "$HOME/.local/bin" >> $GITHUB_PATH
|
|
87
87
|
|
|
88
|
-
- name: Set project version with
|
|
88
|
+
- name: Set project version with UV
|
|
89
89
|
run: |
|
|
90
|
-
|
|
90
|
+
uvx --from toml-cli toml set --toml-path pyproject.toml project.version "${{ needs.details.outputs.new_version }}"
|
|
91
91
|
|
|
92
92
|
- name: Install dependencies
|
|
93
|
-
run:
|
|
93
|
+
run: uv sync
|
|
94
94
|
|
|
95
95
|
- name: Build source and wheel distribution
|
|
96
96
|
run: |
|
|
97
|
-
|
|
97
|
+
uv build
|
|
98
98
|
|
|
99
99
|
- name: Upload artifacts
|
|
100
100
|
uses: actions/upload-artifact@v4
|
|
@@ -19,19 +19,15 @@ jobs:
|
|
|
19
19
|
uses: actions/setup-python@v5
|
|
20
20
|
with:
|
|
21
21
|
python-version: "3.11"
|
|
22
|
-
- name: Install
|
|
22
|
+
- name: Install UV
|
|
23
23
|
run: |
|
|
24
|
-
curl -
|
|
24
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
25
25
|
echo "$HOME/.local/bin" >> $GITHUB_PATH
|
|
26
26
|
|
|
27
|
-
- name: Set project version with Poetry
|
|
28
|
-
run: |
|
|
29
|
-
poetry version ${{ needs.details.outputs.new_version }}
|
|
30
|
-
|
|
31
27
|
- name: Install dependencies
|
|
32
|
-
run:
|
|
28
|
+
run: uv sync
|
|
33
29
|
|
|
34
30
|
- name: Run PyTest 🧪
|
|
35
31
|
shell: bash
|
|
36
32
|
run: |
|
|
37
|
-
|
|
33
|
+
uv run -m pytest -vv tests
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ts-data-generator
|
|
3
|
+
Version: 0.2.4
|
|
4
|
+
Summary: A Python library for generating synthetic time series data
|
|
5
|
+
Author-email: Manoj Manivannan <manojm18@live.in>
|
|
6
|
+
License: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Keywords: data generator,python,synthetic data,time series
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Requires-Dist: click
|
|
14
|
+
Requires-Dist: matplotlib
|
|
15
|
+
Requires-Dist: pandas
|
|
16
|
+
Requires-Dist: pydantic
|
|
17
|
+
Requires-Dist: pytest
|
|
18
|
+
Requires-Dist: python-dotenv
|
|
19
|
+
Provides-Extra: dev
|
|
20
|
+
Requires-Dist: black; extra == 'dev'
|
|
21
|
+
Requires-Dist: flake8; extra == 'dev'
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
<!-- html title in the middle -->
|
|
25
|
+
<div align="center">
|
|
26
|
+
|
|
27
|
+
# Synthetic Time Series Data Generator
|
|
28
|
+
|
|
29
|
+
[](https://pypi.org/project/ts-data-generator) 
|
|
30
|
+
|
|
31
|
+
A Python library for generating synthetic time series data
|
|
32
|
+
|
|
33
|
+
<sup>Special thanks to: [Nike-Inc](https://github.com/Nike-Inc/timeseries-generator) repo
|
|
34
|
+
|
|
35
|
+
<img src="https://github.com/manojmanivannan/ts-data-generator/raw/main/notebooks/image.png" alt="MarineGEO circle logo" style="height: 1000px; width:800px;"/>
|
|
36
|
+
|
|
37
|
+
<!-- ![Tutorial][tutorial] -->
|
|
38
|
+
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
### PyPi (recommended)
|
|
43
|
+
You can install with pip directly by
|
|
44
|
+
```bash
|
|
45
|
+
pip install ts-data-generator
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Repo
|
|
49
|
+
After cloning this repo and creating a virtual environment, run the following command:
|
|
50
|
+
```bash
|
|
51
|
+
pip install --editable .
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Usage
|
|
55
|
+
1. To check out constructing for time series data, check the sample notebook [here](https://github.com/manojmanivannan/ts-data-generator/blob/main/notebooks/sample.ipynb)
|
|
56
|
+
2. To extract the trends from an existing data, check this sample notebook [here](https://github.com/manojmanivannan/ts-data-generator/blob/main/notebooks/imputer.ipynb)
|
|
57
|
+
|
|
58
|
+
### UV
|
|
59
|
+
You can easily run it using `uv`
|
|
60
|
+
```bash
|
|
61
|
+
uvx --python 3.11 --from ts-data-generator tsdata generate \
|
|
62
|
+
--start "2019-01-01" \
|
|
63
|
+
--end "2019-01-12" \
|
|
64
|
+
--granularity "5min" \
|
|
65
|
+
--dims "product_id:random_float:1,4" \
|
|
66
|
+
--dims "const:constant:5"
|
|
67
|
+
--mets "sales:LinearTrend(limit=500)+WeekendTrend(weekend_effect=50)"
|
|
68
|
+
--mets "trend:LinearTrend(limit=10)"
|
|
69
|
+
--output "data.csv"
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### CLI
|
|
73
|
+
|
|
74
|
+
You can also use the command line utility `tsdata` to generate the data.
|
|
75
|
+
```bash
|
|
76
|
+
~/G/ts-data-generator on main! 🐍 (ts-data-generator) $ tsdata
|
|
77
|
+
Usage: tsdata [OPTIONS] COMMAND [ARGS]...
|
|
78
|
+
|
|
79
|
+
CLI tool for generating time series data.
|
|
80
|
+
|
|
81
|
+
Options:
|
|
82
|
+
--help Show this message and exit.
|
|
83
|
+
|
|
84
|
+
Commands:
|
|
85
|
+
dimensions List all available dimension functions in ts_data_generator.utils.functions.
|
|
86
|
+
generate Generate time series data and save it to a CSV file.
|
|
87
|
+
metrics List all available metric trends in ts_data_generator.utils.trends.
|
|
88
|
+
~/G/ts-data-generator on main! 🐍 (ts-data-generator) $
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
~/G/ts-data-generator on main! 🐍 (ts-data-generator) $ tsdata dimensions
|
|
93
|
+
Available dimension functions are:
|
|
94
|
+
- auto_generate_name(category: str) -> str
|
|
95
|
+
Example: name:auto_generate_name:mycat
|
|
96
|
+
- constant(value: Union[int, str, float, list])
|
|
97
|
+
Example: name:constant:10
|
|
98
|
+
- ordered_choice(iterable)
|
|
99
|
+
Example: name:ordered_choice:A,B,C
|
|
100
|
+
- random_choice(iterable: Iterable[~T]) -> Generator[~T, NoneType, NoneType]
|
|
101
|
+
Example: name:random_choice:A,B,C
|
|
102
|
+
- random_float(start: float, end: float)
|
|
103
|
+
Example: name:random_float:0.0,1.0
|
|
104
|
+
- random_int(start: int, end: int) -> Generator[int, NoneType, NoneType]
|
|
105
|
+
Example: name:random_int:1,100
|
|
106
|
+
~/G/ts-data-generator on main! 🐍 (ts-data-generator) $
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
~/G/ts-data-generator on main! 🐍 (ts-data-generator) $ tsdata metrics
|
|
111
|
+
Available metric trends & parameters are:
|
|
112
|
+
- LinearTrend(name: str = 'default', offset: float = 0.0, noise_level: float = 0.0, limit: float = 2.0)
|
|
113
|
+
Example: sales:LinearTrend(offset=0,noise_level=1,limit=10)
|
|
114
|
+
- SinusoidalTrend(name: str = 'default', amplitude: float = 1, freq: float = 1, phase: float = 0, noise_level: float = 0)
|
|
115
|
+
Example: sales:SinusoidalTrend(amplitude=1,freq=24,phase=0,noise_level=0)
|
|
116
|
+
- StockTrend(name: str = 'default', amplitude: float = 15.0, direction: Literal['up', 'down'] = 'up', noise_level: float = 0.0)
|
|
117
|
+
Example: sales:StockTrend(amplitude=15.0,direction='up',noise_level=0.0)
|
|
118
|
+
- WeekendTrend(name: str = 'default', weekend_effect: float = 1.0, direction: Literal['up', 'down'] = 'up', noise_level: float = 0.0, limit: float = 10.0)
|
|
119
|
+
Example: sales:WeekendTrend(weekend_effect=10,direction='up',noise_level=0.5,limit=10)
|
|
120
|
+
~/G/ts-data-generator on main! 🐍 (ts-data-generator) $
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
~/G/ts-data-generator on main! 🐍 (ts-data-generator) $ tsdata generate
|
|
125
|
+
Usage: tsdata generate [OPTIONS]
|
|
126
|
+
|
|
127
|
+
Generate time series data and save it to a CSV file.
|
|
128
|
+
|
|
129
|
+
Options:
|
|
130
|
+
--start TEXT Start datetime 'YYYY-MM-DD'
|
|
131
|
+
--end TEXT End datetime 'YYYY-MM-DD'
|
|
132
|
+
--granularity [s|min|5min|h|D|W|ME|Y]
|
|
133
|
+
Granularity of the time series data
|
|
134
|
+
--dims TEXT + separated list of dimensions definition of format 'name:function:values'
|
|
135
|
+
--mets TEXT + separated list of metrics definition trends of format 'name:trend(*params)'
|
|
136
|
+
--output TEXT Output file name
|
|
137
|
+
--help Show this message and exit.
|
|
138
|
+
~/G/ts-data-generator on main! 🐍 (ts-data-generator) $
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
For example you can call this cli tool like below to generate data
|
|
142
|
+
```bash
|
|
143
|
+
tsdata generate \
|
|
144
|
+
--start "2019-01-01" \
|
|
145
|
+
--end "2019-01-12" \
|
|
146
|
+
--granularity "5min" \
|
|
147
|
+
--dims "product:random_choice:A,B,C,D" \
|
|
148
|
+
--dims "product_id:random_float:1,4" \
|
|
149
|
+
--dims "const:constant:5" \
|
|
150
|
+
--mets "sales:LinearTrend(limit=500)+WeekendTrend(weekend_effect=50)" \
|
|
151
|
+
--mets "trend:LinearTrend(limit=10)" \
|
|
152
|
+
--output "data.csv"
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
#### Release method
|
|
156
|
+
1. `git tag <x.x.x>`
|
|
157
|
+
2. `git push origin <x.x.x>`
|
|
158
|
+
|
|
159
|
+
<!-- [tutorial]: /notebooks/test.gif -->
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
<!-- html title in the middle -->
|
|
2
|
+
<div align="center">
|
|
3
|
+
|
|
4
|
+
# Synthetic Time Series Data Generator
|
|
5
|
+
|
|
6
|
+
[](https://pypi.org/project/ts-data-generator) 
|
|
7
|
+
|
|
8
|
+
A Python library for generating synthetic time series data
|
|
9
|
+
|
|
10
|
+
<sup>Special thanks to: [Nike-Inc](https://github.com/Nike-Inc/timeseries-generator) repo
|
|
11
|
+
|
|
12
|
+
<img src="https://github.com/manojmanivannan/ts-data-generator/raw/main/notebooks/image.png" alt="MarineGEO circle logo" style="height: 1000px; width:800px;"/>
|
|
13
|
+
|
|
14
|
+
<!-- ![Tutorial][tutorial] -->
|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
### PyPi (recommended)
|
|
20
|
+
You can install with pip directly by
|
|
21
|
+
```bash
|
|
22
|
+
pip install ts-data-generator
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Repo
|
|
26
|
+
After cloning this repo and creating a virtual environment, run the following command:
|
|
27
|
+
```bash
|
|
28
|
+
pip install --editable .
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
1. To check out constructing for time series data, check the sample notebook [here](https://github.com/manojmanivannan/ts-data-generator/blob/main/notebooks/sample.ipynb)
|
|
33
|
+
2. To extract the trends from an existing data, check this sample notebook [here](https://github.com/manojmanivannan/ts-data-generator/blob/main/notebooks/imputer.ipynb)
|
|
34
|
+
|
|
35
|
+
### UV
|
|
36
|
+
You can easily run it using `uv`
|
|
37
|
+
```bash
|
|
38
|
+
uvx --python 3.11 --from ts-data-generator tsdata generate \
|
|
39
|
+
--start "2019-01-01" \
|
|
40
|
+
--end "2019-01-12" \
|
|
41
|
+
--granularity "5min" \
|
|
42
|
+
--dims "product_id:random_float:1,4" \
|
|
43
|
+
--dims "const:constant:5"
|
|
44
|
+
--mets "sales:LinearTrend(limit=500)+WeekendTrend(weekend_effect=50)"
|
|
45
|
+
--mets "trend:LinearTrend(limit=10)"
|
|
46
|
+
--output "data.csv"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### CLI
|
|
50
|
+
|
|
51
|
+
You can also use the command line utility `tsdata` to generate the data.
|
|
52
|
+
```bash
|
|
53
|
+
~/G/ts-data-generator on main! 🐍 (ts-data-generator) $ tsdata
|
|
54
|
+
Usage: tsdata [OPTIONS] COMMAND [ARGS]...
|
|
55
|
+
|
|
56
|
+
CLI tool for generating time series data.
|
|
57
|
+
|
|
58
|
+
Options:
|
|
59
|
+
--help Show this message and exit.
|
|
60
|
+
|
|
61
|
+
Commands:
|
|
62
|
+
dimensions List all available dimension functions in ts_data_generator.utils.functions.
|
|
63
|
+
generate Generate time series data and save it to a CSV file.
|
|
64
|
+
metrics List all available metric trends in ts_data_generator.utils.trends.
|
|
65
|
+
~/G/ts-data-generator on main! 🐍 (ts-data-generator) $
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
~/G/ts-data-generator on main! 🐍 (ts-data-generator) $ tsdata dimensions
|
|
70
|
+
Available dimension functions are:
|
|
71
|
+
- auto_generate_name(category: str) -> str
|
|
72
|
+
Example: name:auto_generate_name:mycat
|
|
73
|
+
- constant(value: Union[int, str, float, list])
|
|
74
|
+
Example: name:constant:10
|
|
75
|
+
- ordered_choice(iterable)
|
|
76
|
+
Example: name:ordered_choice:A,B,C
|
|
77
|
+
- random_choice(iterable: Iterable[~T]) -> Generator[~T, NoneType, NoneType]
|
|
78
|
+
Example: name:random_choice:A,B,C
|
|
79
|
+
- random_float(start: float, end: float)
|
|
80
|
+
Example: name:random_float:0.0,1.0
|
|
81
|
+
- random_int(start: int, end: int) -> Generator[int, NoneType, NoneType]
|
|
82
|
+
Example: name:random_int:1,100
|
|
83
|
+
~/G/ts-data-generator on main! 🐍 (ts-data-generator) $
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
~/G/ts-data-generator on main! 🐍 (ts-data-generator) $ tsdata metrics
|
|
88
|
+
Available metric trends & parameters are:
|
|
89
|
+
- LinearTrend(name: str = 'default', offset: float = 0.0, noise_level: float = 0.0, limit: float = 2.0)
|
|
90
|
+
Example: sales:LinearTrend(offset=0,noise_level=1,limit=10)
|
|
91
|
+
- SinusoidalTrend(name: str = 'default', amplitude: float = 1, freq: float = 1, phase: float = 0, noise_level: float = 0)
|
|
92
|
+
Example: sales:SinusoidalTrend(amplitude=1,freq=24,phase=0,noise_level=0)
|
|
93
|
+
- StockTrend(name: str = 'default', amplitude: float = 15.0, direction: Literal['up', 'down'] = 'up', noise_level: float = 0.0)
|
|
94
|
+
Example: sales:StockTrend(amplitude=15.0,direction='up',noise_level=0.0)
|
|
95
|
+
- WeekendTrend(name: str = 'default', weekend_effect: float = 1.0, direction: Literal['up', 'down'] = 'up', noise_level: float = 0.0, limit: float = 10.0)
|
|
96
|
+
Example: sales:WeekendTrend(weekend_effect=10,direction='up',noise_level=0.5,limit=10)
|
|
97
|
+
~/G/ts-data-generator on main! 🐍 (ts-data-generator) $
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
~/G/ts-data-generator on main! 🐍 (ts-data-generator) $ tsdata generate
|
|
102
|
+
Usage: tsdata generate [OPTIONS]
|
|
103
|
+
|
|
104
|
+
Generate time series data and save it to a CSV file.
|
|
105
|
+
|
|
106
|
+
Options:
|
|
107
|
+
--start TEXT Start datetime 'YYYY-MM-DD'
|
|
108
|
+
--end TEXT End datetime 'YYYY-MM-DD'
|
|
109
|
+
--granularity [s|min|5min|h|D|W|ME|Y]
|
|
110
|
+
Granularity of the time series data
|
|
111
|
+
--dims TEXT + separated list of dimensions definition of format 'name:function:values'
|
|
112
|
+
--mets TEXT + separated list of metrics definition trends of format 'name:trend(*params)'
|
|
113
|
+
--output TEXT Output file name
|
|
114
|
+
--help Show this message and exit.
|
|
115
|
+
~/G/ts-data-generator on main! 🐍 (ts-data-generator) $
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
For example you can call this cli tool like below to generate data
|
|
119
|
+
```bash
|
|
120
|
+
tsdata generate \
|
|
121
|
+
--start "2019-01-01" \
|
|
122
|
+
--end "2019-01-12" \
|
|
123
|
+
--granularity "5min" \
|
|
124
|
+
--dims "product:random_choice:A,B,C,D" \
|
|
125
|
+
--dims "product_id:random_float:1,4" \
|
|
126
|
+
--dims "const:constant:5" \
|
|
127
|
+
--mets "sales:LinearTrend(limit=500)+WeekendTrend(weekend_effect=50)" \
|
|
128
|
+
--mets "trend:LinearTrend(limit=10)" \
|
|
129
|
+
--output "data.csv"
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
#### Release method
|
|
133
|
+
1. `git tag <x.x.x>`
|
|
134
|
+
2. `git push origin <x.x.x>`
|
|
135
|
+
|
|
136
|
+
<!-- [tutorial]: /notebooks/test.gif -->
|