tab2seq 0.1.1__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.
- tab2seq-0.1.1/LICENSE +21 -0
- tab2seq-0.1.1/PKG-INFO +246 -0
- tab2seq-0.1.1/README.md +196 -0
- tab2seq-0.1.1/pyproject.toml +95 -0
- tab2seq-0.1.1/setup.cfg +4 -0
- tab2seq-0.1.1/src/tab2seq/__init__.py +9 -0
- tab2seq-0.1.1/src/tab2seq/datasets/__init__.py +5 -0
- tab2seq-0.1.1/src/tab2seq/datasets/synthetic.py +602 -0
- tab2seq-0.1.1/src/tab2seq/source/__init__.py +12 -0
- tab2seq-0.1.1/src/tab2seq/source/collection.py +165 -0
- tab2seq-0.1.1/src/tab2seq/source/config.py +101 -0
- tab2seq-0.1.1/src/tab2seq/source/core.py +223 -0
- tab2seq-0.1.1/src/tab2seq.egg-info/PKG-INFO +246 -0
- tab2seq-0.1.1/src/tab2seq.egg-info/SOURCES.txt +17 -0
- tab2seq-0.1.1/src/tab2seq.egg-info/dependency_links.txt +1 -0
- tab2seq-0.1.1/src/tab2seq.egg-info/requires.txt +29 -0
- tab2seq-0.1.1/src/tab2seq.egg-info/top_level.txt +1 -0
- tab2seq-0.1.1/tests/test_datasets.py +352 -0
- tab2seq-0.1.1/tests/test_source.py +434 -0
tab2seq-0.1.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Germans Savcisens
|
|
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.
|
tab2seq-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tab2seq
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Transform tabular event data into sequences ready for Transformer and Sequential models: Life2Vec, BEHRT and more.
|
|
5
|
+
Author-email: Germans Savcisens <germans@savcisens.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/carlomarxdk/tab2seq
|
|
8
|
+
Project-URL: Documentation, https://tab2seq.readthedocs.io
|
|
9
|
+
Project-URL: Repository, https://github.com/carlomarxdk/tab2seq
|
|
10
|
+
Project-URL: Issues, https://github.com/carlomarxdk/tab2seq/issues
|
|
11
|
+
Keywords: tokenization,data preprocessing,tabular data,transformer models,sequential models,life2vec
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
20
|
+
Requires-Python: >=3.11
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: numpy>=2.0.0
|
|
24
|
+
Requires-Dist: polars<2.0,>=1.38.0
|
|
25
|
+
Requires-Dist: pyarrow>=12.0.0
|
|
26
|
+
Requires-Dist: pydantic>=2.0.0
|
|
27
|
+
Requires-Dist: tqdm>=4.65.0
|
|
28
|
+
Requires-Dist: pyyaml>=6.0
|
|
29
|
+
Requires-Dist: click>=8.1.0
|
|
30
|
+
Requires-Dist: joblib>=1.3.0
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: pytest>=9.0.0; extra == "dev"
|
|
33
|
+
Requires-Dist: pytest-cov>=6.0.0; extra == "dev"
|
|
34
|
+
Requires-Dist: pytest-xdist>=3.5.0; extra == "dev"
|
|
35
|
+
Requires-Dist: ruff>=0.15.0; extra == "dev"
|
|
36
|
+
Requires-Dist: mypy>=1.19.0; extra == "dev"
|
|
37
|
+
Requires-Dist: types-PyYAML>=6.0.0; extra == "dev"
|
|
38
|
+
Provides-Extra: docs
|
|
39
|
+
Requires-Dist: mkdocs>=1.6.1; extra == "docs"
|
|
40
|
+
Requires-Dist: mkdocs-material>=9.7.1; extra == "docs"
|
|
41
|
+
Requires-Dist: mkdocstrings>=1.0.2; extra == "docs"
|
|
42
|
+
Requires-Dist: mkdocstrings-python>=2.0.0; extra == "docs"
|
|
43
|
+
Requires-Dist: mkdocs-gen-files>=0.6.0; extra == "docs"
|
|
44
|
+
Requires-Dist: mkdocs-literate-nav>=0.6.2; extra == "docs"
|
|
45
|
+
Requires-Dist: mkdocs-section-index>=0.3.10; extra == "docs"
|
|
46
|
+
Requires-Dist: mkdocs-bibtex>=4.4.0; extra == "docs"
|
|
47
|
+
Provides-Extra: all
|
|
48
|
+
Requires-Dist: tab2seq[dev,docs]; extra == "all"
|
|
49
|
+
Dynamic: license-file
|
|
50
|
+
|
|
51
|
+
# tab2seq
|
|
52
|
+
|
|
53
|
+
[](https://pypi.org/project/tab2seq/)
|
|
54
|
+
[](https://pypi.org/project/tab2seq/)
|
|
55
|
+
[](https://pypi.org/project/tab2seq/)
|
|
56
|
+
[](https://github.com/carlomarxdk/tab2seq/blob/main/LICENSE)
|
|
57
|
+
|
|
58
|
+
**tab2seq** adapts the Life2Vec data processing pipeline to make it easy to work with multi-source tabular event data for sequential modeling projects. Transform registry data, EHR records, and other event-based datasets into formats ready for Transformer and sequential deep learning models.
|
|
59
|
+
|
|
60
|
+
> [!WARNING]
|
|
61
|
+
> This is an alpha package. In the beta version, it will reimplement all the data-preprocessing steps of the [life2vec](https://github.com/SocialComplexityLab/life2vec) and [life2vec-light](https://github.com/carlomarxdk/life2vec-light) repos. See [TODOs](#todos) to see what is implemented at this point.
|
|
62
|
+
|
|
63
|
+
## About
|
|
64
|
+
|
|
65
|
+
This package extracts and generalizes the data processing patterns from the [Life2Vec](https://github.com/SocialComplexityLab/life2vec) project, making them reusable for similar research projects that need to:
|
|
66
|
+
- Work with multiple longitudinal data sources (registries, databases)
|
|
67
|
+
- Define and filter cohorts based on complex criteria
|
|
68
|
+
- Generate realistic synthetic data for development and testing
|
|
69
|
+
- Process large-scale tabular event data efficiently
|
|
70
|
+
|
|
71
|
+
Whether you're working with healthcare data, financial records, or any time-stamped event data, tab2seq provides the building blocks for preparing data for Life2Vec-style sequential models.
|
|
72
|
+
|
|
73
|
+
## Features
|
|
74
|
+
|
|
75
|
+
- **Multi-Source Data Management**: Handle multiple data sources (registries) with unified schema
|
|
76
|
+
- **Type-Safe Configuration**: Pydantic-based configuration with YAML support
|
|
77
|
+
- **Synthetic Data Generation**: Generate realistic dummy registry data for testing and exploration
|
|
78
|
+
- **Memory-Efficient Loading**: Chunked iteration and lazy loading with Polars
|
|
79
|
+
- **Schema Validation**: Automatic validation of entity IDs, timestamps, and column types
|
|
80
|
+
- **Cross-Source Operations**: Unified access and operations across multiple data sources
|
|
81
|
+
|
|
82
|
+
## Installation
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# Basic installation
|
|
86
|
+
pip install tab2seq
|
|
87
|
+
|
|
88
|
+
# Development installation
|
|
89
|
+
pip install -e ".[dev]"
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Quick Start
|
|
93
|
+
|
|
94
|
+
### Working with Multiple Data Sources
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
from tab2seq.source import Source, SourceCollection, SourceConfig
|
|
98
|
+
|
|
99
|
+
# Define your data sources
|
|
100
|
+
configs = [
|
|
101
|
+
SourceConfig(
|
|
102
|
+
name="health",
|
|
103
|
+
filepath="data/health.parquet",
|
|
104
|
+
entity_id_col="patient_id",
|
|
105
|
+
timestamp_cols=["date"],
|
|
106
|
+
categorical_cols=["diagnosis", "procedure", "department"],
|
|
107
|
+
continuous_cols=["cost", "length_of_stay"],
|
|
108
|
+
),
|
|
109
|
+
SourceConfig(
|
|
110
|
+
name="income",
|
|
111
|
+
filepath="data/income.parquet",
|
|
112
|
+
entity_id_col="person_id",
|
|
113
|
+
timestamp_cols=["year"],
|
|
114
|
+
categorical_cols=["income_type", "sector"],
|
|
115
|
+
continuous_cols=["income_amount"],
|
|
116
|
+
),
|
|
117
|
+
]
|
|
118
|
+
|
|
119
|
+
# Create a source collection
|
|
120
|
+
collection = SourceCollection.from_configs(configs)
|
|
121
|
+
|
|
122
|
+
# Access individual sources
|
|
123
|
+
health = collection["health"]
|
|
124
|
+
df = health.read_all()
|
|
125
|
+
|
|
126
|
+
# Or iterate over all sources
|
|
127
|
+
for source in collection:
|
|
128
|
+
print(f"{source.name}: {len(source.get_entity_ids())} entities")
|
|
129
|
+
|
|
130
|
+
# Cross-source operations
|
|
131
|
+
all_entity_ids = collection.get_all_entity_ids()
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Generating Synthetic Data
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
from tab2seq.datasets import generate_synthetic_collections
|
|
138
|
+
|
|
139
|
+
# Generate synthetic registry data for testing
|
|
140
|
+
collection = generate_synthetic_collections(
|
|
141
|
+
output_dir="data/dummy",
|
|
142
|
+
n_entities=1000,
|
|
143
|
+
seed=42
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
# Returns a ready-to-use SourceCollection
|
|
147
|
+
health = collection["health"]
|
|
148
|
+
print(health.read_all().head())
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Architecture
|
|
152
|
+
|
|
153
|
+
> [!warning]
|
|
154
|
+
> Work in progress!
|
|
155
|
+
|
|
156
|
+
**Available Registries:**
|
|
157
|
+
|
|
158
|
+
- **health**: Medical events with diagnoses (ICD codes), procedures, departments, costs, and length of stay
|
|
159
|
+
- **income**: Yearly income records with income type, sector, and amounts
|
|
160
|
+
- **labour**: Quarterly labour status with occupation, employment status, and residence
|
|
161
|
+
- **survey**: Periodic survey responses with education level, marital status, and satisfaction scores
|
|
162
|
+
|
|
163
|
+
All synthetic data includes realistic temporal patterns, missing data, and correlations between fields to mimic real-world registry data.
|
|
164
|
+
|
|
165
|
+
## Use Cases
|
|
166
|
+
|
|
167
|
+
- **Healthcare Research**: Transform electronic health records (EHR) into sequences for predictive modeling
|
|
168
|
+
- **Registry Data Processing**: Work with multiple event-based registries (health, income, labour, surveys)
|
|
169
|
+
- **Sequential Modeling**: Prepare multi-source data for Life2Vec, BEHRT, or other transformer-based models
|
|
170
|
+
- **Data Pipeline Development**: Use synthetic data to develop and test processing pipelines before working with sensitive real data
|
|
171
|
+
- **Multi-Source Analysis**: Combine and analyze data from multiple longitudinal sources with unified tooling
|
|
172
|
+
|
|
173
|
+
## Development
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
# Install development dependencies
|
|
177
|
+
pip install -e ".[dev]"
|
|
178
|
+
|
|
179
|
+
# Run tests
|
|
180
|
+
pytest
|
|
181
|
+
|
|
182
|
+
# Run tests with coverage
|
|
183
|
+
pytest --cov=tab2seq --cov-report=html
|
|
184
|
+
|
|
185
|
+
# Format code
|
|
186
|
+
black src/tab2seq tests
|
|
187
|
+
|
|
188
|
+
# Lint code
|
|
189
|
+
ruff check src/tab2seq tests
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## TODOs
|
|
193
|
+
|
|
194
|
+
- [x] Synthetic Datasets
|
|
195
|
+
- [x] `Source` implementation
|
|
196
|
+
- [ ] `Cohort` implementation
|
|
197
|
+
- [ ] `Cohort` and data splits
|
|
198
|
+
- [ ] `Tokenization` implementation
|
|
199
|
+
- [ ] `Vocabulary` implementation
|
|
200
|
+
- [ ] Caching and chunking
|
|
201
|
+
|
|
202
|
+
## Citation
|
|
203
|
+
|
|
204
|
+
If you use this package in your research, please cite:
|
|
205
|
+
|
|
206
|
+
```bibtex
|
|
207
|
+
@software{tab2seq2024,
|
|
208
|
+
author = {Savcisens, Germans},
|
|
209
|
+
title = {tab2seq: Scalable Tabular to Sequential Data Processing},
|
|
210
|
+
year = {2024},
|
|
211
|
+
url = {https://github.com/carlomarxdk/tab2seq}
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
And the original Life2Vec paper that inspired this work:
|
|
216
|
+
|
|
217
|
+
```bibtex
|
|
218
|
+
@article{savcisens2024using,
|
|
219
|
+
title={Using sequences of life-events to predict human lives},
|
|
220
|
+
author={Savcisens, Germans and Eliassi-Rad, Tina and Hansen, Lars Kai and Mortensen, Laust Hvas and Lilleholt, Lau and Rogers, Anna and Zettler, Ingo and Lehmann, Sune},
|
|
221
|
+
journal={Nature computational science},
|
|
222
|
+
volume={4},
|
|
223
|
+
number={1},
|
|
224
|
+
pages={43--56},
|
|
225
|
+
year={2024},
|
|
226
|
+
publisher={Nature Publishing Group US New York}
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## Acknowledgments
|
|
231
|
+
|
|
232
|
+
- Inspired by the data processing pipeline from [Life2Vec](https://github.com/SocialComplexityLab/life2vec) and [Life2Vec-Light](https://github.com/SocialComplexityLab/life2vec-light)
|
|
233
|
+
- Built with [Polars](https://polars.rs/), [PyArrow](https://arrow.apache.org/docs/python/), [Pydantic](https://pydantic.dev/), and [Joblib](https://joblib.readthedocs.io/)
|
|
234
|
+
|
|
235
|
+
## Contributing
|
|
236
|
+
|
|
237
|
+
Contributions are welcome! Please open an issue or submit a pull request on [GitHub](https://github.com/carlomarxdk/tab2seq).
|
|
238
|
+
|
|
239
|
+
## License
|
|
240
|
+
|
|
241
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
242
|
+
|
|
243
|
+
## Support
|
|
244
|
+
|
|
245
|
+
- 🐛 Issues: [GitHub Issues](https://github.com/carlomarxdk/tab2seq/issues)
|
|
246
|
+
- 💬 Discussions: [GitHub Discussions](https://github.com/carlomarxdk/tab2seq/discussions)
|
tab2seq-0.1.1/README.md
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# tab2seq
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/tab2seq/)
|
|
4
|
+
[](https://pypi.org/project/tab2seq/)
|
|
5
|
+
[](https://pypi.org/project/tab2seq/)
|
|
6
|
+
[](https://github.com/carlomarxdk/tab2seq/blob/main/LICENSE)
|
|
7
|
+
|
|
8
|
+
**tab2seq** adapts the Life2Vec data processing pipeline to make it easy to work with multi-source tabular event data for sequential modeling projects. Transform registry data, EHR records, and other event-based datasets into formats ready for Transformer and sequential deep learning models.
|
|
9
|
+
|
|
10
|
+
> [!WARNING]
|
|
11
|
+
> This is an alpha package. In the beta version, it will reimplement all the data-preprocessing steps of the [life2vec](https://github.com/SocialComplexityLab/life2vec) and [life2vec-light](https://github.com/carlomarxdk/life2vec-light) repos. See [TODOs](#todos) to see what is implemented at this point.
|
|
12
|
+
|
|
13
|
+
## About
|
|
14
|
+
|
|
15
|
+
This package extracts and generalizes the data processing patterns from the [Life2Vec](https://github.com/SocialComplexityLab/life2vec) project, making them reusable for similar research projects that need to:
|
|
16
|
+
- Work with multiple longitudinal data sources (registries, databases)
|
|
17
|
+
- Define and filter cohorts based on complex criteria
|
|
18
|
+
- Generate realistic synthetic data for development and testing
|
|
19
|
+
- Process large-scale tabular event data efficiently
|
|
20
|
+
|
|
21
|
+
Whether you're working with healthcare data, financial records, or any time-stamped event data, tab2seq provides the building blocks for preparing data for Life2Vec-style sequential models.
|
|
22
|
+
|
|
23
|
+
## Features
|
|
24
|
+
|
|
25
|
+
- **Multi-Source Data Management**: Handle multiple data sources (registries) with unified schema
|
|
26
|
+
- **Type-Safe Configuration**: Pydantic-based configuration with YAML support
|
|
27
|
+
- **Synthetic Data Generation**: Generate realistic dummy registry data for testing and exploration
|
|
28
|
+
- **Memory-Efficient Loading**: Chunked iteration and lazy loading with Polars
|
|
29
|
+
- **Schema Validation**: Automatic validation of entity IDs, timestamps, and column types
|
|
30
|
+
- **Cross-Source Operations**: Unified access and operations across multiple data sources
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Basic installation
|
|
36
|
+
pip install tab2seq
|
|
37
|
+
|
|
38
|
+
# Development installation
|
|
39
|
+
pip install -e ".[dev]"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Quick Start
|
|
43
|
+
|
|
44
|
+
### Working with Multiple Data Sources
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from tab2seq.source import Source, SourceCollection, SourceConfig
|
|
48
|
+
|
|
49
|
+
# Define your data sources
|
|
50
|
+
configs = [
|
|
51
|
+
SourceConfig(
|
|
52
|
+
name="health",
|
|
53
|
+
filepath="data/health.parquet",
|
|
54
|
+
entity_id_col="patient_id",
|
|
55
|
+
timestamp_cols=["date"],
|
|
56
|
+
categorical_cols=["diagnosis", "procedure", "department"],
|
|
57
|
+
continuous_cols=["cost", "length_of_stay"],
|
|
58
|
+
),
|
|
59
|
+
SourceConfig(
|
|
60
|
+
name="income",
|
|
61
|
+
filepath="data/income.parquet",
|
|
62
|
+
entity_id_col="person_id",
|
|
63
|
+
timestamp_cols=["year"],
|
|
64
|
+
categorical_cols=["income_type", "sector"],
|
|
65
|
+
continuous_cols=["income_amount"],
|
|
66
|
+
),
|
|
67
|
+
]
|
|
68
|
+
|
|
69
|
+
# Create a source collection
|
|
70
|
+
collection = SourceCollection.from_configs(configs)
|
|
71
|
+
|
|
72
|
+
# Access individual sources
|
|
73
|
+
health = collection["health"]
|
|
74
|
+
df = health.read_all()
|
|
75
|
+
|
|
76
|
+
# Or iterate over all sources
|
|
77
|
+
for source in collection:
|
|
78
|
+
print(f"{source.name}: {len(source.get_entity_ids())} entities")
|
|
79
|
+
|
|
80
|
+
# Cross-source operations
|
|
81
|
+
all_entity_ids = collection.get_all_entity_ids()
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Generating Synthetic Data
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
from tab2seq.datasets import generate_synthetic_collections
|
|
88
|
+
|
|
89
|
+
# Generate synthetic registry data for testing
|
|
90
|
+
collection = generate_synthetic_collections(
|
|
91
|
+
output_dir="data/dummy",
|
|
92
|
+
n_entities=1000,
|
|
93
|
+
seed=42
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
# Returns a ready-to-use SourceCollection
|
|
97
|
+
health = collection["health"]
|
|
98
|
+
print(health.read_all().head())
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Architecture
|
|
102
|
+
|
|
103
|
+
> [!warning]
|
|
104
|
+
> Work in progress!
|
|
105
|
+
|
|
106
|
+
**Available Registries:**
|
|
107
|
+
|
|
108
|
+
- **health**: Medical events with diagnoses (ICD codes), procedures, departments, costs, and length of stay
|
|
109
|
+
- **income**: Yearly income records with income type, sector, and amounts
|
|
110
|
+
- **labour**: Quarterly labour status with occupation, employment status, and residence
|
|
111
|
+
- **survey**: Periodic survey responses with education level, marital status, and satisfaction scores
|
|
112
|
+
|
|
113
|
+
All synthetic data includes realistic temporal patterns, missing data, and correlations between fields to mimic real-world registry data.
|
|
114
|
+
|
|
115
|
+
## Use Cases
|
|
116
|
+
|
|
117
|
+
- **Healthcare Research**: Transform electronic health records (EHR) into sequences for predictive modeling
|
|
118
|
+
- **Registry Data Processing**: Work with multiple event-based registries (health, income, labour, surveys)
|
|
119
|
+
- **Sequential Modeling**: Prepare multi-source data for Life2Vec, BEHRT, or other transformer-based models
|
|
120
|
+
- **Data Pipeline Development**: Use synthetic data to develop and test processing pipelines before working with sensitive real data
|
|
121
|
+
- **Multi-Source Analysis**: Combine and analyze data from multiple longitudinal sources with unified tooling
|
|
122
|
+
|
|
123
|
+
## Development
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
# Install development dependencies
|
|
127
|
+
pip install -e ".[dev]"
|
|
128
|
+
|
|
129
|
+
# Run tests
|
|
130
|
+
pytest
|
|
131
|
+
|
|
132
|
+
# Run tests with coverage
|
|
133
|
+
pytest --cov=tab2seq --cov-report=html
|
|
134
|
+
|
|
135
|
+
# Format code
|
|
136
|
+
black src/tab2seq tests
|
|
137
|
+
|
|
138
|
+
# Lint code
|
|
139
|
+
ruff check src/tab2seq tests
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## TODOs
|
|
143
|
+
|
|
144
|
+
- [x] Synthetic Datasets
|
|
145
|
+
- [x] `Source` implementation
|
|
146
|
+
- [ ] `Cohort` implementation
|
|
147
|
+
- [ ] `Cohort` and data splits
|
|
148
|
+
- [ ] `Tokenization` implementation
|
|
149
|
+
- [ ] `Vocabulary` implementation
|
|
150
|
+
- [ ] Caching and chunking
|
|
151
|
+
|
|
152
|
+
## Citation
|
|
153
|
+
|
|
154
|
+
If you use this package in your research, please cite:
|
|
155
|
+
|
|
156
|
+
```bibtex
|
|
157
|
+
@software{tab2seq2024,
|
|
158
|
+
author = {Savcisens, Germans},
|
|
159
|
+
title = {tab2seq: Scalable Tabular to Sequential Data Processing},
|
|
160
|
+
year = {2024},
|
|
161
|
+
url = {https://github.com/carlomarxdk/tab2seq}
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
And the original Life2Vec paper that inspired this work:
|
|
166
|
+
|
|
167
|
+
```bibtex
|
|
168
|
+
@article{savcisens2024using,
|
|
169
|
+
title={Using sequences of life-events to predict human lives},
|
|
170
|
+
author={Savcisens, Germans and Eliassi-Rad, Tina and Hansen, Lars Kai and Mortensen, Laust Hvas and Lilleholt, Lau and Rogers, Anna and Zettler, Ingo and Lehmann, Sune},
|
|
171
|
+
journal={Nature computational science},
|
|
172
|
+
volume={4},
|
|
173
|
+
number={1},
|
|
174
|
+
pages={43--56},
|
|
175
|
+
year={2024},
|
|
176
|
+
publisher={Nature Publishing Group US New York}
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Acknowledgments
|
|
181
|
+
|
|
182
|
+
- Inspired by the data processing pipeline from [Life2Vec](https://github.com/SocialComplexityLab/life2vec) and [Life2Vec-Light](https://github.com/SocialComplexityLab/life2vec-light)
|
|
183
|
+
- Built with [Polars](https://polars.rs/), [PyArrow](https://arrow.apache.org/docs/python/), [Pydantic](https://pydantic.dev/), and [Joblib](https://joblib.readthedocs.io/)
|
|
184
|
+
|
|
185
|
+
## Contributing
|
|
186
|
+
|
|
187
|
+
Contributions are welcome! Please open an issue or submit a pull request on [GitHub](https://github.com/carlomarxdk/tab2seq).
|
|
188
|
+
|
|
189
|
+
## License
|
|
190
|
+
|
|
191
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
192
|
+
|
|
193
|
+
## Support
|
|
194
|
+
|
|
195
|
+
- 🐛 Issues: [GitHub Issues](https://github.com/carlomarxdk/tab2seq/issues)
|
|
196
|
+
- 💬 Discussions: [GitHub Discussions](https://github.com/carlomarxdk/tab2seq/discussions)
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=65.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "tab2seq"
|
|
7
|
+
version = "0.1.1"
|
|
8
|
+
description = "Transform tabular event data into sequences ready for Transformer and Sequential models: Life2Vec, BEHRT and more."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Germans Savcisens", email = "germans@savcisens.com"}
|
|
14
|
+
]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 3 - Alpha",
|
|
17
|
+
"Intended Audience :: Science/Research",
|
|
18
|
+
"License :: OSI Approved :: MIT License",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"Programming Language :: Python :: 3.12",
|
|
22
|
+
"Programming Language :: Python :: 3.13",
|
|
23
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
keywords = ["tokenization", "data preprocessing", "tabular data", "transformer models", "sequential models", "life2vec"]
|
|
27
|
+
|
|
28
|
+
dependencies = [
|
|
29
|
+
"numpy>=2.0.0",
|
|
30
|
+
"polars>=1.38.0,<2.0",
|
|
31
|
+
"pyarrow>=12.0.0",
|
|
32
|
+
"pydantic>=2.0.0",
|
|
33
|
+
"tqdm>=4.65.0",
|
|
34
|
+
"pyyaml>=6.0",
|
|
35
|
+
"click>=8.1.0",
|
|
36
|
+
"joblib>=1.3.0",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
[project.optional-dependencies]
|
|
40
|
+
dev = [
|
|
41
|
+
"pytest>=9.0.0",
|
|
42
|
+
"pytest-cov>=6.0.0",
|
|
43
|
+
"pytest-xdist>=3.5.0",
|
|
44
|
+
"ruff>=0.15.0",
|
|
45
|
+
"mypy>=1.19.0",
|
|
46
|
+
"types-PyYAML>=6.0.0",
|
|
47
|
+
]
|
|
48
|
+
docs = [
|
|
49
|
+
"mkdocs>=1.6.1",
|
|
50
|
+
"mkdocs-material>=9.7.1",
|
|
51
|
+
"mkdocstrings>=1.0.2",
|
|
52
|
+
"mkdocstrings-python>=2.0.0",
|
|
53
|
+
"mkdocs-gen-files>=0.6.0",
|
|
54
|
+
"mkdocs-literate-nav>=0.6.2",
|
|
55
|
+
"mkdocs-section-index>=0.3.10",
|
|
56
|
+
"mkdocs-bibtex>=4.4.0",
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
all = ["tab2seq[dev,docs]"]
|
|
60
|
+
|
|
61
|
+
[project.urls]
|
|
62
|
+
Homepage = "https://github.com/carlomarxdk/tab2seq"
|
|
63
|
+
Documentation = "https://tab2seq.readthedocs.io"
|
|
64
|
+
Repository = "https://github.com/carlomarxdk/tab2seq"
|
|
65
|
+
Issues = "https://github.com/carlomarxdk/tab2seq/issues"
|
|
66
|
+
|
|
67
|
+
[tool.setuptools.packages.find]
|
|
68
|
+
where = ["src"]
|
|
69
|
+
include = ["tab2seq*"]
|
|
70
|
+
|
|
71
|
+
[tool.pytest.ini_options]
|
|
72
|
+
testpaths = ["tests"]
|
|
73
|
+
python_files = ["test_*.py"]
|
|
74
|
+
python_classes = ["Test*"]
|
|
75
|
+
python_functions = ["test_*"]
|
|
76
|
+
addopts = [
|
|
77
|
+
"--strict-markers",
|
|
78
|
+
"--cov=tab2seq",
|
|
79
|
+
"--cov-report=term-missing",
|
|
80
|
+
"--cov-report=html",
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
[tool.ruff]
|
|
84
|
+
line-length = 88
|
|
85
|
+
target-version = "py311"
|
|
86
|
+
|
|
87
|
+
[tool.ruff.lint]
|
|
88
|
+
select = ["E", "F", "I", "N", "W", "D"]
|
|
89
|
+
ignore = ["D203", "D213"]
|
|
90
|
+
|
|
91
|
+
[tool.mypy]
|
|
92
|
+
python_version = "3.11"
|
|
93
|
+
warn_return_any = true
|
|
94
|
+
warn_unused_configs = true
|
|
95
|
+
disallow_untyped_defs = true
|
tab2seq-0.1.1/setup.cfg
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"""tab2seq - Transform tabular event data into sequences for transformer models."""
|
|
2
|
+
|
|
3
|
+
from importlib.metadata import version, PackageNotFoundError
|
|
4
|
+
|
|
5
|
+
try:
|
|
6
|
+
__version__ = version("tab2seq")
|
|
7
|
+
except PackageNotFoundError:
|
|
8
|
+
# Package not installed (e.g. running from source without pip install -e .)
|
|
9
|
+
__version__ = "unknown"
|