mescla.emma.archetypes.archetype_stability

mescla.emma.archetypes.archetype_stability(X, n_archetypes, *, n_seeds=10, n_restarts=5, seed=0, standardize=True, **kwargs)[source]

Refit from different seeds and ask whether the same vertices come back.

The objective is not convex, so a single fit is an anecdote. For each pair of fits, every archetype of one is matched to its nearest archetype in the other and the distance recorded, in standardised units and relative to the spread of the samples themselves.

A relative displacement of a few per cent means the vertices are being found reliably. Large values mean the optimum is not well determined – most often because n_archetypes is too large for the structure actually present, which makes this a rank diagnostic as much as a numerical one.

Returns:

DataFrame – One row per archetype: mean and maximum displacement across seed pairs, both absolute and relative to the sample spread.

Parameters:
  • X (Any)

  • n_archetypes (int)

  • n_seeds (int)

  • n_restarts (int)

  • seed (int)

  • standardize (bool)

  • kwargs (Any)

Return type:

pd.DataFrame