spacr.classify¶
One Classify entry point over both classifier families.
Classify (CV) trains a Torch model on object crops. Classify (ML) fits a gradient-boosted model on measured features. They answer the same question – which class is this object – and until now they were two modules that shared six setting names out of 78 and 37, two of which disagreed on their default.
spacr.training_basis already unified what defines a CLASS. This module
unifies what runs: one settings dict, one classifier_family switch, one
call. The two original modules stay exactly as they are – a merged screen
that removed them would strand every saved settings CSV and every notebook
that imports their entry points.
Nothing here reimplements either pipeline. deep_spacr and
generate_ml_scores are called unchanged, which is what makes the merged
module honest: a run through it and a run through the module it dispatches to
produce the same result, because they are the same code.
Exceptions¶
A classifier family spaCR does not have. |
Functions¶
|
Run whichever classifier family |
|
Settings belonging to the OTHER family -- what the panel greys out. |
|
Return the classifier family a settings dict asks for. |
|
Return the classical-ML estimator selected by |
Module Contents¶
- exception spacr.classify.ClassifierFamilyError[source]¶
Bases:
ValueErrorA classifier family spaCR does not have.
Initialize self. See help(type(self)) for accurate signature.
- spacr.classify.classify(settings: Mapping[str, Any]) Any[source]¶
Run whichever classifier family
settingsasks for.The merged module’s pipeline entry point. It normalises the shared vocabulary, resolves the family, and calls the existing entry point unchanged – so a run here and a run through Classify (CV) or Classify (ML) are the same run, not two implementations that have to be kept in step.
- Parameters:
settings – the run settings.
- Returns:
whatever the dispatched pipeline returns.
- Raises:
ClassifierFamilyError – an unrecognised family.
ValueError – when pre-dispatch validation rejects the selected ML estimator or CV crop source.
- spacr.classify.inapplicable_settings(family: str) Tuple[str, ...][source]¶
Settings belonging to the OTHER family – what the panel greys out.
Greyed, never removed: INVARIANTS §6. A key absent from the dict makes the pipeline fall back to its own default, which can differ from the value the module needs and says nothing when it does.
- Parameters:
family – the chosen family.
- Returns:
setting keys the other family owns.
- Raises:
ClassifierFamilyError – unknown family.
- spacr.classify.resolve_family(settings: Mapping[str, Any]) str[source]¶
Return the classifier family a settings dict asks for.
Defaults to
'cv', because the merged module’s own default settings are the CV ones and a dict with no family is most likely a Classify (CV) CSV opened in the merged screen.- Parameters:
settings – the run settings.
- Returns:
'cv'or'ml'.- Raises:
ClassifierFamilyError – an unrecognised family. Guessing would train a different kind of model than the user asked for and report success.
- spacr.classify.resolve_ml_model_type(settings: Mapping[str, Any]) str[source]¶
Return the classical-ML estimator selected by
settings.model_type_mlis authoritative in a merged payload.model_typeis accepted only when the ML-specific key is absent, which migrates the short-lived shared-vocabulary settings files written before the two model controls were separated. The default matchesspacr.settings.set_default_analyze_screen().- Parameters:
settings – settings for an ML-family run.
- Returns:
a member of
ML_MODEL_TYPES.- Raises:
ValueError – when the selected value is not an ML estimator.