mescla.emma.archetypes.archetypal_analysis¶
- mescla.emma.archetypes.archetypal_analysis(X, n_archetypes, *, n_restarts=10, seed=0, max_iter=200, tol=1e-06, standardize=True, standardizer=None)[source]¶
Fit
n_archetypeshull points to water samples.- Parameters:
X (WaterChemistry, DataFrame or array) – Mixed samples. Candidate end-members do not belong here, for the same reason they are kept out of
mescla.emma.model.EMMA.fit(): they would help define the hull they are supposed to be judged against.n_archetypes (int) – Usually
EMMA.n_endmembers, i.e.k + 1. Compare ranks witharchetype_rss_curve()rather than assuming.n_restarts (int, default 10) – Restarts from different initialisations; the best objective wins and the spread across restarts is reported. The objective is not convex, so this is not optional decoration.
seed (int, default 0) – Fixed so a fitted result is reproducible. It is recorded in the result.
standardize (bool, default True) – Z-score first, as EMMA does, so a large-concentration species does not define the hull on its own.
standardizer (Standardizer, optional) – A standardiser already fitted on these samples. Supply it to keep one standardisation across an analysis.
max_iter (int)
tol (float)
- Returns:
ArchetypeResult
- Return type:
Notes
The fit is a candidate-generation step. See the module docstring for the four cautions that come with it;
ArchetypeResult.summary()restates them.Examples
>>> res = archetypal_analysis(samples, 3) >>> print(res.summary()) >>> res.archetypes_frame() # candidate compositions >>> ratios = mixing_ratios(res.as_endmembers(), samples) # ratios come from here