slatex 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.
@@ -0,0 +1,27 @@
1
+ # Build artifacts
2
+ build/
3
+ dist/
4
+ *.egg-info/
5
+ .eggs/
6
+
7
+ # Python
8
+ __pycache__/
9
+ *.py[cod]
10
+ *.so
11
+ .Python
12
+
13
+ # Testing / coverage
14
+ .pytest_cache/
15
+ .coverage
16
+ htmlcov/
17
+ .tox/
18
+
19
+ # Virtual environments
20
+ .venv/
21
+ venv/
22
+ env/
23
+
24
+ # Editors / OS
25
+ .idea/
26
+ .vscode/
27
+ .DS_Store
@@ -0,0 +1,23 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here. This project adheres
4
+ to [Semantic Versioning](https://semver.org/).
5
+
6
+ ## [0.1.0] - 2026-06-15
7
+
8
+ ### Added
9
+ - Initial public release of `SlateClassifier`.
10
+ - Budgeted, L1-regularized Newton boosting over axis-aligned threshold atoms.
11
+ - Binary and multiclass (one-vs-rest) classification.
12
+ - Automatic label encoding for arbitrary label types.
13
+ - Input validation with clear error messages (NaN/inf, shape, unfitted, etc.).
14
+ - Exact additive interpretability: `shape_function` and `shapley_values`.
15
+ - Model-size introspection: `n_atoms_`, `n_parameters_`, `memory_bytes_`.
16
+ - scikit-learn-compatible `get_params` / `set_params`, `score`.
17
+ - NumPy-only runtime dependency.
18
+
19
+ ### Performance
20
+ - Drop the per-feature quantile grids (`thresholds_`) after fitting, since they
21
+ are training-only scaffolding unused by inference or interpretability. A
22
+ pickled/joblib-saved model is now ~1-2 KB (matching the live inference
23
+ footprint) instead of tens of KB, with no change to predictions.
slatex-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Saikiran Gogineni
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.
slatex-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,174 @@
1
+ Metadata-Version: 2.4
2
+ Name: slatex
3
+ Version: 0.1.0
4
+ Summary: Sparse Lightweight Additive Threshold Ensemble — a small, fast, interpretable classifier for edge devices and TinyML.
5
+ Project-URL: Homepage, https://github.com/saikirangogineni/slatex
6
+ Project-URL: Repository, https://github.com/saikirangogineni/slatex
7
+ Project-URL: Issues, https://github.com/saikirangogineni/slatex/issues
8
+ Author-email: Saikiran Gogineni <goginenisaikiran31677@gmail.com>
9
+ Maintainer-email: Saikiran Gogineni <goginenisaikiran31677@gmail.com>
10
+ License: MIT License
11
+
12
+ Copyright (c) 2026 Saikiran Gogineni
13
+
14
+ Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ of this software and associated documentation files (the "Software"), to deal
16
+ in the Software without restriction, including without limitation the rights
17
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ copies of the Software, and to permit persons to whom the Software is
19
+ furnished to do so, subject to the following conditions:
20
+
21
+ The above copyright notice and this permission notice shall be included in all
22
+ copies or substantial portions of the Software.
23
+
24
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
+ SOFTWARE.
31
+ License-File: LICENSE
32
+ Keywords: boosting,classifier,edge-ai,explainable-ai,gam,generalized-additive-model,interpretable-ml,machine-learning,sparse-models,tinyml
33
+ Classifier: Development Status :: 4 - Beta
34
+ Classifier: Intended Audience :: Developers
35
+ Classifier: Intended Audience :: Science/Research
36
+ Classifier: License :: OSI Approved :: MIT License
37
+ Classifier: Operating System :: OS Independent
38
+ Classifier: Programming Language :: Python :: 3
39
+ Classifier: Programming Language :: Python :: 3.9
40
+ Classifier: Programming Language :: Python :: 3.10
41
+ Classifier: Programming Language :: Python :: 3.11
42
+ Classifier: Programming Language :: Python :: 3.12
43
+ Classifier: Programming Language :: Python :: 3.13
44
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
45
+ Requires-Python: >=3.9
46
+ Requires-Dist: numpy>=1.21
47
+ Provides-Extra: dev
48
+ Requires-Dist: build; extra == 'dev'
49
+ Requires-Dist: pytest>=7.0; extra == 'dev'
50
+ Requires-Dist: scikit-learn>=1.0; extra == 'dev'
51
+ Requires-Dist: twine; extra == 'dev'
52
+ Provides-Extra: test
53
+ Requires-Dist: pytest>=7.0; extra == 'test'
54
+ Requires-Dist: scikit-learn>=1.0; extra == 'test'
55
+ Description-Content-Type: text/markdown
56
+
57
+ # slatex
58
+
59
+ **Sparse Lightweight Additive Threshold Ensemble** — a small, fast, interpretable
60
+ classifier for constrained hardware (edge devices, microcontrollers, TinyML).
61
+
62
+ SLATE is an additive model (a Generalized Additive Model) built from simple
63
+ threshold rules of the form *"1 if a feature is at or below a learned cut, else 0"*.
64
+ It is trained by L1-regularized Newton boosting: rules are selected one at a time,
65
+ then all active rules are refit together in a corrective pass, while a hard budget
66
+ keeps the model tiny.
67
+
68
+ - **Tiny.** A hard budget caps the number of rules, so a trained model is on the
69
+ order of a kilobyte and inference is a handful of comparisons and adds. The
70
+ fitted model drops its training-time scaffolding, so a pickled/joblib-saved
71
+ estimator is just ~1-2 KB — the same as its live inference footprint.
72
+ - **Interpretable.** Because the model is additive, you get exact per-feature shape
73
+ functions and exact Shapley attributions in closed form.
74
+ - **Lightweight to install.** Pure NumPy at runtime — no heavy ML stack required.
75
+ - **Familiar API.** `fit` / `predict` / `predict_proba`, drops into scikit-learn
76
+ pipelines and grid search. Binary *and* multiclass are supported.
77
+
78
+ ## Installation
79
+
80
+ ```bash
81
+ pip install slatex
82
+ ```
83
+
84
+ Requires Python 3.9+ and NumPy. To run the test suite you also need
85
+ scikit-learn (`pip install "slatex[test]"`).
86
+
87
+ ## Quickstart
88
+
89
+ ```python
90
+ import numpy as np
91
+ from slatex import SlateClassifier
92
+
93
+ rng = np.random.RandomState(0)
94
+ X = rng.randn(500, 8)
95
+ y = (X[:, 0] + 0.5 * X[:, 3] > 0).astype(int)
96
+
97
+ clf = SlateClassifier(budget=32).fit(X, y)
98
+
99
+ clf.predict(X[:5]) # class labels
100
+ clf.predict_proba(X[:5]) # (n_samples, n_classes) probabilities
101
+ clf.score(X, y) # mean accuracy
102
+
103
+ print(clf.n_atoms_) # number of threshold rules used
104
+ print(clf.memory_bytes_) # approximate packed model size in bytes
105
+ ```
106
+
107
+ Multiclass works the same way (handled internally via one-vs-rest), and labels
108
+ can be any type — integers, strings, etc.:
109
+
110
+ ```python
111
+ y = np.array(["low", "mid", "high"])[rng.randint(0, 3, size=500)]
112
+ clf = SlateClassifier(budget=24).fit(X, y)
113
+ clf.classes_ # array(['high', 'low', 'mid'], dtype='<U4')
114
+ ```
115
+
116
+ ## Interpretability
117
+
118
+ Because SLATE is additive, the contribution of each feature is exact and cheap to
119
+ compute.
120
+
121
+ ```python
122
+ # Shape function: how feature 0 contributes to the score across a range of values
123
+ grid = np.linspace(-3, 3, 50)
124
+ contribution = clf.shape_function(feature=0, grid=grid) # binary
125
+ # contribution = clf.shape_function(0, grid, target="high") # multiclass
126
+
127
+ # Exact Shapley attributions against a background sample
128
+ phi = clf.shapley_values(X[:10], X_background=X) # (10, n_features)
129
+ ```
130
+
131
+ ## Hyperparameters
132
+
133
+ | Parameter | Default | Meaning |
134
+ |---|---|---|
135
+ | `budget` | 64 | Hard cap on the number of threshold rules per binary model |
136
+ | `n_bins` | 32 | Max quantile bins per feature (candidate-cut granularity) |
137
+ | `max_iter` | 400 | Max boosting iterations |
138
+ | `learning_rate` | 0.5 | Shrinkage on each Newton step |
139
+ | `l2` | 2.0 | Newton damping (ridge on the Hessian) |
140
+ | `l1` | 1e-3 | Soft-threshold level for pruning weak rules |
141
+ | `corrective_every` | 5 | Run a fully-corrective refit pass every *k* iterations |
142
+ | `corrective_passes` | 2 | Cyclic passes per corrective phase |
143
+ | `tol` | 1e-7 | Stop when the best Newton gain falls below this |
144
+
145
+ Smaller `budget` → smaller, faster, more interpretable model. Increase `n_bins`
146
+ for finer cuts on continuous features.
147
+
148
+ ## scikit-learn compatibility
149
+
150
+ `SlateClassifier` implements `get_params` / `set_params` and follows the standard
151
+ estimator API, so it composes with scikit-learn tools:
152
+
153
+ ```python
154
+ from sklearn.pipeline import make_pipeline
155
+ from sklearn.preprocessing import StandardScaler
156
+ from sklearn.model_selection import GridSearchCV
157
+
158
+ pipe = make_pipeline(StandardScaler(), SlateClassifier())
159
+ grid = GridSearchCV(pipe, {"slateclassifier__budget": [16, 32, 64]}, cv=3)
160
+ grid.fit(X, y)
161
+ ```
162
+
163
+ (scikit-learn is optional and only needed if you use these helpers.)
164
+
165
+ ## Notes and requirements
166
+
167
+ - Inputs must be **finite numeric arrays** (no NaN/inf). Impute or clean first.
168
+ - Training is **deterministic**; `random_state` is accepted for API compatibility
169
+ but does not change results.
170
+ - This is research-grade software released under the MIT License.
171
+
172
+ ## License
173
+
174
+ MIT © Saikiran Gogineni
slatex-0.1.0/README.md ADDED
@@ -0,0 +1,118 @@
1
+ # slatex
2
+
3
+ **Sparse Lightweight Additive Threshold Ensemble** — a small, fast, interpretable
4
+ classifier for constrained hardware (edge devices, microcontrollers, TinyML).
5
+
6
+ SLATE is an additive model (a Generalized Additive Model) built from simple
7
+ threshold rules of the form *"1 if a feature is at or below a learned cut, else 0"*.
8
+ It is trained by L1-regularized Newton boosting: rules are selected one at a time,
9
+ then all active rules are refit together in a corrective pass, while a hard budget
10
+ keeps the model tiny.
11
+
12
+ - **Tiny.** A hard budget caps the number of rules, so a trained model is on the
13
+ order of a kilobyte and inference is a handful of comparisons and adds. The
14
+ fitted model drops its training-time scaffolding, so a pickled/joblib-saved
15
+ estimator is just ~1-2 KB — the same as its live inference footprint.
16
+ - **Interpretable.** Because the model is additive, you get exact per-feature shape
17
+ functions and exact Shapley attributions in closed form.
18
+ - **Lightweight to install.** Pure NumPy at runtime — no heavy ML stack required.
19
+ - **Familiar API.** `fit` / `predict` / `predict_proba`, drops into scikit-learn
20
+ pipelines and grid search. Binary *and* multiclass are supported.
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ pip install slatex
26
+ ```
27
+
28
+ Requires Python 3.9+ and NumPy. To run the test suite you also need
29
+ scikit-learn (`pip install "slatex[test]"`).
30
+
31
+ ## Quickstart
32
+
33
+ ```python
34
+ import numpy as np
35
+ from slatex import SlateClassifier
36
+
37
+ rng = np.random.RandomState(0)
38
+ X = rng.randn(500, 8)
39
+ y = (X[:, 0] + 0.5 * X[:, 3] > 0).astype(int)
40
+
41
+ clf = SlateClassifier(budget=32).fit(X, y)
42
+
43
+ clf.predict(X[:5]) # class labels
44
+ clf.predict_proba(X[:5]) # (n_samples, n_classes) probabilities
45
+ clf.score(X, y) # mean accuracy
46
+
47
+ print(clf.n_atoms_) # number of threshold rules used
48
+ print(clf.memory_bytes_) # approximate packed model size in bytes
49
+ ```
50
+
51
+ Multiclass works the same way (handled internally via one-vs-rest), and labels
52
+ can be any type — integers, strings, etc.:
53
+
54
+ ```python
55
+ y = np.array(["low", "mid", "high"])[rng.randint(0, 3, size=500)]
56
+ clf = SlateClassifier(budget=24).fit(X, y)
57
+ clf.classes_ # array(['high', 'low', 'mid'], dtype='<U4')
58
+ ```
59
+
60
+ ## Interpretability
61
+
62
+ Because SLATE is additive, the contribution of each feature is exact and cheap to
63
+ compute.
64
+
65
+ ```python
66
+ # Shape function: how feature 0 contributes to the score across a range of values
67
+ grid = np.linspace(-3, 3, 50)
68
+ contribution = clf.shape_function(feature=0, grid=grid) # binary
69
+ # contribution = clf.shape_function(0, grid, target="high") # multiclass
70
+
71
+ # Exact Shapley attributions against a background sample
72
+ phi = clf.shapley_values(X[:10], X_background=X) # (10, n_features)
73
+ ```
74
+
75
+ ## Hyperparameters
76
+
77
+ | Parameter | Default | Meaning |
78
+ |---|---|---|
79
+ | `budget` | 64 | Hard cap on the number of threshold rules per binary model |
80
+ | `n_bins` | 32 | Max quantile bins per feature (candidate-cut granularity) |
81
+ | `max_iter` | 400 | Max boosting iterations |
82
+ | `learning_rate` | 0.5 | Shrinkage on each Newton step |
83
+ | `l2` | 2.0 | Newton damping (ridge on the Hessian) |
84
+ | `l1` | 1e-3 | Soft-threshold level for pruning weak rules |
85
+ | `corrective_every` | 5 | Run a fully-corrective refit pass every *k* iterations |
86
+ | `corrective_passes` | 2 | Cyclic passes per corrective phase |
87
+ | `tol` | 1e-7 | Stop when the best Newton gain falls below this |
88
+
89
+ Smaller `budget` → smaller, faster, more interpretable model. Increase `n_bins`
90
+ for finer cuts on continuous features.
91
+
92
+ ## scikit-learn compatibility
93
+
94
+ `SlateClassifier` implements `get_params` / `set_params` and follows the standard
95
+ estimator API, so it composes with scikit-learn tools:
96
+
97
+ ```python
98
+ from sklearn.pipeline import make_pipeline
99
+ from sklearn.preprocessing import StandardScaler
100
+ from sklearn.model_selection import GridSearchCV
101
+
102
+ pipe = make_pipeline(StandardScaler(), SlateClassifier())
103
+ grid = GridSearchCV(pipe, {"slateclassifier__budget": [16, 32, 64]}, cv=3)
104
+ grid.fit(X, y)
105
+ ```
106
+
107
+ (scikit-learn is optional and only needed if you use these helpers.)
108
+
109
+ ## Notes and requirements
110
+
111
+ - Inputs must be **finite numeric arrays** (no NaN/inf). Impute or clean first.
112
+ - Training is **deterministic**; `random_state` is accepted for API compatibility
113
+ but does not change results.
114
+ - This is research-grade software released under the MIT License.
115
+
116
+ ## License
117
+
118
+ MIT © Saikiran Gogineni
@@ -0,0 +1,81 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "slatex"
7
+ dynamic = ["version"]
8
+ description = "Sparse Lightweight Additive Threshold Ensemble — a small, fast, interpretable classifier for edge devices and TinyML."
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = { file = "LICENSE" }
12
+ authors = [
13
+ { name = "Saikiran Gogineni", email = "goginenisaikiran31677@gmail.com" },
14
+ ]
15
+ maintainers = [
16
+ { name = "Saikiran Gogineni", email = "goginenisaikiran31677@gmail.com" },
17
+ ]
18
+ keywords = [
19
+ "machine-learning",
20
+ "interpretable-ml",
21
+ "classifier",
22
+ "generalized-additive-model",
23
+ "gam",
24
+ "boosting",
25
+ "tinyml",
26
+ "edge-ai",
27
+ "sparse-models",
28
+ "explainable-ai",
29
+ ]
30
+ classifiers = [
31
+ "Development Status :: 4 - Beta",
32
+ "Intended Audience :: Science/Research",
33
+ "Intended Audience :: Developers",
34
+ "License :: OSI Approved :: MIT License",
35
+ "Operating System :: OS Independent",
36
+ "Programming Language :: Python :: 3",
37
+ "Programming Language :: Python :: 3.9",
38
+ "Programming Language :: Python :: 3.10",
39
+ "Programming Language :: Python :: 3.11",
40
+ "Programming Language :: Python :: 3.12",
41
+ "Programming Language :: Python :: 3.13",
42
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
43
+ ]
44
+ dependencies = [
45
+ "numpy>=1.21",
46
+ ]
47
+
48
+ [project.optional-dependencies]
49
+ test = [
50
+ "pytest>=7.0",
51
+ "scikit-learn>=1.0",
52
+ ]
53
+ dev = [
54
+ "pytest>=7.0",
55
+ "scikit-learn>=1.0",
56
+ "build",
57
+ "twine",
58
+ ]
59
+
60
+ [project.urls]
61
+ Homepage = "https://github.com/saikirangogineni/slatex"
62
+ Repository = "https://github.com/saikirangogineni/slatex"
63
+ Issues = "https://github.com/saikirangogineni/slatex/issues"
64
+
65
+ [tool.hatch.version]
66
+ path = "src/slatex/__init__.py"
67
+
68
+ [tool.hatch.build.targets.wheel]
69
+ packages = ["src/slatex"]
70
+
71
+ [tool.hatch.build.targets.sdist]
72
+ include = [
73
+ "/src",
74
+ "/tests",
75
+ "/README.md",
76
+ "/LICENSE",
77
+ "/CHANGELOG.md",
78
+ ]
79
+
80
+ [tool.pytest.ini_options]
81
+ testpaths = ["tests"]
@@ -0,0 +1,18 @@
1
+ """slatex — Sparse Lightweight Additive Threshold Ensemble.
2
+
3
+ A small, fast, interpretable classifier for constrained hardware (edge devices,
4
+ microcontrollers, TinyML). SLATE is an additive model (a GAM) built from simple
5
+ threshold rules of the form "1 if a feature is at or below a learned cut, else 0",
6
+ trained by budgeted, L1-regularized Newton boosting.
7
+
8
+ Basic usage
9
+ -----------
10
+ >>> from slatex import SlateClassifier
11
+ >>> clf = SlateClassifier(budget=32).fit(X_train, y_train)
12
+ >>> clf.predict(X_test)
13
+ >>> clf.predict_proba(X_test)
14
+ """
15
+ from .classifier import NotFittedError, SlateClassifier
16
+
17
+ __all__ = ["SlateClassifier", "NotFittedError", "__version__"]
18
+ __version__ = "0.1.0"