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)
Metadata
Release files for tlmnet 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tlmnet-0.1.0.tar.gz | 6.8 kB | With provenance | Details for tlmnet-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tlmnet-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for tlmnet-0.1.0-py3-none-any.whl |
Total release size: 13.2 kB
Release files / tlmnet-0.1.0.tar.gz
| Download URL | tlmnet-0.1.0.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5d5e0a2af4e0f9ee5a7c8d320be1e967bdf54e435780a64aaf7c60b3d1ce106b
|
|
BLAKE2b-256 checksum How to use checksums |
ec432befabf8f26ae0972288d1b1615a5d77d8ba1e39562a75af4dee391f625a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.
Transparency logRelease files / tlmnet-0.1.0-py3-none-any.whl
| Download URL | tlmnet-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b1bbaf5ad84e7923ce1254fcd9e884b2f2a69f2417b3a82b2e750eb8555589ac
|
|
BLAKE2b-256 checksum How to use checksums |
5f93d7bc625f73c4091adbb3ca90323734df38ce4f1208fababbe296655fddbf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.
Transparency logSecurity for tlmnet 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for tlmnet-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.