Expand description
§Tsetlin Machine
A professional Rust implementation of the Tsetlin Machine algorithm for interpretable machine learning.
§Models
TsetlinMachine- Binary classification (dynamic)SmallTsetlinMachine- Binary classification (compile-time optimized)SparseTsetlinMachine- Memory-efficient inference (5-100x reduction)MultiClass- Multi-class classification (one-vs-all)Regressor- RegressionConvolutional- Image classification with patch extraction
§Clause Types
| Type | Heap | Best For |
|---|---|---|
Clause | Yes | Dynamic dimensions, serde |
SmallClause | No | N ≤ 64, maximum speed |
BitwiseClause | Yes | N ≥ 64, 25-92x speedup |
SmallBitwiseClause | No | 64-256 features, no heap |
SparseClause | Inline | Inference, 5-100x compression |
SparseClauseBank | Yes | CSR batch inference |
§Advanced Features
- Weighted Clauses - Clauses learn weights based on accuracy
- Adaptive Threshold - Dynamic T adjustment during training
- Clause Pruning - Automatic reset of dead/ineffective clauses
- Const Generics - Zero-allocation stack types with loop unrolling
- Lock-Free Parallel Training - Async local voting tallies (ICML 2021)
§Feature Flags
std(default): Standard library supportsimd: SIMD-optimized evaluation (requires nightly)parallel: Parallel training via rayonserde: Serialization support
§Quick Start
use tsetlin_rs::{Config, TsetlinMachine};
let config = Config::builder().clauses(20).features(2).build().unwrap();
let mut tm = TsetlinMachine::new(config, 10);
let x = vec![vec![0, 0], vec![0, 1], vec![1, 0], vec![1, 1]];
let y = vec![0, 1, 1, 0];
tm.fit(&x, &y, 200, 42);
assert!(tm.evaluate(&x, &y) >= 0.75);Re-exports§
Modules§
- error
- Error types for Tsetlin Machine.
- feedback
- Type I and Type II feedback mechanisms.
- utils
- Utility functions for random number generation and helpers.
Structs§
- Advanced
Options - Overview
- Automaton
- Overview
- BitPlane
Bank - Bit-plane storage for automata states.
- Bitwise
Clause - Overview
- Clause
- A clause with 2*n_features automata, weight, and activation tracking.
- Clause
Bank - Structure of Arrays storage for Tsetlin Machine clauses.
- Clause
Filter - Bloom filter for fast clause rejection.
- Clause
Filter Stats - Statistics about a clause filter.
- Config
- Overview
- Config
Builder - Overview
- Conv
Config - Overview
- Convolutional
- Overview
- Early
Stop - Early stopping configuration.
- FitOptions
- Options for training a Tsetlin Machine.
- FitResult
- Result of training.
- Multi
Class - Multi-class Tsetlin Machine using one-vs-all strategy.
- Regressor
- Overview
- Rule
- Overview
- Small
Bitwise Clause - Bitwise clause with compile-time known feature count.
- Small
Clause - A clause with compile-time known feature count.
- Small
Tsetlin Machine - Binary classification Tsetlin Machine with compile-time known dimensions.
- Sparse
Clause - Sparse clause representation storing only active literal indices.
- Sparse
Clause Bank - Sparse clause bank using CSR (Compressed Sparse Row) format.
- Sparse
Memory Stats - Memory usage breakdown for sparse clause bank.
- Sparse
Tsetlin Machine - Sparse Tsetlin Machine for memory-efficient inference.
- Tsetlin
Machine - Overview
Traits§
- Tsetlin
Model - Unified interface for all Tsetlin Machine variants.
- Voting
Model - Extension trait for models with vote-based predictions.
Functions§
- pack_
batch - Overview
- pack_
input - Overview
- pack_
input_ small - Packs binary input into u64 array for bitwise evaluation.
Type Aliases§
- Bitwise
Clause64 - Bitwise clause for 64 features (1 u64 word).
- Bitwise
Clause128 - Bitwise clause for 128 features (2 u64 words).
- Bitwise
Clause256 - Bitwise clause for 256 features (4 u64 words).
- Clause2
- Type alias for 2-feature clause.
- Clause4
- Type alias for 4-feature clause (XOR problems).
- Clause8
- Type alias for 8-feature clause.
- Clause16
- Type alias for 16-feature clause.
- Clause32
- Type alias for 32-feature clause.
- Clause64
- Type alias for 64-feature clause.
- TM2x20
- 2-feature, 20-clause machine (XOR).
- TM4x40
- 4-feature, 40-clause machine.
- TM8x80
- 8-feature, 80-clause machine.
- TM16x160
- 16-feature, 160-clause machine.