ashlar-tabular 0.0.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.
- ashlar_tabular-0.0.1/.github/workflows/build.yml +26 -0
- ashlar_tabular-0.0.1/.github/workflows/publish.yml +36 -0
- ashlar_tabular-0.0.1/.github/workflows/tests.yml +18 -0
- ashlar_tabular-0.0.1/.gitignore +10 -0
- ashlar_tabular-0.0.1/LICENSE +202 -0
- ashlar_tabular-0.0.1/MANIFEST.in +11 -0
- ashlar_tabular-0.0.1/PKG-INFO +243 -0
- ashlar_tabular-0.0.1/README.md +208 -0
- ashlar_tabular-0.0.1/docs/benchmarks.md +357 -0
- ashlar_tabular-0.0.1/docs/forecast.md +74 -0
- ashlar_tabular-0.0.1/docs/heads.md +72 -0
- ashlar_tabular-0.0.1/docs/images/categorical-embeddings.png +0 -0
- ashlar_tabular-0.0.1/docs/images/distributional-head.png +0 -0
- ashlar_tabular-0.0.1/docs/images/fare-heads.png +0 -0
- ashlar_tabular-0.0.1/docs/images/forecast-fan.png +0 -0
- ashlar_tabular-0.0.1/docs/images/forecast-path.png +0 -0
- ashlar_tabular-0.0.1/docs/images/histogram-bins.png +0 -0
- ashlar_tabular-0.0.1/docs/images/mixture-density.png +0 -0
- ashlar_tabular-0.0.1/docs/images/ordinal-score.png +0 -0
- ashlar_tabular-0.0.1/docs/images/outcome-embeddings.png +0 -0
- ashlar_tabular-0.0.1/docs/images/outcome-tree.png +0 -0
- ashlar_tabular-0.0.1/docs/images/quantile-forecast.png +0 -0
- ashlar_tabular-0.0.1/docs/images/tabular-fit.png +0 -0
- ashlar_tabular-0.0.1/docs/images/tabular-path.png +0 -0
- ashlar_tabular-0.0.1/docs/images/taxi-zones.png +0 -0
- ashlar_tabular-0.0.1/docs/images/tip-heads.png +0 -0
- ashlar_tabular-0.0.1/docs/models.md +61 -0
- ashlar_tabular-0.0.1/docs/tabular.md +128 -0
- ashlar_tabular-0.0.1/examples/ablation_gbm_parity.py +158 -0
- ashlar_tabular-0.0.1/examples/advanced.py +83 -0
- ashlar_tabular-0.0.1/examples/architecture.py +248 -0
- ashlar_tabular-0.0.1/examples/benchmark.py +255 -0
- ashlar_tabular-0.0.1/examples/benchmark_abalone_ordinal.py +66 -0
- ashlar_tabular-0.0.1/examples/benchmark_clear.py +201 -0
- ashlar_tabular-0.0.1/examples/benchmark_coverage.py +710 -0
- ashlar_tabular-0.0.1/examples/benchmark_extra_regression.py +229 -0
- ashlar_tabular-0.0.1/examples/benchmark_forecast.py +394 -0
- ashlar_tabular-0.0.1/examples/benchmark_gradient_categorical.py +397 -0
- ashlar_tabular-0.0.1/examples/benchmark_gradient_more.py +274 -0
- ashlar_tabular-0.0.1/examples/benchmark_gradient_multiclass.py +303 -0
- ashlar_tabular-0.0.1/examples/benchmark_gradient_multiclass_more.py +332 -0
- ashlar_tabular-0.0.1/examples/benchmark_gradient_suite.py +398 -0
- ashlar_tabular-0.0.1/examples/benchmark_horizon.py +125 -0
- ashlar_tabular-0.0.1/examples/benchmark_large.py +603 -0
- ashlar_tabular-0.0.1/examples/benchmark_lr_embed.py +93 -0
- ashlar_tabular-0.0.1/examples/benchmark_node.py +146 -0
- ashlar_tabular-0.0.1/examples/benchmark_outcome_tree.py +492 -0
- ashlar_tabular-0.0.1/examples/benchmark_priors.py +144 -0
- ashlar_tabular-0.0.1/examples/benchmark_readme.py +628 -0
- ashlar_tabular-0.0.1/examples/benchmark_rounds.py +168 -0
- ashlar_tabular-0.0.1/examples/benchmark_scaling_sweep.py +111 -0
- ashlar_tabular-0.0.1/examples/benchmark_tabm_borrow.py +99 -0
- ashlar_tabular-0.0.1/examples/benchmark_tabm_classification.py +150 -0
- ashlar_tabular-0.0.1/examples/benchmark_tabm_d_seeds.py +150 -0
- ashlar_tabular-0.0.1/examples/benchmark_tabm_seeds.py +171 -0
- ashlar_tabular-0.0.1/examples/benchmark_tabm_unshared.py +74 -0
- ashlar_tabular-0.0.1/examples/benchmark_torch.py +232 -0
- ashlar_tabular-0.0.1/examples/benchmark_wine_ordinal.py +461 -0
- ashlar_tabular-0.0.1/examples/classifier.py +84 -0
- ashlar_tabular-0.0.1/examples/distributional_probe.py +158 -0
- ashlar_tabular-0.0.1/examples/embeddings.py +56 -0
- ashlar_tabular-0.0.1/examples/figures.py +984 -0
- ashlar_tabular-0.0.1/examples/jax_composition.py +89 -0
- ashlar_tabular-0.0.1/examples/logo.py +151 -0
- ashlar_tabular-0.0.1/examples/ordinal.py +43 -0
- ashlar_tabular-0.0.1/examples/ordinary.py +76 -0
- ashlar_tabular-0.0.1/examples/readme_figures.py +577 -0
- ashlar_tabular-0.0.1/examples/search.py +63 -0
- ashlar_tabular-0.0.1/examples/table_heads.py +94 -0
- ashlar_tabular-0.0.1/examples/transformer.py +71 -0
- ashlar_tabular-0.0.1/pyproject.toml +51 -0
- ashlar_tabular-0.0.1/setup.cfg +4 -0
- ashlar_tabular-0.0.1/src/ashlar/__init__.py +100 -0
- ashlar_tabular-0.0.1/src/ashlar/_compat.py +17 -0
- ashlar_tabular-0.0.1/src/ashlar/_version.py +1 -0
- ashlar_tabular-0.0.1/src/ashlar/additive.py +1185 -0
- ashlar_tabular-0.0.1/src/ashlar/core.py +110 -0
- ashlar_tabular-0.0.1/src/ashlar/demos/__init__.py +1 -0
- ashlar_tabular-0.0.1/src/ashlar/demos/linked.py +61 -0
- ashlar_tabular-0.0.1/src/ashlar/distributional.py +533 -0
- ashlar_tabular-0.0.1/src/ashlar/errors.py +13 -0
- ashlar_tabular-0.0.1/src/ashlar/estimator.py +1889 -0
- ashlar_tabular-0.0.1/src/ashlar/forecast.py +1314 -0
- ashlar_tabular-0.0.1/src/ashlar/heads.py +244 -0
- ashlar_tabular-0.0.1/src/ashlar/io.py +64 -0
- ashlar_tabular-0.0.1/src/ashlar/layers.py +785 -0
- ashlar_tabular-0.0.1/src/ashlar/node.py +422 -0
- ashlar_tabular-0.0.1/src/ashlar/objectives.py +288 -0
- ashlar_tabular-0.0.1/src/ashlar/predict.py +154 -0
- ashlar_tabular-0.0.1/src/ashlar/preprocess.py +582 -0
- ashlar_tabular-0.0.1/src/ashlar/priors.py +1208 -0
- ashlar_tabular-0.0.1/src/ashlar/recipes.py +247 -0
- ashlar_tabular-0.0.1/src/ashlar/rounds.py +797 -0
- ashlar_tabular-0.0.1/src/ashlar/search.py +77 -0
- ashlar_tabular-0.0.1/src/ashlar/train.py +558 -0
- ashlar_tabular-0.0.1/src/ashlar/tree.py +288 -0
- ashlar_tabular-0.0.1/src/ashlar/weights.py +97 -0
- ashlar_tabular-0.0.1/src/ashlar_tabular.egg-info/SOURCES.txt +107 -0
- ashlar_tabular-0.0.1/tests/conftest.py +5 -0
- ashlar_tabular-0.0.1/tests/test_additive.py +145 -0
- ashlar_tabular-0.0.1/tests/test_distributional.py +325 -0
- ashlar_tabular-0.0.1/tests/test_estimator.py +1119 -0
- ashlar_tabular-0.0.1/tests/test_forecast.py +186 -0
- ashlar_tabular-0.0.1/tests/test_gbm_parity.py +134 -0
- ashlar_tabular-0.0.1/tests/test_names.py +91 -0
- ashlar_tabular-0.0.1/tests/test_node.py +63 -0
- ashlar_tabular-0.0.1/tests/test_priors.py +245 -0
- ashlar_tabular-0.0.1/tests/test_rounds.py +99 -0
- ashlar_tabular-0.0.1/tests/test_semantics.py +124 -0
- ashlar_tabular-0.0.1/tests/test_tree.py +141 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
name: build
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
pull_request:
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
dist:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v4
|
|
12
|
+
- uses: actions/setup-python@v5
|
|
13
|
+
with:
|
|
14
|
+
python-version: "3.12"
|
|
15
|
+
- run: python -m pip install build twine
|
|
16
|
+
- run: python -m build
|
|
17
|
+
- run: twine check --strict dist/*
|
|
18
|
+
- name: Install the wheel in a clean venv and import it
|
|
19
|
+
run: |
|
|
20
|
+
python -m venv /tmp/smoke
|
|
21
|
+
/tmp/smoke/bin/pip install dist/*.whl
|
|
22
|
+
cd /tmp && /tmp/smoke/bin/python -c "import ashlar; print(ashlar.__version__)"
|
|
23
|
+
- uses: actions/upload-artifact@v4
|
|
24
|
+
with:
|
|
25
|
+
name: dist
|
|
26
|
+
path: dist/
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
build:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v4
|
|
12
|
+
- uses: actions/setup-python@v5
|
|
13
|
+
with:
|
|
14
|
+
python-version: "3.12"
|
|
15
|
+
- run: python -m pip install build twine
|
|
16
|
+
- run: python -m build
|
|
17
|
+
- run: twine check --strict dist/*
|
|
18
|
+
- uses: actions/upload-artifact@v4
|
|
19
|
+
with:
|
|
20
|
+
name: dist
|
|
21
|
+
path: dist/
|
|
22
|
+
|
|
23
|
+
pypi:
|
|
24
|
+
needs: build
|
|
25
|
+
runs-on: ubuntu-latest
|
|
26
|
+
environment:
|
|
27
|
+
name: pypi
|
|
28
|
+
url: https://pypi.org/p/ashlar-tabular
|
|
29
|
+
permissions:
|
|
30
|
+
id-token: write
|
|
31
|
+
steps:
|
|
32
|
+
- uses: actions/download-artifact@v4
|
|
33
|
+
with:
|
|
34
|
+
name: dist
|
|
35
|
+
path: dist/
|
|
36
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
name: tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
pull_request:
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
unit:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v4
|
|
12
|
+
- uses: actions/setup-python@v5
|
|
13
|
+
with:
|
|
14
|
+
python-version: "3.12"
|
|
15
|
+
- run: python -m pip install ".[dev]"
|
|
16
|
+
- run: pytest
|
|
17
|
+
env:
|
|
18
|
+
JAX_PLATFORMS: cpu
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
include .gitignore
|
|
2
|
+
include LICENSE
|
|
3
|
+
recursive-include tests *.py
|
|
4
|
+
recursive-include examples *.py
|
|
5
|
+
recursive-include .github *.yml
|
|
6
|
+
recursive-include docs *.md
|
|
7
|
+
recursive-include docs *.png
|
|
8
|
+
global-exclude *.py[cod]
|
|
9
|
+
global-exclude __pycache__/*
|
|
10
|
+
global-exclude *.egg-info/*
|
|
11
|
+
prune src/ashlar_tabular.egg-info
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ashlar-tabular
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Narrow JAX/Equinox tabular models with explicit weights and ensemble semantics.
|
|
5
|
+
Author: Maxwell Bay
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/maxmbay/ashlar
|
|
8
|
+
Project-URL: Documentation, https://github.com/maxmbay/ashlar/tree/main/docs
|
|
9
|
+
Project-URL: Issues, https://github.com/maxmbay/ashlar/issues
|
|
10
|
+
Keywords: tabular,jax,equinox,deep-learning,distributional-regression,forecasting,scikit-learn
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: jax>=0.4.38
|
|
23
|
+
Requires-Dist: equinox>=0.11
|
|
24
|
+
Requires-Dist: optax>=0.2
|
|
25
|
+
Requires-Dist: numpy>=1.26
|
|
26
|
+
Requires-Dist: scikit-learn>=1.3
|
|
27
|
+
Provides-Extra: dataframes
|
|
28
|
+
Requires-Dist: pandas>=2.0; extra == "dataframes"
|
|
29
|
+
Requires-Dist: polars>=1.0; extra == "dataframes"
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: pandas>=2.0; extra == "dev"
|
|
32
|
+
Requires-Dist: polars>=1.0; extra == "dev"
|
|
33
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
|
|
36
|
+
<p align="center">
|
|
37
|
+
<picture>
|
|
38
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/maxmbay/ashlar/main/docs/images/logo-dark.svg">
|
|
39
|
+
<img alt="ashlar" src="https://raw.githubusercontent.com/maxmbay/ashlar/main/docs/images/logo-light.svg" width="720">
|
|
40
|
+
</picture>
|
|
41
|
+
</p>
|
|
42
|
+
|
|
43
|
+
Ashlar fits tables and forecasts series with JAX neural networks. You call `fit` and `predict`. Categorical columns become learned vectors. A regression or a forecast can return a whole distribution, not just a point: a Gaussian, a mixture, a spline flow, a histogram, or a set of quantiles.
|
|
44
|
+
|
|
45
|
+
It slots in wherever a gradient-boosted model does. Swap `LGBMRegressor()` for `ASRRegressor()` and `LGBMClassifier()` for `ASRClassifier()`: the scikit-learn interface, a pandas or Polars frame as it is, string columns included, and `clone`, `Pipeline`, `cross_val_score`, and `GridSearchCV` all work. On eight public tables of half a million to two million rows the defaults win or tie on five, and for a predictive distribution they beat the trees on most tables. [The benchmarks](https://github.com/maxmbay/ashlar/blob/main/docs/benchmarks.md) have every number, including where the trees still win.
|
|
46
|
+
|
|
47
|
+
It needs no GPU. Every number on this page was trained on a laptop CPU, where the default model fits two million rows in just a few minutes.
|
|
48
|
+
|
|
49
|
+
## Install
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pip install "ashlar-tabular[dataframes]"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The import name is `ashlar`. This installs JAX's CPU build, which is all Ashlar needs.
|
|
56
|
+
|
|
57
|
+
To train on an NVIDIA GPU (Linux), add JAX's CUDA build. It brings its own CUDA libraries, so only the NVIDIA driver has to be on the machine:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pip install "ashlar-tabular[dataframes]" "jax[cuda12]"
|
|
61
|
+
python -c "import jax; print(jax.devices())" # should list a CudaDevice
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Ashlar code does not change: JAX puts the arrays on the GPU when it finds one. For other CUDA versions and platforms, see [JAX's install guide](https://docs.jax.dev/en/latest/installation.html).
|
|
65
|
+
|
|
66
|
+
## Quick start
|
|
67
|
+
|
|
68
|
+
If you have an XGBoost or LightGBM call, you already have an Ashlar one. Regression:
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from ashlar import ASRRegressor
|
|
72
|
+
from xgboost import XGBRegressor
|
|
73
|
+
|
|
74
|
+
model = XGBRegressor().fit(X, y) # before
|
|
75
|
+
model = ASRRegressor().fit(X, y) # after
|
|
76
|
+
model.predict(X_new)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Classification:
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
from ashlar import ASRClassifier
|
|
83
|
+
from xgboost import XGBClassifier
|
|
84
|
+
|
|
85
|
+
model = XGBClassifier().fit(X, labels) # before
|
|
86
|
+
model = ASRClassifier().fit(X, labels) # after
|
|
87
|
+
model.predict(X_new), model.predict_proba(X_new), model.score(X_new, labels_new)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
`X` is a NumPy array, a dict of columns, or a pandas or Polars frame. Numeric columns are imputed and scaled, string columns get a learned embedding, and a category that never appeared in training is not an error. `clone`, `Pipeline`, `cross_val_score`, and `GridSearchCV` work as they did.
|
|
91
|
+
|
|
92
|
+
One argument turns the same model into a conditional predictive distribution, which a gradient-boosted tree cannot return from a single fit:
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
from ashlar import ASRRegressor
|
|
96
|
+
|
|
97
|
+
model = ASRRegressor(task="mixture").fit(X, y)
|
|
98
|
+
|
|
99
|
+
model.predict(X_new) # still the mean
|
|
100
|
+
model.predict_quantiles(X_new, [0.1, 0.9]) # an interval, on the scale of y
|
|
101
|
+
model.sample(X_new, n=1000) # draws
|
|
102
|
+
model.log_prob(X_new, y_new) # log density of what happened
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
No second model per quantile, and no fixed-width normal around the mean.
|
|
106
|
+
|
|
107
|
+
## Architecture is set by keyword arguments
|
|
108
|
+
|
|
109
|
+
A model is one set of keyword arguments with four independent slots: how the columns are encoded, the backbone that reads them, the head that answers, and the training schedule. Changing the head makes the same network return a density instead of a number. Changing the backbone leaves the head unchanged.
|
|
110
|
+
|
|
111
|
+
<p align="center">
|
|
112
|
+
<picture>
|
|
113
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/maxmbay/ashlar/main/docs/images/architecture-dark.svg">
|
|
114
|
+
<img alt="Four courses of model choices: encode, backbone, head, and train, with one path lit." src="https://raw.githubusercontent.com/maxmbay/ashlar/main/docs/images/architecture-light.svg" width="900">
|
|
115
|
+
</picture>
|
|
116
|
+
</p>
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
from ashlar import ASRClassifier, ASRRegressor
|
|
120
|
+
|
|
121
|
+
ASRRegressor() # the defaults above
|
|
122
|
+
ASRRegressor(task="mixture") # same net, now a predictive density
|
|
123
|
+
ASRRegressor(task="flow", backbone="tabm") # skewed target, ensemble trunk
|
|
124
|
+
ASRClassifier(backbone="transformer") # attention over the columns
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
None of these are wrapper classes: every line is `ASRModel` with different arguments, so a configuration is a dict you can save, version, or sweep. `backbone=` also takes your own Equinox module, and `task="custom"` takes your own head and objective. [docs/models.md](https://github.com/maxmbay/ashlar/blob/main/docs/models.md) is the tour of what goes in each slot.
|
|
128
|
+
|
|
129
|
+
## Conditional predictive distributions, one head per target shape
|
|
130
|
+
|
|
131
|
+
The distribution is conditional on the row, so one fitted model returns a different shape for every row, and the head sets which shapes it can represent.
|
|
132
|
+
|
|
133
|
+

|
|
134
|
+
|
|
135
|
+
One fit per head on taxi fares, given the zones, the hour, the weekday, the passengers, and the cab color, with distance and the total held out. A different head wins each condition, by held-out log density: the `mixture` on Manhattan hops, the `flow` on the heavier Brooklyn tail, and the `histogram` on the Queens corridor, where 32% of trips run at the $52 airport flat fare. Only the histogram grows a real spike there, 23% of its mass against the mixture's 5%, because a spike at one value is what a smooth density cannot make. Its resolution is yours: `head_kwargs={"bins": 48}`, 16 by default.
|
|
136
|
+
|
|
137
|
+
`gaussian`, `mixture`, `flow`, `histogram`, and `quantile` for a number; `ASRClassifier` for classes, `ASROrdinalClassifier` for an ordered scale, and `ASROutcomeTree` for nested outcomes. [docs/heads.md](https://github.com/maxmbay/ashlar/blob/main/docs/heads.md) says which to reach for and why.
|
|
138
|
+
|
|
139
|
+
## Forecasting
|
|
140
|
+
|
|
141
|
+
A series reaches Ashlar two ways. `ASRForecaster` reads a window of the series itself and emits the next steps:
|
|
142
|
+
|
|
143
|
+
```python
|
|
144
|
+
import jax
|
|
145
|
+
from ashlar import ASRForecaster
|
|
146
|
+
|
|
147
|
+
model = ASRForecaster(lookback=48, horizon=24, head="mixture").fit(series)
|
|
148
|
+
model.predict(history) # one point per horizon step
|
|
149
|
+
model.sample(history, jax.random.key(0), n=1000) # draws
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Or the series is already a table of lags and calendar columns, and every tabular head applies to it. `cyclical=` turns a calendar column into a sine and a cosine, so hour 23 sits beside hour 0 and days near each other in the year share what the model learns about them:
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
from ashlar import tabm_piecewise
|
|
156
|
+
|
|
157
|
+
model = tabm_piecewise(task="mixture", cyclical={"hour": 24.0, "weekday": 7.0, "day_of_year": 365.25})
|
|
158
|
+
model.fit(lags, pickups)
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+

|
|
162
|
+
|
|
163
|
+
Hourly NYC taxi pickups, July 2014 to January 2015. Each row is one hour, and reads the 24 hours of the previous day, the same hour a week earlier, and the calendar. A sixth of the days were held out whole, so each is forecast 1 to 24 hours ahead from midnight, by one fit rather than one model per step. Over the 34 held-out days the median forecast is off by 2,678 pickups on average, against 3,806 for the same hour a week earlier, and the 80% interval holds 73% of held-out hours.
|
|
164
|
+
|
|
165
|
+
`ASRHistoryForecaster` reads the whole prefix instead of a window. [docs/forecast.md](https://github.com/maxmbay/ashlar/blob/main/docs/forecast.md) covers both, call by call.
|
|
166
|
+
|
|
167
|
+
## Nested outcomes as a tree of labels
|
|
168
|
+
|
|
169
|
+
Some targets are a tree, not a flat set of classes: a ball is a wicket, a dot, or runs, and runs are a four or a six. `ASROutcomeTree` fits one backbone with a softmax per split, so a label that stops early (`"runs"`, with no detail recorded) still trains the splits above it.
|
|
170
|
+
|
|
171
|
+

|
|
172
|
+
|
|
173
|
+
```python
|
|
174
|
+
from ashlar import ASROutcomeTree
|
|
175
|
+
|
|
176
|
+
model = ASROutcomeTree({"wicket": None, "dot": None, "runs": ["four", "six"]}).fit(X, outcomes)
|
|
177
|
+
model.predict_proba(X_new) # the leaves
|
|
178
|
+
model.predict_conditional(X_new, "runs") # P(four or six | runs, x)
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Every categorical column in that model is a learned vector, and the branch probabilities are a function of those vectors together with the rest of the row, not of either alone:
|
|
182
|
+
|
|
183
|
+

|
|
184
|
+
|
|
185
|
+
An outcome tree over taxi tips, with the leaves `no_tip`, `under_two`, and `two_or_more`. Each pickup zone becomes an 8-dimensional vector, and the vectors arrange themselves by how often trips from that zone are tipped. The right panel sweeps the fare with every other column fixed: P(tip) climbs 0.30 across the sweep from Central Harlem North and 0.29 from Manhattan Valley, but only 0.09 from Battery Park City, which starts high and stays there. The zone does not shift one curve up or down, it changes the response to the fare.
|
|
186
|
+
|
|
187
|
+
## Save and load
|
|
188
|
+
|
|
189
|
+
```python
|
|
190
|
+
from ashlar import ASRModel
|
|
191
|
+
|
|
192
|
+
model.save("models/fare") # a directory: metadata.json and the weights
|
|
193
|
+
model = ASRModel.load("models/fare") # comes back as the class it was saved as
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
A saved model is JSON plus Equinox weight files, not a pickle. Every model saves this way, distributional heads included, and reloads with identical predictions. The forecasters load with their own class: `ASRForecaster.load(path)`. Pass `save_optimizer=False` to a tabular model to leave out the optimizer state when you only need to predict. A custom head or backbone is recorded by its module path and imported on load, so load only models you trust.
|
|
197
|
+
|
|
198
|
+
## Results
|
|
199
|
+
|
|
200
|
+
Eight public tables of half a million to two million rows, against LightGBM, XGBoost, and CatBoost, all trained on a laptop CPU. Ashlar is `ASRRegressor()` or `ASRClassifier()` with no arguments.
|
|
201
|
+
|
|
202
|
+
| Table | Rows | Target, metric | Ashlar | Best tree |
|
|
203
|
+
|---|---:|---|---:|---:|
|
|
204
|
+
| Higgs | 2,000,000 | signal, accuracy ↑ | **0.762** | 0.752 |
|
|
205
|
+
| Covertype | 581,012 | 7 forest types, accuracy ↑ | **0.967** | 0.963 |
|
|
206
|
+
| Year (MSD) | 515,345 | release year, RMSE ↓ | **8.698** | 8.710 |
|
|
207
|
+
| Airline delay | 2,000,000 | delay in minutes, RMSE ↓ | **29.04** | 29.05 |
|
|
208
|
+
| Zurich transport | 2,000,000 | delay, RMSE ↓ | 3.052 | **3.047** |
|
|
209
|
+
| Click prediction | 1,997,410 | click, accuracy ↑ | 0.842 | **0.844** |
|
|
210
|
+
| Airlines | 539,383 | delayed, accuracy ↑ | 0.660 | **0.668** |
|
|
211
|
+
| NYC green taxi | 581,835 | tip in $, RMSE ↓ | 1.977 | **1.752** |
|
|
212
|
+
|
|
213
|
+
Four wins, one tie within a thousandth, two a few tenths of a point behind, and one clear loss. Higgs and covertype are not close: on Higgs the defaults beat every tree by more than a point of accuracy (AUC 0.846 against 0.835), and on covertype by half a point against the best tree and five points against CatBoost.
|
|
214
|
+
|
|
215
|
+
Ask for a distribution and the gap widens. CRPS scores a whole predictive distribution in the target's units, NLL is the negative log density of what happened, and both are lower-is-better:
|
|
216
|
+
|
|
217
|
+
| Table | Score | Ashlar `mixture` | Best tree distribution |
|
|
218
|
+
|---|---|---:|---:|
|
|
219
|
+
| Airline delay, minutes | CRPS | **9.17** | 11.46 |
|
|
220
|
+
| | NLL | **2.66** | 4.72 |
|
|
221
|
+
| Year (MSD) | CRPS | **4.05** | 4.41 |
|
|
222
|
+
| | NLL | **3.08** | 3.42 |
|
|
223
|
+
| Zurich transport | CRPS | **1.62** | 1.74 |
|
|
224
|
+
| | NLL | **2.00** | 2.53 |
|
|
225
|
+
| NYC green taxi tips, $ | CRPS | 0.59 | **0.46** |
|
|
226
|
+
| | NLL | **−1.97** | 0.70 |
|
|
227
|
+
|
|
228
|
+
The best likelihood on all four, and the best CRPS on three. The intervals are honest too: an Ashlar interval that promises 80% holds about 80% of held-out values, where a tree mean with a fitted normal holds 94% of airline delays because one width has to serve every flight. On airline delay the mixture's 80% interval is less than half as wide, 33 minutes against 75, and still covers 80%.
|
|
229
|
+
|
|
230
|
+
On five smaller tables the defaults win two (Ames, abalone) and trail LightGBM on the rest, where `tabm_piecewise()` closes most of the gap. [docs/benchmarks.md](https://github.com/maxmbay/ashlar/blob/main/docs/benchmarks.md) has every number: all eight large tables per metric, the five small ones, RealMLP, TabM, and FT-Transformer, the ablation behind the defaults, and the forecast heads.
|
|
231
|
+
|
|
232
|
+
## Documentation
|
|
233
|
+
|
|
234
|
+
- [docs/models.md](https://github.com/maxmbay/ashlar/blob/main/docs/models.md): the four slots, and the research models beyond the defaults.
|
|
235
|
+
- [docs/heads.md](https://github.com/maxmbay/ashlar/blob/main/docs/heads.md): every head and the shape of target it suits.
|
|
236
|
+
- [docs/tabular.md](https://github.com/maxmbay/ashlar/blob/main/docs/tabular.md): fitting a table. Defaults, recipes, tasks, embeddings, set columns, and search.
|
|
237
|
+
- [docs/forecast.md](https://github.com/maxmbay/ashlar/blob/main/docs/forecast.md): the two forecasters, call by call.
|
|
238
|
+
- [docs/benchmarks.md](https://github.com/maxmbay/ashlar/blob/main/docs/benchmarks.md): every number, per table and per metric, and how it was run.
|
|
239
|
+
- [`examples/`](https://github.com/maxmbay/ashlar/tree/main/examples): runnable scripts, including the benchmarks and the figures on this page.
|
|
240
|
+
|
|
241
|
+
## Acknowledgements
|
|
242
|
+
|
|
243
|
+
The `tabm` backbone and the `tabm()` and `tabm_piecewise()` recipes follow TabM, by Yury Gorishniy, Akim Kotelnikov, and Artem Babenko ([paper](https://arxiv.org/abs/2410.24210), [code](https://github.com/yandex-research/tabm)). The piecewise-linear and periodic numeric embeddings follow [Gorishniy, Rubachev, and Babenko (2022)](https://arxiv.org/abs/2203.05556). TabM is also the strongest neural baseline in our benchmarks.
|