causilo 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. causilo-1.0.0/LICENSE +202 -0
  2. causilo-1.0.0/MANIFEST.in +9 -0
  3. causilo-1.0.0/PKG-INFO +144 -0
  4. causilo-1.0.0/README.md +111 -0
  5. causilo-1.0.0/examples/cached_prediction.py +10 -0
  6. causilo-1.0.0/examples/classification.py +12 -0
  7. causilo-1.0.0/examples/regression.py +12 -0
  8. causilo-1.0.0/examples/save_restore.py +21 -0
  9. causilo-1.0.0/pyproject.toml +48 -0
  10. causilo-1.0.0/setup.cfg +4 -0
  11. causilo-1.0.0/src/causilo/__init__.py +7 -0
  12. causilo-1.0.0/src/causilo/checkpoints.py +54 -0
  13. causilo-1.0.0/src/causilo/data/__init__.py +1 -0
  14. causilo-1.0.0/src/causilo/data/dataset.py +108 -0
  15. causilo-1.0.0/src/causilo/data/encoding.py +106 -0
  16. causilo-1.0.0/src/causilo/data/ensemble.py +87 -0
  17. causilo-1.0.0/src/causilo/data/normalization.py +123 -0
  18. causilo-1.0.0/src/causilo/engine.py +156 -0
  19. causilo-1.0.0/src/causilo/estimators.py +168 -0
  20. causilo-1.0.0/src/causilo/execution/__init__.py +1 -0
  21. causilo-1.0.0/src/causilo/execution/cached.py +87 -0
  22. causilo-1.0.0/src/causilo/execution/chunks.py +165 -0
  23. causilo-1.0.0/src/causilo/execution/direct.py +135 -0
  24. causilo-1.0.0/src/causilo/execution/memory.py +84 -0
  25. causilo-1.0.0/src/causilo/execution/precision.py +18 -0
  26. causilo-1.0.0/src/causilo/execution/runner.py +151 -0
  27. causilo-1.0.0/src/causilo/model.py +73 -0
  28. causilo-1.0.0/src/causilo/nn/__init__.py +1 -0
  29. causilo-1.0.0/src/causilo/nn/cache.py +28 -0
  30. causilo-1.0.0/src/causilo/nn/column.py +55 -0
  31. causilo-1.0.0/src/causilo/nn/embeddings.py +50 -0
  32. causilo-1.0.0/src/causilo/nn/layers/__init__.py +1 -0
  33. causilo-1.0.0/src/causilo/nn/layers/attention.py +108 -0
  34. causilo-1.0.0/src/causilo/nn/layers/feedforward.py +17 -0
  35. causilo-1.0.0/src/causilo/nn/layers/scaling.py +33 -0
  36. causilo-1.0.0/src/causilo/nn/prediction.py +61 -0
  37. causilo-1.0.0/src/causilo/nn/row.py +89 -0
  38. causilo-1.0.0/src/causilo/serialization.py +146 -0
  39. causilo-1.0.0/src/causilo.egg-info/PKG-INFO +144 -0
  40. causilo-1.0.0/src/causilo.egg-info/SOURCES.txt +46 -0
  41. causilo-1.0.0/src/causilo.egg-info/dependency_links.txt +1 -0
  42. causilo-1.0.0/src/causilo.egg-info/requires.txt +15 -0
  43. causilo-1.0.0/src/causilo.egg-info/top_level.txt +1 -0
  44. causilo-1.0.0/tests/helpers/restore_probe.py +25 -0
  45. causilo-1.0.0/tests/test_fitted_contract.py +271 -0
  46. causilo-1.0.0/tests/test_input_precision.py +87 -0
  47. causilo-1.0.0/tests/test_inputs.py +86 -0
  48. causilo-1.0.0/tests/test_partitioning.py +65 -0
causilo-1.0.0/LICENSE ADDED
@@ -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 2026 Nums AI Inc.
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,9 @@
1
+ include LICENSE README.md pyproject.toml
2
+ recursive-include src *.py
3
+ recursive-include tests *.py
4
+ recursive-include examples *.py
5
+ prune reports
6
+ prune artifacts
7
+ prune tools
8
+ prune .github
9
+ global-exclude __pycache__ *.py[cod]
causilo-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,144 @@
1
+ Metadata-Version: 2.4
2
+ Name: causilo
3
+ Version: 1.0.0
4
+ Summary: Pretrained tabular classification and regression
5
+ Author-email: "Nums AI Inc." <contact@nums.world>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Repository, https://github.com/nums-ai/causilo
8
+ Project-URL: Issues, https://github.com/nums-ai/causilo/issues
9
+ Project-URL: Models, https://huggingface.co/nums-ai/causilo
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Operating System :: POSIX :: Linux
14
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
15
+ Requires-Python: <3.13,>=3.10
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: torch>=2.13
19
+ Requires-Dist: numpy
20
+ Requires-Dist: pandas
21
+ Requires-Dist: scipy
22
+ Requires-Dist: scikit-learn>=1.6
23
+ Requires-Dist: safetensors>=0.8
24
+ Requires-Dist: huggingface-hub>=0.28
25
+ Requires-Dist: psutil
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=8; extra == "dev"
28
+ Requires-Dist: ruff; extra == "dev"
29
+ Requires-Dist: build; extra == "dev"
30
+ Requires-Dist: twine; extra == "dev"
31
+ Requires-Dist: joblib; extra == "dev"
32
+ Dynamic: license-file
33
+
34
+ # Causilo
35
+
36
+ Causilo is a pretrained tabular foundation model from Nums AI Inc., supporting classification and regression through a scikit-learn interface.
37
+
38
+ [Apache-2.0 code](https://github.com/nums-ai/causilo/blob/main/LICENSE) · [Causilo License v1.0 model weights](https://huggingface.co/nums-ai/causilo/blob/main/LICENSE) · [License & contact](#license--contact)
39
+
40
+ ## Installation
41
+
42
+ Python 3.10–3.12 and PyTorch 2.13+ are required.
43
+
44
+ ```bash
45
+ pip install causilo
46
+ hf auth login
47
+ ```
48
+
49
+ Authenticate with an account that has access to the [model weights](https://huggingface.co/nums-ai/causilo). Package installation does not grant weight access; the first fit downloads and caches the task's checkpoint. `device="auto"` uses CUDA when available, otherwise CPU. Use `CUDA_VISIBLE_DEVICES=0` to select a GPU.
50
+
51
+ ## Quick start
52
+
53
+ ```python
54
+ from causilo import CausiloClassifier, CausiloRegressor
55
+
56
+ classifier = CausiloClassifier(n_estimators=8, random_state=42)
57
+ classifier.fit(X_train, y_train)
58
+ labels = classifier.predict(X_test)
59
+ probabilities = classifier.predict_proba(X_test)
60
+
61
+ regressor = CausiloRegressor(n_estimators=8, random_state=42)
62
+ regressor.fit(X_train, y_train)
63
+ predictions = regressor.predict(X_test)
64
+ ```
65
+
66
+
67
+ Inputs can be NumPy arrays or pandas DataFrames, including categorical features and missing feature values. Use pandas categorical dtype for numeric category codes. NumPy object arrays infer numeric columns; strings and Booleans remain categorical. Prediction reuses the fitted schema, including handling unseen categories.
68
+
69
+ Classification supports up to 10 classes; regression returns point predictions. Targets must not be missing. See runnable [classification](https://github.com/nums-ai/causilo/blob/main/examples/classification.py) and [regression](https://github.com/nums-ai/causilo/blob/main/examples/regression.py) examples.
70
+
71
+ ## Benchmarks
72
+
73
+ Official TabArena default-only evaluation: 51 datasets, 51 Lite splits and 816 Full splits, using eight estimators and seed 42. System methods are excluded. Full plots show the top 16 model families by their best Elo, with default, tuned and ensembled variants.
74
+
75
+ | Suite | Task | Elo position | Elo ↑ | Improvability ↓ |
76
+ |:--------|:---------------|---------------:|--------:|------------------:|
77
+ | Lite | Overall | 1 | 1817.4 | 0.0596 |
78
+ | Lite | Classification | 1 | 1780.1 | 0.0747 |
79
+ | Lite | Regression | 1 | 2168.2 | 0.0155 |
80
+ | Full | Overall | 1 | 1792.9 | 0.0684 |
81
+ | Full | Classification | 1 | 1771.8 | 0.0875 |
82
+ | Full | Regression | 1 | 2032.6 | 0.0125 |
83
+
84
+ ![Overall performance](https://raw.githubusercontent.com/nums-ai/causilo/main/docs/benchmarks/overall.png)
85
+
86
+ *Overall — TabArena Full, classification and regression combined.*
87
+
88
+ <details>
89
+ <summary>Classification and regression</summary>
90
+
91
+ ![Classification performance](https://raw.githubusercontent.com/nums-ai/causilo/main/docs/benchmarks/classification.png)
92
+
93
+ *Classification — TabArena Full, classification datasets only.*
94
+
95
+ ![Regression performance](https://raw.githubusercontent.com/nums-ai/causilo/main/docs/benchmarks/regression.png)
96
+
97
+ *Regression — TabArena Full, regression datasets only.*
98
+
99
+ </details>
100
+
101
+ Local H100 80 GB comparison, one GPU and eight physical CPU cores per job:
102
+
103
+ | Model | Fit (s/1k) | Predict (s/1k) | CPU (GiB) | GPU (GiB) |
104
+ |:---------|-------------:|-----------------:|------------:|------------:|
105
+ | **Causilo** | **2.504** | **0.251** | **1.94** | 8.15 |
106
+ | TabICLv2 | 3.449 | 0.303 | 2 | 8.37 |
107
+ | TabPFN-3 | 4.18 | 0.686 | 2.87 | **0.88** |
108
+
109
+ Times are median seconds per 1,000 rows; memory is mean peak usage during fit only. [Protocol, task-level resources and complete leaderboards](https://github.com/nums-ai/causilo/blob/main/docs/benchmarks/README.md).
110
+
111
+ ## Options
112
+
113
+ | Parameter | Default | Behavior |
114
+ | --- | --- | --- |
115
+ | `n_estimators` | `8` | Number of ensemble members to evaluate |
116
+ | `random_state` | `42` | Nonnegative integer seed for feature and class permutations |
117
+ | `device` | `"auto"` | One available CUDA device, otherwise CPU; explicit `"cpu"` or `"cuda:0"` is supported |
118
+ | `use_kv_cache` | `False` | Prepare and retain attention keys and values during fit |
119
+ | `retain_preprocessing` | `True` | Retain transformed training tables for later prediction |
120
+
121
+
122
+ Refit after changing options. Seeds must be nonnegative integers; the same inputs and seed reproduce the fitted permutations without changing global RNG state. Bitwise floating-point determinism is not forced.
123
+
124
+ Preprocessing and execution policies are fixed. Ensembles cycle through none, rank2gaussian, robust and power normalization. CUDA uses FP16 mixed precision, with regression column stages and both output heads in FP32; CPU uses FP32. Regression target scaling and output restoration use float64.
125
+
126
+ ## Repeated prediction
127
+
128
+ Set `use_kv_cache=True` to move reusable context computation into fit, trading additional device memory for repeated prediction speed. With `retain_preprocessing=False`, fitted transforms are retained but transformed training tables are recomputed. Refitting replaces the context; a failed fit leaves the estimator unfitted. See [cached prediction](https://github.com/nums-ai/causilo/blob/main/examples/cached_prediction.py).
129
+
130
+ ## Fitted-state storage
131
+
132
+ ```python
133
+ import joblib
134
+
135
+ joblib.dump(classifier, "classifier.joblib")
136
+ restored = joblib.load("classifier.joblib")
137
+ ```
138
+
139
+
140
+ Saved state includes fitted preprocessing and optional K/V caches, but excludes pretrained weights. Restoration loads the pinned checkpoint and reuses saved caches. It requires matching Causilo and dependency versions, including Python major/minor. Automatic device selection runs again; an unavailable explicit device fails. See [save/restore](https://github.com/nums-ai/causilo/blob/main/examples/save_restore.py).
141
+
142
+ ## License & contact
143
+
144
+ Code is licensed under [Apache-2.0](https://github.com/nums-ai/causilo/blob/main/LICENSE); model weights are separately licensed under [Causilo License v1.0](https://huggingface.co/nums-ai/causilo/blob/main/LICENSE). Non-commercial research and free research redistribution are permitted under its conditions. Commercial or production use, and hosted/API/SaaS services whether paid or free, require separate licenses. Contact contact@nums.world.
@@ -0,0 +1,111 @@
1
+ # Causilo
2
+
3
+ Causilo is a pretrained tabular foundation model from Nums AI Inc., supporting classification and regression through a scikit-learn interface.
4
+
5
+ [Apache-2.0 code](https://github.com/nums-ai/causilo/blob/main/LICENSE) · [Causilo License v1.0 model weights](https://huggingface.co/nums-ai/causilo/blob/main/LICENSE) · [License & contact](#license--contact)
6
+
7
+ ## Installation
8
+
9
+ Python 3.10–3.12 and PyTorch 2.13+ are required.
10
+
11
+ ```bash
12
+ pip install causilo
13
+ hf auth login
14
+ ```
15
+
16
+ Authenticate with an account that has access to the [model weights](https://huggingface.co/nums-ai/causilo). Package installation does not grant weight access; the first fit downloads and caches the task's checkpoint. `device="auto"` uses CUDA when available, otherwise CPU. Use `CUDA_VISIBLE_DEVICES=0` to select a GPU.
17
+
18
+ ## Quick start
19
+
20
+ ```python
21
+ from causilo import CausiloClassifier, CausiloRegressor
22
+
23
+ classifier = CausiloClassifier(n_estimators=8, random_state=42)
24
+ classifier.fit(X_train, y_train)
25
+ labels = classifier.predict(X_test)
26
+ probabilities = classifier.predict_proba(X_test)
27
+
28
+ regressor = CausiloRegressor(n_estimators=8, random_state=42)
29
+ regressor.fit(X_train, y_train)
30
+ predictions = regressor.predict(X_test)
31
+ ```
32
+
33
+
34
+ Inputs can be NumPy arrays or pandas DataFrames, including categorical features and missing feature values. Use pandas categorical dtype for numeric category codes. NumPy object arrays infer numeric columns; strings and Booleans remain categorical. Prediction reuses the fitted schema, including handling unseen categories.
35
+
36
+ Classification supports up to 10 classes; regression returns point predictions. Targets must not be missing. See runnable [classification](https://github.com/nums-ai/causilo/blob/main/examples/classification.py) and [regression](https://github.com/nums-ai/causilo/blob/main/examples/regression.py) examples.
37
+
38
+ ## Benchmarks
39
+
40
+ Official TabArena default-only evaluation: 51 datasets, 51 Lite splits and 816 Full splits, using eight estimators and seed 42. System methods are excluded. Full plots show the top 16 model families by their best Elo, with default, tuned and ensembled variants.
41
+
42
+ | Suite | Task | Elo position | Elo ↑ | Improvability ↓ |
43
+ |:--------|:---------------|---------------:|--------:|------------------:|
44
+ | Lite | Overall | 1 | 1817.4 | 0.0596 |
45
+ | Lite | Classification | 1 | 1780.1 | 0.0747 |
46
+ | Lite | Regression | 1 | 2168.2 | 0.0155 |
47
+ | Full | Overall | 1 | 1792.9 | 0.0684 |
48
+ | Full | Classification | 1 | 1771.8 | 0.0875 |
49
+ | Full | Regression | 1 | 2032.6 | 0.0125 |
50
+
51
+ ![Overall performance](https://raw.githubusercontent.com/nums-ai/causilo/main/docs/benchmarks/overall.png)
52
+
53
+ *Overall — TabArena Full, classification and regression combined.*
54
+
55
+ <details>
56
+ <summary>Classification and regression</summary>
57
+
58
+ ![Classification performance](https://raw.githubusercontent.com/nums-ai/causilo/main/docs/benchmarks/classification.png)
59
+
60
+ *Classification — TabArena Full, classification datasets only.*
61
+
62
+ ![Regression performance](https://raw.githubusercontent.com/nums-ai/causilo/main/docs/benchmarks/regression.png)
63
+
64
+ *Regression — TabArena Full, regression datasets only.*
65
+
66
+ </details>
67
+
68
+ Local H100 80 GB comparison, one GPU and eight physical CPU cores per job:
69
+
70
+ | Model | Fit (s/1k) | Predict (s/1k) | CPU (GiB) | GPU (GiB) |
71
+ |:---------|-------------:|-----------------:|------------:|------------:|
72
+ | **Causilo** | **2.504** | **0.251** | **1.94** | 8.15 |
73
+ | TabICLv2 | 3.449 | 0.303 | 2 | 8.37 |
74
+ | TabPFN-3 | 4.18 | 0.686 | 2.87 | **0.88** |
75
+
76
+ Times are median seconds per 1,000 rows; memory is mean peak usage during fit only. [Protocol, task-level resources and complete leaderboards](https://github.com/nums-ai/causilo/blob/main/docs/benchmarks/README.md).
77
+
78
+ ## Options
79
+
80
+ | Parameter | Default | Behavior |
81
+ | --- | --- | --- |
82
+ | `n_estimators` | `8` | Number of ensemble members to evaluate |
83
+ | `random_state` | `42` | Nonnegative integer seed for feature and class permutations |
84
+ | `device` | `"auto"` | One available CUDA device, otherwise CPU; explicit `"cpu"` or `"cuda:0"` is supported |
85
+ | `use_kv_cache` | `False` | Prepare and retain attention keys and values during fit |
86
+ | `retain_preprocessing` | `True` | Retain transformed training tables for later prediction |
87
+
88
+
89
+ Refit after changing options. Seeds must be nonnegative integers; the same inputs and seed reproduce the fitted permutations without changing global RNG state. Bitwise floating-point determinism is not forced.
90
+
91
+ Preprocessing and execution policies are fixed. Ensembles cycle through none, rank2gaussian, robust and power normalization. CUDA uses FP16 mixed precision, with regression column stages and both output heads in FP32; CPU uses FP32. Regression target scaling and output restoration use float64.
92
+
93
+ ## Repeated prediction
94
+
95
+ Set `use_kv_cache=True` to move reusable context computation into fit, trading additional device memory for repeated prediction speed. With `retain_preprocessing=False`, fitted transforms are retained but transformed training tables are recomputed. Refitting replaces the context; a failed fit leaves the estimator unfitted. See [cached prediction](https://github.com/nums-ai/causilo/blob/main/examples/cached_prediction.py).
96
+
97
+ ## Fitted-state storage
98
+
99
+ ```python
100
+ import joblib
101
+
102
+ joblib.dump(classifier, "classifier.joblib")
103
+ restored = joblib.load("classifier.joblib")
104
+ ```
105
+
106
+
107
+ Saved state includes fitted preprocessing and optional K/V caches, but excludes pretrained weights. Restoration loads the pinned checkpoint and reuses saved caches. It requires matching Causilo and dependency versions, including Python major/minor. Automatic device selection runs again; an unavailable explicit device fails. See [save/restore](https://github.com/nums-ai/causilo/blob/main/examples/save_restore.py).
108
+
109
+ ## License & contact
110
+
111
+ Code is licensed under [Apache-2.0](https://github.com/nums-ai/causilo/blob/main/LICENSE); model weights are separately licensed under [Causilo License v1.0](https://huggingface.co/nums-ai/causilo/blob/main/LICENSE). Non-commercial research and free research redistribution are permitted under its conditions. Commercial or production use, and hosted/API/SaaS services whether paid or free, require separate licenses. Contact contact@nums.world.
@@ -0,0 +1,10 @@
1
+ """Reuse fitted attention context for successive prediction calls."""
2
+
3
+ from sklearn.datasets import load_iris
4
+
5
+ from causilo import CausiloClassifier
6
+
7
+ X, y = load_iris(return_X_y=True, as_frame=True)
8
+ model = CausiloClassifier(use_kv_cache=True).fit(X.iloc[::2], y.iloc[::2])
9
+ for start in (1, 11, 21):
10
+ print(model.predict_proba(X.iloc[start:start + 5]))
@@ -0,0 +1,12 @@
1
+ """Fit a classifier and inspect class probabilities."""
2
+
3
+ from sklearn.datasets import load_iris
4
+ from sklearn.model_selection import train_test_split
5
+
6
+ from causilo import CausiloClassifier
7
+
8
+ X, y = load_iris(return_X_y=True, as_frame=True)
9
+ X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0, stratify=y)
10
+ model = CausiloClassifier().fit(X_train, y_train)
11
+ print("Accuracy:", model.score(X_test, y_test))
12
+ print("Probabilities:", model.predict_proba(X_test.iloc[:3]))
@@ -0,0 +1,12 @@
1
+ """Fit a regressor and inspect point predictions."""
2
+
3
+ from sklearn.datasets import load_diabetes
4
+ from sklearn.model_selection import train_test_split
5
+
6
+ from causilo import CausiloRegressor
7
+
8
+ X, y = load_diabetes(return_X_y=True, as_frame=True)
9
+ X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0)
10
+ model = CausiloRegressor().fit(X_train, y_train)
11
+ print("R-squared:", model.score(X_test, y_test))
12
+ print("Predictions:", model.predict(X_test.iloc[:3]))
@@ -0,0 +1,21 @@
1
+ """Save fitted context and restore it without another fit."""
2
+
3
+ from pathlib import Path
4
+ from tempfile import TemporaryDirectory
5
+
6
+ import joblib
7
+ import numpy as np
8
+ from sklearn.datasets import load_diabetes
9
+
10
+ from causilo import CausiloRegressor
11
+
12
+ X, y = load_diabetes(return_X_y=True, as_frame=True)
13
+ model = CausiloRegressor(use_kv_cache=True).fit(X.iloc[:100], y.iloc[:100])
14
+ query = X.iloc[100:105]
15
+ expected = model.predict(query)
16
+ with TemporaryDirectory() as folder:
17
+ path = Path(folder) / "fitted.joblib"
18
+ joblib.dump(model, path)
19
+ restored = joblib.load(path)
20
+ np.testing.assert_array_equal(restored.predict(query), expected)
21
+ print(restored.predict(query))
@@ -0,0 +1,48 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "causilo"
7
+ version = "1.0.0"
8
+ description = "Pretrained tabular classification and regression"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10,<3.13"
11
+ license = "Apache-2.0"
12
+ license-files = ["LICENSE"]
13
+ authors = [{name = "Nums AI Inc.", email = "contact@nums.world"}]
14
+ dependencies = [
15
+ "torch>=2.13", "numpy", "pandas", "scipy", "scikit-learn>=1.6",
16
+ "safetensors>=0.8", "huggingface-hub>=0.28", "psutil",
17
+ ]
18
+ classifiers = [
19
+ "Programming Language :: Python :: 3.10",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Operating System :: POSIX :: Linux",
23
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
24
+ ]
25
+
26
+ [project.urls]
27
+ Repository = "https://github.com/nums-ai/causilo"
28
+ Issues = "https://github.com/nums-ai/causilo/issues"
29
+ Models = "https://huggingface.co/nums-ai/causilo"
30
+
31
+ [project.optional-dependencies]
32
+ dev = ["pytest>=8", "ruff", "build", "twine", "joblib"]
33
+
34
+ [tool.setuptools.packages.find]
35
+ where = ["src"]
36
+
37
+ [tool.pytest.ini_options]
38
+ testpaths = ["tests"]
39
+ pythonpath = ["src"]
40
+ addopts = "-m 'not pretrained'"
41
+ markers = ["pretrained: requires access to official model weights"]
42
+
43
+ [tool.ruff]
44
+ line-length = 110
45
+ target-version = "py310"
46
+
47
+ [tool.ruff.lint]
48
+ select = ["E4", "E7", "E9", "F", "I"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,7 @@
1
+ """Tabular prediction with fixed pretrained context models."""
2
+
3
+ __version__ = "1.0.0"
4
+
5
+ from .estimators import CausiloClassifier, CausiloRegressor
6
+
7
+ __all__ = ["CausiloClassifier", "CausiloRegressor"]
@@ -0,0 +1,54 @@
1
+ """Load pinned safetensors weights and verify their task/configuration pairing."""
2
+
3
+ import hashlib
4
+ import json
5
+ from pathlib import Path
6
+
7
+ import torch
8
+ from huggingface_hub import snapshot_download
9
+ from safetensors import safe_open
10
+
11
+ from .model import Model, ModelConfig
12
+
13
+ REPOSITORY = "nums-ai/causilo"
14
+ RELEASE_COMMIT = "94f2bd91db0737d4da59f347910662905ecb5a09"
15
+
16
+
17
+ def load_checkpoint(directory: Path) -> Model:
18
+ """Validate the format and config hash, then materialize an evaluation model."""
19
+ encoded = (directory / "config.json").read_bytes()
20
+ record = json.loads(encoded)
21
+ expected = {"architecture": "causilo-v1.0", "format_version": 1, "config_version": 1}
22
+ if any(record.get(key) != value for key, value in expected.items()):
23
+ raise ValueError("Unsupported model configuration")
24
+ config = ModelConfig(**record["model"])
25
+ with safe_open(directory / "model.safetensors", framework="pt") as artifact:
26
+ metadata = artifact.metadata()
27
+ required = {
28
+ "architecture": "causilo-v1.0",
29
+ "format_version": "1",
30
+ "task": config.task,
31
+ "config_sha256": hashlib.sha256(encoded).hexdigest(),
32
+ }
33
+ if metadata != required:
34
+ raise ValueError("Weights do not match their task and configuration")
35
+ tensors = {key: artifact.get_tensor(key) for key in artifact.keys()}
36
+ # Construct shapes without allocating a second full copy of the weights.
37
+ with torch.device("meta"):
38
+ model = Model(config)
39
+ model.load_state_dict(tensors, strict=True, assign=True)
40
+ return model.eval()
41
+
42
+
43
+ def load_pretrained_model(task: str) -> Model:
44
+ """Fetch the task's files at the pinned revision, reusing the Hub cache when available."""
45
+ folder = "classifier" if task == "classification" else "regressor"
46
+ root = snapshot_download(
47
+ REPOSITORY,
48
+ revision=RELEASE_COMMIT,
49
+ allow_patterns=[f"{folder}/config.json", f"{folder}/model.safetensors"],
50
+ )
51
+ model = load_checkpoint(Path(root) / folder)
52
+ if model.config.task != task:
53
+ raise ValueError("The official checkpoint has the wrong prediction task")
54
+ return model
@@ -0,0 +1 @@
1
+ """Fitted tabular representations and deterministic ensemble views."""