Use Trained Models Programmatically¶
Every model_rndNN.joblib in a results folder is a fitted sklearn
Pipeline. This page shows how to work with its parts directly — for plain
predictions see Inference.
What is inside the pipeline¶
| Step name | Contents |
|---|---|
"preprocessor" |
Fitted CustomPreprocessor (encodes categoricals, scales numerics, …) |
"regressor" |
Fitted regressor |
Plus a coremat_export_meta_ attribute:
| Key | Description |
|---|---|
"target_name" |
Name of the predicted column |
"features" |
The columns the pipeline was trained on |
"x_tx" |
The fitted feature transforms, or None without any |
"y_tx" |
The fitted target transform, or None without one — see Inference |
import joblib
import pandas as pd
pipe = joblib.load(
"data/results/yield_strength_experiment/lin__ridge/round_03/model_rnd03.joblib"
)
X_new = pd.read_csv("new_alloys.csv")
X_new = X_new[pipe.coremat_export_meta_["features"]]
y_pred = pipe.predict(X_new) # full pipeline
X_pre = pipe.named_steps["preprocessor"].transform(X_new) # preprocessed features only
reg = pipe.named_steps["regressor"] # bare fitted regressor
Which round to load: use the stored best_round (the delivered round, selected in the
round-scores CSV) unless
you have a domain-driven reason for another round — the per-round scores are in
csv_<model_id>_res_round_scores.csv.
Exact hyperparameters
The Model Report's Reproduction panel (under each round's tabs) shows the estimator class, library versions, feature list, transforms, split recipe, a copy-paste snippet with the exact Optuna hyperparameters, and the preprocessing parameters.
TabPFN: extract per-sample embeddings¶
TabPFN builds an internal representation vector for every input row. These
per-sample embeddings can serve as input for a downstream autoencoder or
clustering step. Extraction is three lines on top of the loading code above, with a
TabPFN pipeline loaded (e.g. fm__tabpfn__v3/round_03/model_rnd03.joblib):
X_pre = pipe.named_steps["preprocessor"].transform(X_new)
reg = pipe.named_steps["regressor"]
tabpfn = getattr(reg, "_model", reg) # unwrap device-fallback adapter if present
emb = tabpfn.get_embeddings(X_pre) # shape: (n_estimators, n_samples, embedding_dim)
Line by line:
- Preprocess —
get_embeddingsexpects the same encoded feature space the model was trained on, so apply the pipeline's preprocessor first. - Unwrap — COREMat may wrap the
TabPFNRegressorin a device-fallback adapter that holds the real model under._model. Thegetattrcall works for both the wrapped and unwrapped case. - Extract —
get_embeddingsreturns one vector per sample and ensemble member.
With the default config n_estimators is 1, so emb[0] gives the usual
(n_samples, embedding_dim) matrix. For multi-estimator runs, average with
emb.mean(axis=0).
Embeddings, not weights
TabPFN's network weights are fixed — they never change during training.
What is dataset-specific are these in-context per-sample representations,
which is exactly what get_embeddings returns.
The recipe is TabPFN-specific; there is no generic export-embeddings CLI.