SearchResult

Note

This page is a reference documentation. It only explains the class signature, and not how to use it. Please refer to the Habitat Guide and Python API guide (v2.0) for usage.

class SearchResult(spec: MLSpec, best_params: Mapping[str, Any], best_score: float, objective: str, trials: Tuple[Mapping[str, Any], ...], manifest: RunManifest, model: ModelResult | None = None)[source]

Bases: object

Outcome of search_hyperparameters(), entirely in memory.

spec

The TUNED modelling definition – the input spec with every searched parameter replaced by its winning value, in the same field layout it was declared in. This is the publishable artefact of a search: it fingerprints, serialises back to YAML and re-runs, so the tuning step never breaks the provenance chain the way a fitted-object-only result would.

Type:

habit.spec.specs.MLSpec

best_params

Winning parameters, keyed exactly as the grid was ("model__component__C"), so a caller can compare them against what it asked for without re-deriving the key syntax.

Type:

Mapping[str, Any]

best_score

Cross-validated score of the winning candidate, in the objective metric’s OWN direction (higher is better for auc, lower for mae) – never scikit-learn’s internally negated form, which would silently flip the sign of a reported number.

Type:

float

objective

Name of the metric that was optimised.

Type:

str

trials

One record per evaluated candidate: params, mean_score, std_score (across the search folds) and rank. This is the tuning table a methods section reports.

Type:

Tuple[Mapping[str, Any], …]

manifest

Record of what ran, fingerprinting the TUNED spec.

Type:

habit.contracts.manifest.RunManifest

model

The final model, refitted on the whole table with spec; None when the caller asked for the tuned spec only (refit=False), which is what nested cross-validation does since it refits on its own outer training rows.

Type:

habit.recipes.modeling.ModelResult | None

__init__(spec: MLSpec, best_params: Mapping[str, Any], best_score: float, objective: str, trials: Tuple[Mapping[str, Any], ...], manifest: RunManifest, model: ModelResult | None = None) → None