models.probe_transformer.ProbeTransformerClassifier
models.probe_transformer.ProbeTransformerClassifier(path_model, index=None)A published ProbeTransformer ensemble, ready to predict a region per channel.
A release ships one transformer per random seed under artifacts.seeds (weights + per-seed feature scaler); the single config.model_config and inputs.features describe them all. predict standardises with each seed’s own scaler, runs one probe at a time, and averages the per-class probabilities.
Attributes: path_model (Path): Local model directory. index (dict): Contents of ephysatlas_model.json (the publication manifest). config (dict): Manifest config block – class ids, acronyms, region map, model config. inputs (dict): Manifest inputs block – feature list and the position column name.
Methods
| Name | Description |
|---|---|
| predict | Predict a brain region per channel. |
| selftest | Reproduce the shipped golden predictions, if the model ships an example. |
predict
models.probe_transformer.ProbeTransformerClassifier.predict(
df,
estimator='ensemble',
)Predict a brain region per channel.
Args: df (pd.DataFrame): Features, indexed by (pid, channel). Must contain every column in the manifest’s features plus the position column (axial_um). Channels with any non-finite feature are dropped, so the result may be a subset of df. estimator (str, optional): "ensemble" (default) averages every seed and reports seed_agreement; "global" uses the first seed alone, at a fraction of the cost, with seed_agreement returned as NaN.
Returns: pd.DataFrame: Indexed like the surviving rows of df, with predicted_acronym, predicted_atlas_id, prediction_probability (probability of the winning class), seed_agreement (fraction of seeds voting for the winner), and one p_<acronym> column per class. Prediction columns are namespaced so df.join(out) cannot collide with histology-derived acronym/atlas_id columns.
Raises: KeyError: If a required feature or the position column is absent, naming it. ValueError: If the manifest’s feature list no longer matches its recorded digest.
selftest
models.probe_transformer.ProbeTransformerClassifier.selftest(
rtol=0.0001,
atol=1e-05,
)Reproduce the shipped golden predictions, if the model ships an example.
Turns silent numerical drift (a changed scaler, an incompatible torch, a reordered class vector) into one explicit failure. The tolerances are loose because these are float32 transformer outputs that drift ~1e-4 across environments – a genuine reproduction.
Raises: FileNotFoundError: If the model does not ship example/ files. AssertionError: If the predictions differ.