Skip to contents

Validates a candidate clustering result returned by KmeansInference::kmeans_inference() for a given seed: it must have exactly NC distinct clusters, and both requested clusters must be present among them. Stops with an informative error asking the user to try a different seed otherwise.

Usage

validate_km_candidate(candidate, NC, clusters, seed)

Arguments

candidate

The output of KmeansInference::kmeans_inference().

NC

Integer scalar giving the number of clusters.

clusters

Integer vector of length 2 specifying the pair of clusters to compare. Entries must belong to 1:NC.

seed

The seed used to produce candidate (or NULL), only used to compose the error message.

Value

candidate, unchanged, if it is valid.