mescla.emma.archetypes.ArchetypeResult

class mescla.emma.archetypes.ArchetypeResult(archetypes, weights, support, rss, tss, n_iter, converged, seed, restart_rss, space, samples, species, hull_fraction=None, diagnostics=<factory>)[source]

Bases: object

Archetypes fitted to a set of water samples.

Variables:
  • archetypes (EndMembers) – The k hull points, back-transformed to concentration units. These are candidates: real chemistry has to recognise them before they are end-members.

  • weights (ndarray, shape (n_samples, n_archetypes)) – Reconstruction weights. Non-negative, rows sum to one, and not mixing ratios – see the module docstring and ratios.

  • support (ndarray, shape (n_archetypes, n_samples)) – How each archetype is built from the samples. A row concentrated on one sample is a single-sample end-member with all the fragility that implies; a row spread over several is the thing that answers “we have no replicates”.

  • tss (rss,) – Residual and total sum of squares in standardised space.

  • explained_variance (float) – 1 - rss / tss.

  • hull_fraction (float or None) – Fraction of samples enclosed by the archetypes, when fitted through mescla.emma.model.EMMA.archetypes() so that U-space is defined.

  • restart_rss (ndarray) – Objective reached by each restart. When only a minority of restarts reach the best value the optimum is not being found reliably – see restarts_at_best and run archetype_stability().

Parameters:
archetypes: EndMembers
weights: ndarray
support: ndarray
rss: float
tss: float
n_iter: int
converged: bool
seed: int
restart_rss: ndarray
space: str
samples: tuple[str, ...]
species: tuple[str, ...]
hull_fraction: float | None = None
diagnostics: dict[str, Any]
property ratios: ndarray

Always raises. Archetypal weights are not mixing ratios.

as_endmembers(labels=None)[source]

The archetypes, ready to hand to a mixing estimator.

Rename them as you go: an end-member called A2 has not been interpreted, and interpreting it against the conceptual model is the step that turns a hull point into a source.

Parameters:

labels (list[str] | tuple[str, ...] | None)

Return type:

EndMembers

property n_archetypes: int
archetypes_frame()[source]

Archetype compositions in concentration units.

Return type:

pd.DataFrame

weights_frame()[source]

Reconstruction weights. Read ratios before you treat these as shares.

Return type:

pd.DataFrame

support_frame(top=5)[source]

Which real samples define each archetype, and how strongly.

n_effective is the inverse participation ratio of the support weights: roughly how many samples the archetype actually rests on. Close to 1 means it is one analysis wearing a hat, and its uncertainty is assumed rather than measured – exactly the limitation that jackknifing over replicates exists to remove.

Parameters:

top (int)

Return type:

pd.DataFrame

negative_species()[source]

Species an archetype pushes below zero – a physically impossible water.

Not fatal (the fit is done in standardised space, where nothing forbids it) but it means the archetype has been extrapolated past any real water, and it should not be used as an end-member without comment.

Return type:

dict[str, list[str]]

summary()[source]

A readable paragraph, cautions included – paste it into your notes.

Return type:

str

property restarts_at_best: float

Fraction of restarts landing within 1% of the best objective.

The honest measure of whether a non-convex fit found its optimum. Near 1 means the vertices are easy to find; a small value means most starting points end somewhere else, and the single answer you are looking at is one of several.

property explained_variance: float