Skip to main content

Module ensemble

Module ensemble 

Source

Modules§

aggregate
Temperature-scaled softmax and the classification/regression ensemble-combination paths from TabFMClassifier._process_logits / TabFMRegressor._combine_predictions.
calibration
Platt scaling (binary) and vector scaling (multiclass) output calibration, fit on out-of-fold probabilities (see oof.rs). The wrapper fits these via scipy.optimize.minimize (L-BFGS-B) on a regularized negative-log-likelihood; this ports the same objective but optimizes it with an in-house box-constrained coordinate descent (golden-section line search per coordinate) — expect looser numerical agreement than the always-on ensembling path, which matches the real optimizer’s exact trajectory less closely by construction.
cat_encoder
CategoricalOrdinalEncoder (cat_encoder_mode="appearance", the wrapper’s default): assigns integer codes to a categorical column’s values in order of first appearance in the training data; unknown/missing values (at fit or transform time) map to -1.
config_gen
Ports TabFMClassifier/TabFMRegressor’s _generate_ensemble() — builds the n_estimators member configs (feature permutation, classification class-shift offset, categorical-value permutation, row-subsample pattern, normalization method). RNG consumption order matches the source exactly (see the plan doc / module comments below) so results are bit-identical to the real wrapper for the same random_state.
nnls
Lawson-Hanson active-set NNLS (scipy.optimize.nnls’s algorithm): solves min ||Ax - b||^2 subject to x >= 0. Self-contained (no external linear-algebra crate) — columns are few (n_estimators <= 32), so dense Gaussian elimination on the small passive-set normal-equations system is more than adequate.
oof
Out-of-fold (OOF) prediction generation, used to fit calibration/NNLS. Fold splitting uses our own seeded shuffle (PyRandom) rather than sklearn’s KFold(shuffle=True), which draws from NumPy’s legacy RandomState — a related but distinct RNG family we haven’t ported (see the plan’s scoping note). Statistically equivalent, not bit-identical.
orchestrate
Orchestrates one full ensemble-predict call: builds the n_estimators member configs, runs each member’s preprocessing + a single TabFMModel::predict forward pass (reusing the core model unchanged), then aggregates — optionally applying calibration/NNLS ensemble weighting fit via oof.rs’s out-of-fold procedure.
pyrandom
A bit-compatible port of CPython’s random.Random (Mersenne Twister, MT19937), so ensemble member generation can be validated numerically against the real TabFMClassifier/ TabFMRegressor sklearn wrapper (which seeds random.Random(random_state) and calls .sample()/.shuffle() in a specific order — see config_gen.rs).
scalers
Per-column feature scalers, ported from tabfm/src/classifier_and_regressor.py’s PreprocessingPipeline, applied in this exact order: CustomStandardScaler -> one of 5 optional normalizers (if not "none") -> OutlierRemover (last, not second — verified against PreprocessingPipeline.fit). Each scaler exposes fit/transform mirroring sklearn’s split so the same fitted state (from training columns) can be applied to held-out columns.

Functions§

with_thread_pool
Runs f inside a dedicated rayon thread pool of threads workers, or on rayon’s own global default pool (all logical cores, or RAYON_NUM_THREADS if set) when threads is None. Shared by the CLI (--threads) and the Python bindings (n_threads) so both tune the same underlying configs.par_iter() loops in orchestrate.rs/oof.rs.