Saltar al contenido principal

ScoreClustersUnit

Unit
DashAI.back.units.ScoreClustersUnit

Score a fitted clustering over every row of the features it was fitted on.

Reads the cluster labels off the model, refuses a clustering that has nothing to measure, and scores the labels with each metric. The scores are published as {"full": {metric name: score}} -- the shape EvaluateModelToArtifactUnit gives its metrics -- and nothing is written: whoever ran the unit decides where they go. A job writes them as Metric rows; a pipeline keeps them as an artifact.

Three failures are reported apart, each with the text it always had:

  • the labels cannot be read: "Model training failed ...", because to the user the labels are what training produced;
  • fewer than two clusters, or one per point: the internal validity indices are not defined there, so the run has no result to report;
  • a metric raises: "Metric calculation failed ...".

A metric that answers None (undefined for these labels) or a non-finite number is left out of the result rather than recorded, the same rule BaseModel._score_split applies to supervised scores: a NaN that reaches a comparison poisons every one downstream of it.

Parameters​

metrics : array, default=['Silhouette', 'DaviesBouldin', 'CalinskiHarabasz']
Clustering metrics to score the fitted model with, by name.

Methods​

execute(self, ctx: DashAI.back.units.context.ExecutionContext) -> None

Defined on ScoreClustersUnit

Do the unit's work, reading from and writing to the context.

Parameters

ctx : ExecutionContext
The shared execution context.

validate(self, ctx: DashAI.back.units.context.ExecutionContext) -> None

Defined on ScoreClustersUnit

Check preconditions without executing the unit.

Parameters

ctx : ExecutionContext
The shared execution context.

get_credential(self, name: str)

Defined on ConfigObject

Resolve a registered credential component by name.

Parameters

name : str
Credential component class name (e.g. "HuggingFaceCredential").

Returns

BaseCredential
An instance of the requested credential component.

get_schema(cls) -> dict

Defined on ConfigObject

Generates the component related Json Schema.

Returns

dict
Dictionary representing the Json Schema of the component.

validate_and_transform(self, raw_data: dict) -> dict

Defined on ConfigObject

It takes the data given by the user to initialize the model and returns it with all the objects that the model needs to work.

Parameters

raw_data : dict
A dictionary with the data provided by the user to initialize the model.

Returns

dict
A validated dictionary with the necessary objects.