Green Tsetlin
Installation
Green Tsetlin can be installed by the following:
pip install green-tsetlin
Documentation
The documentation can be found on: https://green-tsetlin.readthedocs.io/
Below is some short examples of some of the capabilities of green-tsetlin.
Tsetlin Machine
The Tsetlin Machine is the core of Green Tsetlin. Here a dense (regular) TM:
import green_tsetlin as gt
tm = gt.TsetlinMachine(n_literals=4,
n_clauses=5,
n_classes=2,
s=3.0,
threshold=42,
literal_budget=4
)
Sparse Tsetlin Machine
The Tsetlin Machine is the core of Green Tsetlin. Here a sparse TM:
import green_tsetlin as gt
tm = gt.SparseTsetlinMachine(n_literals=4,
n_clauses=5,
n_classes=2,
s=3.0,
threshold=42,
literal_budget=4,
)
Trainer
Use the Trainer to fit a Tsetlin Machine to the data.
The trainer class is used for both sparse and dense data and TMs.
import green_tsetlin as gt
# set n_jobs = 1 to run single threaded
trainer = gt.Trainer(tm, seed=42, n_jobs=1)
trainer.set_train_data(train_x, train_y)
trainer.set_eval_data(eval_x, eval_y)
trainer.train()
Exporting Tsetlin Machines
Exporting trained Tsetlin Machines.
.
.
tm.save_state("tsetlin_state.npz")
Loading exported Tsetlin Machines
Loading trained Tsetlin Machines to continue training or use for inference.
.
.
tm.load_state("tsetlin_state.npz")
Inference
Inference with trained Tsetlin Machines.
.
.
predictor = tm.get_predictor()
predictor.predict(x)
Green Tsetlin hpsearch
With the built-in hyperparameter search you can optimize your Tsetlin Machine parameters.
from green_tsetlin.hpsearch import HyperparameterSearch
hyperparam_search = HyperparameterSearch(s_space=(2.0, 20.0),
clause_space=(5, 10),
threshold_space=(3, 20),
max_epoch_per_trial=20,
literal_budget=(1, train_x.shape[1]),
search_or_use_boost_true_positives=(False, True),
seed=42,
n_jobs=5,
k_folds=4,
minimize_literal_budget=False)
hyperparam_search.set_train_data(train_x, train_y)
hyperparam_search.set_eval_data(test_x, test_y)
hyperparam_search.optimize(n_trials=10)
Metadata
Release files for green-tsetlin 1.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 |
|---|---|---|---|---|
| green_tsetlin-1.1.0.tar.gz | 653.8 kB | Without provenance | Details for green_tsetlin-1.1.0.tar.gz |
Release files / green_tsetlin-1.1.0.tar.gz
| Download URL | green_tsetlin-1.1.0.tar.gz |
|---|---|
| Size | 653.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
495dc268ba3592a45032d234ae3b46a4c43cf47652de24003dc781db29824e36
|
|
BLAKE2b-256 checksum How to use checksums |
fb3c6f29100b5063a64bebcd6eb6d8d3fada3733a145c044aaa3bb1a37a6f20e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Security for green-tsetlin 1.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.