From 90ca567230dce39681ed5b826b438dd8391dbd8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eneko=20Uru=C3=B1uela?= Date: Wed, 16 Mar 2022 19:11:46 +0100 Subject: [PATCH] Return variance explained for all components (#50) --- mapca/mapca.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mapca/mapca.py b/mapca/mapca.py index 2350247..3de0b3e 100644 --- a/mapca/mapca.py +++ b/mapca/mapca.py @@ -100,16 +100,20 @@ class MovingAveragePCA: - 'n_components': The number of components chosen by the MDL criterion. - 'value': The MDL curve values. - 'explained_variance_total': The total explained variance of the components. - varexp_90 : dict + varexp_90_ : dict Dictionary containing the 90% variance explained results: - 'n_components': The number of components chosen by the 90% variance explained criterion. - 'explained_variance_total': The total explained variance of the components. - varexp_95 : dict + varexp_95_ : dict Dictionary containing the 95% variance explained results: - 'n_components': The number of components chosen by the 95% variance explained criterion. - 'explained_variance_total': The total explained variance of the components. + all_ : dict + Dictionary containing the results for all possible components: + - 'n_components': Total number of possible components. + - 'explained_variance_total': The total explained variance of the components. References ---------- @@ -336,6 +340,10 @@ def _fit(self, img, mask): "n_components": n_comp_varexp_95, "explained_variance_total": cumsum_varexp[n_comp_varexp_95 - 1], } + self.all_ = { + "n_components": ppca.n_components_, + "explained_variance_total": cumsum_varexp, + } # Assign attributes from model self.components_ = ppca.components_[:n_components, :]