NearestCentroidAssigner
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 NearestCentroidAssigner(model: HabitatModel)[source]
Bases:
objectAssign each supervoxel to the habitat of its nearest centroid.
The fitted model is bound at construction time – the ordinary way to obtain this assigner is
model.assigner(). Prediction then has no way to re-learn anything, because everything it needs is inside the model; this is what enforces train/predict consistency structurally.Habitat ids are the centroid row indices plus one, so label
0is reserved for background, matching the v0.1 label-image convention.- Parameters:
model – The fitted habitat definition to project.
- __init__(model: HabitatModel) None[source]
- property model: HabitatModel
Return the fitted habitat definition this assigner projects.
- __call__(supervoxel_map: Supervoxelization) HabitatMap[source]
Project the fitted habitat definition onto one subject.
- Parameters:
supervoxel_map – Supervoxelization of the subject to label.
- Returns:
The subject’s habitat label image, tagged with the model’s id.
- Raises:
CompatibilityError – If the supervoxel features lack a feature the model requires, or a label has no feature row.
Examples using habit.habitat_model.NearestCentroidAssigner
/auto_examples/06_parallel_runs/plot_06_reuse_workers