tlmnet
tlmnet provides exact Mixed-Integer Linear Programming (MILP) solvers for Quantized Statistical Learning with Ternary Linear Models (TLMs).
By restricting coefficients to discrete ternary values ($w_j \in {-1, 0, 1}$), it constructs globally optimal, sparse, and interpretable classifiers compliant with Scikit-Learn 1.6+ API standards.
Features
- Exact Discrete Weights: Solves for ternary coefficients $w_j \in {-1, 0, 1}$ directly using branch-and-bound optimization via
scipy.optimize.milp. - Exact $L_0$ Cardinality Constraints: Enforces strict integer feature selection budgets ($\sum \vert{}w_j\vert{} \le k$) using
max_features. - Native Sparse Data Support: Efficiently processes high-dimensional
scipy.sparsematrices (CSR,CSC,COO) using sparse block constraint assembly. - Scikit-Learn Compatibility: Plugs directly into
Pipeline,OneVsRestClassifier,GridSearchCV, and standard estimator workflows. - Timeout & Incumbent Recovery: Automatically returns the best feasible integer solution found if the solver reaches
time_limitbefore proving global optimality.
Installation
Install tlmnet directly from PyPI:
pip install tlmnet
Quick Start Example
from tlmnet import TlmMilpClassifier
from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler
# Generate synthetic classification dataset
X, y = make_classification(
n_samples=200, n_features=15, n_informative=5, random_state=42
)
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)
# Build pipeline with standardization and exact MILP classification
clf = make_pipeline(
StandardScaler(),
TlmMilpClassifier(max_features=5, C=1.0, time_limit=30.0)
)
clf.fit(X_train, y_train)
# Inspect model properties
tlm_model = clf.named_steps["tlmmilpclassifier"]
print("Ternary Coefficients:", tlm_model.coef_)
print("Test Accuracy:", clf.score(X_test, y_test))
License
This project is licensed under the BSD-3-Clause License.
Authors
- Author & Maintainer: Rolf Carlson (rolf@hrolfrc.com)
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tlmnet-0.1.0.tar.gz.
File metadata
- Download URL: tlmnet-0.1.0.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d5e0a2af4e0f9ee5a7c8d320be1e967bdf54e435780a64aaf7c60b3d1ce106b
|
|
| MD5 |
0911c5e64b39032b2dd7a35fa5a92091
|
|
| BLAKE2b-256 |
ec432befabf8f26ae0972288d1b1615a5d77d8ba1e39562a75af4dee391f625a
|
Provenance
The following attestation bundles were made for tlmnet-0.1.0.tar.gz:
Publisher:
release-pypi.yml on carlson-research/tlmnet
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tlmnet-0.1.0.tar.gz -
Subject digest:
5d5e0a2af4e0f9ee5a7c8d320be1e967bdf54e435780a64aaf7c60b3d1ce106b - Sigstore transparency entry: 2851490728
- Sigstore integration time:
-
Permalink:
carlson-research/tlmnet@1107565070d268ea896253e2b4a90974746ef957 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/carlson-research
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@1107565070d268ea896253e2b4a90974746ef957 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tlmnet-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tlmnet-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1bbaf5ad84e7923ce1254fcd9e884b2f2a69f2417b3a82b2e750eb8555589ac
|
|
| MD5 |
479104ae96affd0710fda378bf720fab
|
|
| BLAKE2b-256 |
5f93d7bc625f73c4091adbb3ca90323734df38ce4f1208fababbe296655fddbf
|
Provenance
The following attestation bundles were made for tlmnet-0.1.0-py3-none-any.whl:
Publisher:
release-pypi.yml on carlson-research/tlmnet
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tlmnet-0.1.0-py3-none-any.whl -
Subject digest:
b1bbaf5ad84e7923ce1254fcd9e884b2f2a69f2417b3a82b2e750eb8555589ac - Sigstore transparency entry: 2851490767
- Sigstore integration time:
-
Permalink:
carlson-research/tlmnet@1107565070d268ea896253e2b4a90974746ef957 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/carlson-research
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@1107565070d268ea896253e2b4a90974746ef957 -
Trigger Event:
push
-
Statement type: