maya-encoding 0.1.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.
Files changed (47) hide show
  1. maya_encoding-0.1.0/.github/workflows/ci.yml +41 -0
  2. maya_encoding-0.1.0/.github/workflows/publish.yml +33 -0
  3. maya_encoding-0.1.0/.gitignore +20 -0
  4. maya_encoding-0.1.0/CHANGELOG.md +27 -0
  5. maya_encoding-0.1.0/CONTRIBUTING.md +41 -0
  6. maya_encoding-0.1.0/LICENSE +21 -0
  7. maya_encoding-0.1.0/PKG-INFO +213 -0
  8. maya_encoding-0.1.0/README.md +154 -0
  9. maya_encoding-0.1.0/benchmarks/results/.gitkeep +0 -0
  10. maya_encoding-0.1.0/benchmarks/run_mce_benchmarks.py +293 -0
  11. maya_encoding-0.1.0/benchmarks/run_vfd_benchmarks.py +275 -0
  12. maya_encoding-0.1.0/docs/api/core.md +27 -0
  13. maya_encoding-0.1.0/docs/api/mce.md +10 -0
  14. maya_encoding-0.1.0/docs/api/vfd.md +11 -0
  15. maya_encoding-0.1.0/docs/changelog.md +27 -0
  16. maya_encoding-0.1.0/docs/contributing.md +22 -0
  17. maya_encoding-0.1.0/docs/getting-started.md +119 -0
  18. maya_encoding-0.1.0/docs/guide/mce.md +101 -0
  19. maya_encoding-0.1.0/docs/guide/vfd.md +81 -0
  20. maya_encoding-0.1.0/docs/guide/visualization.md +39 -0
  21. maya_encoding-0.1.0/docs/index.md +51 -0
  22. maya_encoding-0.1.0/docs/math-background.md +87 -0
  23. maya_encoding-0.1.0/examples/01_quickstart.ipynb +257 -0
  24. maya_encoding-0.1.0/examples/02_vfd_deep_dive.ipynb +232 -0
  25. maya_encoding-0.1.0/examples/03_mce_temporal.ipynb +267 -0
  26. maya_encoding-0.1.0/examples/04_benchmark_results.ipynb +243 -0
  27. maya_encoding-0.1.0/mkdocs.yml +70 -0
  28. maya_encoding-0.1.0/pyproject.toml +93 -0
  29. maya_encoding-0.1.0/setup_github.sh +455 -0
  30. maya_encoding-0.1.0/src/maya_encoding/__init__.py +20 -0
  31. maya_encoding-0.1.0/src/maya_encoding/_version.py +3 -0
  32. maya_encoding-0.1.0/src/maya_encoding/core/__init__.py +1 -0
  33. maya_encoding-0.1.0/src/maya_encoding/core/calendar.py +516 -0
  34. maya_encoding-0.1.0/src/maya_encoding/core/utils.py +237 -0
  35. maya_encoding-0.1.0/src/maya_encoding/core/vigesimal.py +286 -0
  36. maya_encoding-0.1.0/src/maya_encoding/mce/__init__.py +5 -0
  37. maya_encoding-0.1.0/src/maya_encoding/mce/encoder.py +403 -0
  38. maya_encoding-0.1.0/src/maya_encoding/vfd/__init__.py +5 -0
  39. maya_encoding-0.1.0/src/maya_encoding/vfd/encoder.py +395 -0
  40. maya_encoding-0.1.0/src/maya_encoding/visualization/__init__.py +1 -0
  41. maya_encoding-0.1.0/src/maya_encoding/visualization/glyphs.py +205 -0
  42. maya_encoding-0.1.0/tests/__init__.py +0 -0
  43. maya_encoding-0.1.0/tests/test_calendar.py +189 -0
  44. maya_encoding-0.1.0/tests/test_mce_encoder.py +228 -0
  45. maya_encoding-0.1.0/tests/test_sklearn_compat.py +64 -0
  46. maya_encoding-0.1.0/tests/test_vfd_encoder.py +190 -0
  47. maya_encoding-0.1.0/tests/test_vigesimal.py +181 -0
@@ -0,0 +1,41 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.9", "3.10", "3.11", "3.12"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - name: Set up Python ${{ matrix.python-version }}
20
+ uses: actions/setup-python@v5
21
+ with:
22
+ python-version: ${{ matrix.python-version }}
23
+
24
+ - name: Install dependencies
25
+ run: |
26
+ python -m pip install --upgrade pip
27
+ pip install -e ".[dev]"
28
+
29
+ - name: Lint with ruff
30
+ run: |
31
+ ruff check src/ tests/
32
+
33
+ - name: Run tests
34
+ run: |
35
+ pytest tests/ -v --cov=maya_encoding --cov-report=xml
36
+
37
+ - name: Upload coverage
38
+ if: matrix.python-version == '3.11'
39
+ uses: codecov/codecov-action@v4
40
+ with:
41
+ file: ./coverage.xml
@@ -0,0 +1,33 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ permissions:
9
+ id-token: write
10
+
11
+ jobs:
12
+ publish:
13
+ runs-on: ubuntu-latest
14
+ environment: pypi
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - name: Set up Python
20
+ uses: actions/setup-python@v5
21
+ with:
22
+ python-version: "3.11"
23
+
24
+ - name: Install build tools
25
+ run: |
26
+ python -m pip install --upgrade pip
27
+ pip install build
28
+
29
+ - name: Build package
30
+ run: python -m build
31
+
32
+ - name: Publish to PyPI
33
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,20 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *$py.class
4
+ *.egg-info/
5
+ dist/
6
+ build/
7
+ *.egg
8
+ .eggs/
9
+ .pytest_cache/
10
+ .ruff_cache/
11
+ .mypy_cache/
12
+ htmlcov/
13
+ coverage.xml
14
+ .coverage
15
+ *.so
16
+ .env
17
+ .venv/
18
+ venv/
19
+ *.ipynb_checkpoints/
20
+ benchmarks/results/*.json
@@ -0,0 +1,27 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## [0.1.0] - 2026-03-12
6
+
7
+ ### Added
8
+ - `VFDEncoder`: Vigesimal Feature Decomposition for numeric features
9
+ - Full, lite, and bars_dots component modes
10
+ - Automatic level detection and scale factor inference
11
+ - Negative and float handling strategies
12
+ - sklearn pipeline compatible (fit/transform/inverse_transform)
13
+ - `MayaCalendarEncoder`: Maya Calendar Encoding for temporal features
14
+ - Tzolk'in (260-day), Haab' (365-day), and Long Count components
15
+ - Hierarchical and flat encoding modes
16
+ - Optional sine/cosine cyclical encoding
17
+ - GMT and custom epoch support
18
+ - Wayeb' period detection
19
+ - Core mathematical functions
20
+ - Vigesimal number system (encode/decode/decompose)
21
+ - Maya calendar conversions (Gregorian to Tzolk'in, Haab', Long Count)
22
+ - Vectorized operations with numpy
23
+ - Visualization
24
+ - `plot_maya_number()`: Render numbers as Maya glyphs
25
+ - `render_maya_text()`: Text-based Maya numeral representation
26
+ - Benchmark suite comparing VFD and MCE against baseline encodings
27
+ - Full test suite with >90% coverage
@@ -0,0 +1,41 @@
1
+ # Contributing to maya-encoding
2
+
3
+ Thank you for your interest in contributing!
4
+
5
+ ## Development Setup
6
+
7
+ ```bash
8
+ git clone https://github.com/danielregalado/maya-encoding.git
9
+ cd maya-encoding
10
+ pip install -e ".[dev]"
11
+ ```
12
+
13
+ ## Running Tests
14
+
15
+ ```bash
16
+ pytest tests/ -v
17
+ ```
18
+
19
+ ## Code Style
20
+
21
+ We use `ruff` for linting:
22
+
23
+ ```bash
24
+ ruff check src/ tests/
25
+ ruff format src/ tests/
26
+ ```
27
+
28
+ ## Pull Requests
29
+
30
+ 1. Fork the repository
31
+ 2. Create a feature branch (`git checkout -b feature/my-feature`)
32
+ 3. Write tests for your changes
33
+ 4. Ensure all tests pass
34
+ 5. Submit a pull request
35
+
36
+ ## Reporting Issues
37
+
38
+ Please use GitHub Issues and include:
39
+ - Python version
40
+ - maya-encoding version
41
+ - Minimal reproducible example
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Daniel Regalado
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,213 @@
1
+ Metadata-Version: 2.4
2
+ Name: maya-encoding
3
+ Version: 0.1.0
4
+ Summary: Maya-inspired numerical encodings for machine learning: Vigesimal Feature Decomposition (VFD) and Maya Calendar Encoding (MCE)
5
+ Project-URL: Homepage, https://github.com/danielregalado/maya-encoding
6
+ Project-URL: Documentation, https://danielregalado.github.io/maya-encoding
7
+ Project-URL: Repository, https://github.com/danielregalado/maya-encoding
8
+ Project-URL: Issues, https://github.com/danielregalado/maya-encoding/issues
9
+ Author-email: Daniel Regalado <dxr1491@miami.edu>
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: calendar,encoding,feature-engineering,machine-learning,maya,scikit-learn,time-series,vigesimal
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
23
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
24
+ Requires-Python: >=3.9
25
+ Requires-Dist: numpy>=1.21
26
+ Requires-Dist: scikit-learn>=1.0
27
+ Provides-Extra: all
28
+ Requires-Dist: matplotlib>=3.5; extra == 'all'
29
+ Requires-Dist: mkdocs; extra == 'all'
30
+ Requires-Dist: mkdocs-material; extra == 'all'
31
+ Requires-Dist: mkdocstrings[python]; extra == 'all'
32
+ Requires-Dist: mypy; extra == 'all'
33
+ Requires-Dist: pandas>=1.3; extra == 'all'
34
+ Requires-Dist: pytest-cov; extra == 'all'
35
+ Requires-Dist: pytest>=7.0; extra == 'all'
36
+ Requires-Dist: ruff; extra == 'all'
37
+ Requires-Dist: scipy>=1.7; extra == 'all'
38
+ Requires-Dist: seaborn>=0.12; extra == 'all'
39
+ Requires-Dist: xgboost>=1.5; extra == 'all'
40
+ Provides-Extra: benchmarks
41
+ Requires-Dist: pandas>=1.3; extra == 'benchmarks'
42
+ Requires-Dist: scipy>=1.7; extra == 'benchmarks'
43
+ Requires-Dist: seaborn>=0.12; extra == 'benchmarks'
44
+ Requires-Dist: xgboost>=1.5; extra == 'benchmarks'
45
+ Provides-Extra: dev
46
+ Requires-Dist: matplotlib>=3.5; extra == 'dev'
47
+ Requires-Dist: mypy; extra == 'dev'
48
+ Requires-Dist: pandas>=1.3; extra == 'dev'
49
+ Requires-Dist: pytest-cov; extra == 'dev'
50
+ Requires-Dist: pytest>=7.0; extra == 'dev'
51
+ Requires-Dist: ruff; extra == 'dev'
52
+ Provides-Extra: docs
53
+ Requires-Dist: mkdocs; extra == 'docs'
54
+ Requires-Dist: mkdocs-material; extra == 'docs'
55
+ Requires-Dist: mkdocstrings[python]; extra == 'docs'
56
+ Provides-Extra: viz
57
+ Requires-Dist: matplotlib>=3.5; extra == 'viz'
58
+ Description-Content-Type: text/markdown
59
+
60
+ # maya-encoding
61
+
62
+ [![CI](https://github.com/danielregalado/maya-encoding/actions/workflows/ci.yml/badge.svg)](https://github.com/danielregalado/maya-encoding/actions/workflows/ci.yml)
63
+ [![PyPI version](https://badge.fury.io/py/maya-encoding.svg)](https://badge.fury.io/py/maya-encoding)
64
+ [![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
65
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
66
+
67
+ **Maya-inspired numerical encodings for machine learning.**
68
+
69
+ Two sklearn-compatible transformers that use the mathematical structure of the ancient Maya number system and calendar to create richer feature representations:
70
+
71
+ - **VFDEncoder** (Vigesimal Feature Decomposition) — Decomposes numbers into the Maya base-20 system with bars (÷5) and dots (%5), giving models multi-scale numerical structure for free.
72
+ - **MayaCalendarEncoder** (Maya Calendar Encoding) — Converts dates into features from the Tzolk'in (260-day), Haab' (365-day), and Long Count calendars, providing interlocking cyclical patterns at multiple time scales.
73
+
74
+ ## Installation
75
+
76
+ ```bash
77
+ pip install maya-encoding
78
+ ```
79
+
80
+ With visualization support:
81
+ ```bash
82
+ pip install maya-encoding[viz]
83
+ ```
84
+
85
+ ## Quick Start
86
+
87
+ ### VFD: Numeric Feature Encoding
88
+
89
+ ```python
90
+ from maya_encoding import VFDEncoder
91
+ from sklearn.pipeline import Pipeline
92
+ from sklearn.ensemble import RandomForestRegressor
93
+
94
+ # VFD decomposes numbers into vigesimal digits, bars, and dots
95
+ encoder = VFDEncoder(components='full')
96
+
97
+ # Works seamlessly in sklearn pipelines
98
+ pipe = Pipeline([
99
+ ('encode', VFDEncoder()),
100
+ ('model', RandomForestRegressor())
101
+ ])
102
+ pipe.fit(X_train, y_train)
103
+ ```
104
+
105
+ How it works: the number **347** becomes:
106
+ ```
107
+ 347 = 17×20 + 7
108
+
109
+ Level 0 (ones): digit=7, bars=1, dots=2
110
+ Level 1 (twenties): digit=17, bars=3, dots=2
111
+
112
+ Feature vector: [7, 1, 2, 17, 3, 2] (or normalized to [0,1])
113
+ ```
114
+
115
+ This gives the model three "zoom levels" per number — coarse magnitude (digits), medium grouping (bars), and fine residual (dots).
116
+
117
+ ### MCE: Temporal Feature Encoding
118
+
119
+ ```python
120
+ from maya_encoding import MayaCalendarEncoder
121
+
122
+ # Encode dates using Maya calendar cycles
123
+ encoder = MayaCalendarEncoder(
124
+ components=['tzolkin', 'haab', 'long_count'],
125
+ cyclical=True, # Add sine/cosine for smooth cycle boundaries
126
+ )
127
+
128
+ X_temporal = encoder.fit_transform(df['date'])
129
+ ```
130
+
131
+ The Maya calendar provides interlocking cycles of coprime periods (13, 20, 260, 365, 360), capturing multi-scale temporal patterns that standard sine/cosine encoding requires manual period selection to achieve.
132
+
133
+ ## Why Maya Encoding?
134
+
135
+ **The problem:** When you feed a number like "347" to a model, it knows nothing about its structure. It has to learn from scratch that 347 is close to 350, "large" compared to 5, and divisible in certain ways.
136
+
137
+ **The solution:** The Maya vigesimal system naturally decomposes numbers into a hierarchy:
138
+ - **Vigesimal digits** (×20): coarse magnitude
139
+ - **Bars** (×5): medium grouping
140
+ - **Dots** (×1): fine residual
141
+
142
+ This is a strict information superset — the model can ignore the extra features via regularization if they're not useful, but gets multi-scale structure for free if they are.
143
+
144
+ For temporal data, the Maya calendar's three interlocking cycles (Tzolk'in 260-day, Haab' 365-day, Long Count) provide coprime-period features that capture patterns standard time encodings miss.
145
+
146
+ ## API Reference
147
+
148
+ ### VFDEncoder
149
+
150
+ | Parameter | Default | Description |
151
+ |-----------|---------|-------------|
152
+ | `n_levels` | `'auto'` | Vigesimal levels (auto-detected from data) |
153
+ | `components` | `'full'` | `'full'`, `'lite'` (digits only), `'bars_dots'` |
154
+ | `normalize` | `True` | Normalize to [0,1] |
155
+ | `handle_negative` | `'abs_sign'` | `'abs_sign'`, `'shift'`, `'error'` |
156
+ | `handle_float` | `'scale'` | `'scale'`, `'round'`, `'integer_part'` |
157
+ | `scale_factor` | `'auto'` | Auto-detected from decimal precision |
158
+
159
+ ### MayaCalendarEncoder
160
+
161
+ | Parameter | Default | Description |
162
+ |-----------|---------|-------------|
163
+ | `components` | `['tzolkin', 'haab', 'long_count']` | Calendar systems to use |
164
+ | `tzolkin_encoding` | `'separate'` | `'separate'` (2 features) or `'combined'` (1 feature) |
165
+ | `haab_encoding` | `'hierarchical'` | `'hierarchical'` (with bars/dots) or `'flat'` |
166
+ | `long_count_levels` | `3` | 1-5: kin, uinal, tun, katun, baktun |
167
+ | `cyclical` | `True` | Add sine/cosine pairs |
168
+ | `epoch` | `'gmt'` | `'gmt'` (standard), `'spinden'`, or custom JDN |
169
+ | `wayeb_flag` | `True` | Binary feature for the 5-day Wayeb' period |
170
+
171
+ ## Visualization
172
+
173
+ ```python
174
+ from maya_encoding.visualization.glyphs import plot_maya_number, render_maya_text
175
+
176
+ # Text rendering
177
+ print(render_maya_text(347))
178
+
179
+ # Matplotlib rendering
180
+ plot_maya_number(347)
181
+ ```
182
+
183
+ ## Development
184
+
185
+ ```bash
186
+ git clone https://github.com/danielregalado/maya-encoding.git
187
+ cd maya-encoding
188
+ pip install -e ".[dev]"
189
+ pytest
190
+ ```
191
+
192
+ Run benchmarks:
193
+ ```bash
194
+ python benchmarks/run_vfd_benchmarks.py
195
+ python benchmarks/run_mce_benchmarks.py
196
+ ```
197
+
198
+ ## Citation
199
+
200
+ If you use maya-encoding in your research, please cite:
201
+
202
+ ```bibtex
203
+ @software{regalado2026maya,
204
+ author = {Regalado, Daniel},
205
+ title = {maya-encoding: Maya-Inspired Numerical Encodings for Machine Learning},
206
+ year = {2026},
207
+ url = {https://github.com/danielregalado/maya-encoding}
208
+ }
209
+ ```
210
+
211
+ ## License
212
+
213
+ MIT License. See [LICENSE](LICENSE) for details.
@@ -0,0 +1,154 @@
1
+ # maya-encoding
2
+
3
+ [![CI](https://github.com/danielregalado/maya-encoding/actions/workflows/ci.yml/badge.svg)](https://github.com/danielregalado/maya-encoding/actions/workflows/ci.yml)
4
+ [![PyPI version](https://badge.fury.io/py/maya-encoding.svg)](https://badge.fury.io/py/maya-encoding)
5
+ [![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ **Maya-inspired numerical encodings for machine learning.**
9
+
10
+ Two sklearn-compatible transformers that use the mathematical structure of the ancient Maya number system and calendar to create richer feature representations:
11
+
12
+ - **VFDEncoder** (Vigesimal Feature Decomposition) — Decomposes numbers into the Maya base-20 system with bars (÷5) and dots (%5), giving models multi-scale numerical structure for free.
13
+ - **MayaCalendarEncoder** (Maya Calendar Encoding) — Converts dates into features from the Tzolk'in (260-day), Haab' (365-day), and Long Count calendars, providing interlocking cyclical patterns at multiple time scales.
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ pip install maya-encoding
19
+ ```
20
+
21
+ With visualization support:
22
+ ```bash
23
+ pip install maya-encoding[viz]
24
+ ```
25
+
26
+ ## Quick Start
27
+
28
+ ### VFD: Numeric Feature Encoding
29
+
30
+ ```python
31
+ from maya_encoding import VFDEncoder
32
+ from sklearn.pipeline import Pipeline
33
+ from sklearn.ensemble import RandomForestRegressor
34
+
35
+ # VFD decomposes numbers into vigesimal digits, bars, and dots
36
+ encoder = VFDEncoder(components='full')
37
+
38
+ # Works seamlessly in sklearn pipelines
39
+ pipe = Pipeline([
40
+ ('encode', VFDEncoder()),
41
+ ('model', RandomForestRegressor())
42
+ ])
43
+ pipe.fit(X_train, y_train)
44
+ ```
45
+
46
+ How it works: the number **347** becomes:
47
+ ```
48
+ 347 = 17×20 + 7
49
+
50
+ Level 0 (ones): digit=7, bars=1, dots=2
51
+ Level 1 (twenties): digit=17, bars=3, dots=2
52
+
53
+ Feature vector: [7, 1, 2, 17, 3, 2] (or normalized to [0,1])
54
+ ```
55
+
56
+ This gives the model three "zoom levels" per number — coarse magnitude (digits), medium grouping (bars), and fine residual (dots).
57
+
58
+ ### MCE: Temporal Feature Encoding
59
+
60
+ ```python
61
+ from maya_encoding import MayaCalendarEncoder
62
+
63
+ # Encode dates using Maya calendar cycles
64
+ encoder = MayaCalendarEncoder(
65
+ components=['tzolkin', 'haab', 'long_count'],
66
+ cyclical=True, # Add sine/cosine for smooth cycle boundaries
67
+ )
68
+
69
+ X_temporal = encoder.fit_transform(df['date'])
70
+ ```
71
+
72
+ The Maya calendar provides interlocking cycles of coprime periods (13, 20, 260, 365, 360), capturing multi-scale temporal patterns that standard sine/cosine encoding requires manual period selection to achieve.
73
+
74
+ ## Why Maya Encoding?
75
+
76
+ **The problem:** When you feed a number like "347" to a model, it knows nothing about its structure. It has to learn from scratch that 347 is close to 350, "large" compared to 5, and divisible in certain ways.
77
+
78
+ **The solution:** The Maya vigesimal system naturally decomposes numbers into a hierarchy:
79
+ - **Vigesimal digits** (×20): coarse magnitude
80
+ - **Bars** (×5): medium grouping
81
+ - **Dots** (×1): fine residual
82
+
83
+ This is a strict information superset — the model can ignore the extra features via regularization if they're not useful, but gets multi-scale structure for free if they are.
84
+
85
+ For temporal data, the Maya calendar's three interlocking cycles (Tzolk'in 260-day, Haab' 365-day, Long Count) provide coprime-period features that capture patterns standard time encodings miss.
86
+
87
+ ## API Reference
88
+
89
+ ### VFDEncoder
90
+
91
+ | Parameter | Default | Description |
92
+ |-----------|---------|-------------|
93
+ | `n_levels` | `'auto'` | Vigesimal levels (auto-detected from data) |
94
+ | `components` | `'full'` | `'full'`, `'lite'` (digits only), `'bars_dots'` |
95
+ | `normalize` | `True` | Normalize to [0,1] |
96
+ | `handle_negative` | `'abs_sign'` | `'abs_sign'`, `'shift'`, `'error'` |
97
+ | `handle_float` | `'scale'` | `'scale'`, `'round'`, `'integer_part'` |
98
+ | `scale_factor` | `'auto'` | Auto-detected from decimal precision |
99
+
100
+ ### MayaCalendarEncoder
101
+
102
+ | Parameter | Default | Description |
103
+ |-----------|---------|-------------|
104
+ | `components` | `['tzolkin', 'haab', 'long_count']` | Calendar systems to use |
105
+ | `tzolkin_encoding` | `'separate'` | `'separate'` (2 features) or `'combined'` (1 feature) |
106
+ | `haab_encoding` | `'hierarchical'` | `'hierarchical'` (with bars/dots) or `'flat'` |
107
+ | `long_count_levels` | `3` | 1-5: kin, uinal, tun, katun, baktun |
108
+ | `cyclical` | `True` | Add sine/cosine pairs |
109
+ | `epoch` | `'gmt'` | `'gmt'` (standard), `'spinden'`, or custom JDN |
110
+ | `wayeb_flag` | `True` | Binary feature for the 5-day Wayeb' period |
111
+
112
+ ## Visualization
113
+
114
+ ```python
115
+ from maya_encoding.visualization.glyphs import plot_maya_number, render_maya_text
116
+
117
+ # Text rendering
118
+ print(render_maya_text(347))
119
+
120
+ # Matplotlib rendering
121
+ plot_maya_number(347)
122
+ ```
123
+
124
+ ## Development
125
+
126
+ ```bash
127
+ git clone https://github.com/danielregalado/maya-encoding.git
128
+ cd maya-encoding
129
+ pip install -e ".[dev]"
130
+ pytest
131
+ ```
132
+
133
+ Run benchmarks:
134
+ ```bash
135
+ python benchmarks/run_vfd_benchmarks.py
136
+ python benchmarks/run_mce_benchmarks.py
137
+ ```
138
+
139
+ ## Citation
140
+
141
+ If you use maya-encoding in your research, please cite:
142
+
143
+ ```bibtex
144
+ @software{regalado2026maya,
145
+ author = {Regalado, Daniel},
146
+ title = {maya-encoding: Maya-Inspired Numerical Encodings for Machine Learning},
147
+ year = {2026},
148
+ url = {https://github.com/danielregalado/maya-encoding}
149
+ }
150
+ ```
151
+
152
+ ## License
153
+
154
+ MIT License. See [LICENSE](LICENSE) for details.
File without changes