Skip to main content

tlmnet

CI PyPI Version Python Version Documentation License

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.sparse matrices (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_limit before 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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tlmnet-0.1.0.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tlmnet-0.1.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

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

Hashes for tlmnet-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5d5e0a2af4e0f9ee5a7c8d320be1e967bdf54e435780a64aaf7c60b3d1ce106b
MD5 0911c5e64b39032b2dd7a35fa5a92091
BLAKE2b-256 ec432befabf8f26ae0972288d1b1615a5d77d8ba1e39562a75af4dee391f625a

See more details on using hashes here.

Provenance

The following attestation bundles were made for tlmnet-0.1.0.tar.gz:

Publisher: release-pypi.yml on carlson-research/tlmnet

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for tlmnet-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b1bbaf5ad84e7923ce1254fcd9e884b2f2a69f2417b3a82b2e750eb8555589ac
MD5 479104ae96affd0710fda378bf720fab
BLAKE2b-256 5f93d7bc625f73c4091adbb3ca90323734df38ce4f1208fababbe296655fddbf

See more details on using hashes here.

Provenance

The following attestation bundles were made for tlmnet-0.1.0-py3-none-any.whl:

Publisher: release-pypi.yml on carlson-research/tlmnet

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page