From 608ea1310f1797ae95fb081bb928129e7c4727c9 Mon Sep 17 00:00:00 2001 From: Alex Itkes <38556752+alexitkes@users.noreply.github.com> Date: Fri, 12 Jul 2019 23:20:35 +0300 Subject: [PATCH 01/13] Update documentation to NMF Describe the n_components_ attribute in addition to n_components parameter. The will differ it no n_components value given to the constructor. --- sklearn/decomposition/nmf.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sklearn/decomposition/nmf.py b/sklearn/decomposition/nmf.py index ae624e2a1b4ab..8282ff6ae495d 100644 --- a/sklearn/decomposition/nmf.py +++ b/sklearn/decomposition/nmf.py @@ -1192,6 +1192,11 @@ class NMF(BaseEstimator, TransformerMixin): components_ : array, [n_components, n_features] Factorization matrix, sometimes called 'dictionary'. + n_components_ : integer + The number of components. It is same to the `n_components` parameter + if it was given. Otherwise, it will be same with the number of + features. + reconstruction_err_ : number Frobenius norm of the matrix difference, or beta-divergence, between the training data ``X`` and the reconstructed data ``WH`` from From 2c2315fb9512878fc36f16517839771f85c4cf6f Mon Sep 17 00:00:00 2001 From: Alex Itkes <38556752+alexitkes@users.noreply.github.com> Date: Sat, 13 Jul 2019 06:14:48 +0300 Subject: [PATCH 02/13] Fix typo in docstring for GaussianRandomProjection There is an attribute named n_components_, not n_component_ --- sklearn/random_projection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/random_projection.py b/sklearn/random_projection.py index f4fa2c608b842..210769c1781fb 100644 --- a/sklearn/random_projection.py +++ b/sklearn/random_projection.py @@ -453,7 +453,7 @@ class GaussianRandomProjection(BaseRandomProjection): Attributes ---------- - n_component_ : int + n_components_ : int Concrete number of components computed when n_components="auto". components_ : numpy array of shape [n_components, n_features] From 1f4a01e606c0bb8e9bbe92cad8ddd0d000e1b150 Mon Sep 17 00:00:00 2001 From: Alex Itkes <38556752+alexitkes@users.noreply.github.com> Date: Sat, 13 Jul 2019 08:15:11 +0300 Subject: [PATCH 03/13] Update docstring for SparseRandomProjection The n_components_ attribute was referred to as n_component_ --- sklearn/random_projection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/random_projection.py b/sklearn/random_projection.py index 210769c1781fb..8297a42ab17f8 100644 --- a/sklearn/random_projection.py +++ b/sklearn/random_projection.py @@ -573,7 +573,7 @@ class SparseRandomProjection(BaseRandomProjection): Attributes ---------- - n_component_ : int + n_components_ : int Concrete number of components computed when n_components="auto". components_ : CSR matrix with shape [n_components, n_features] From c5e36d7b4416b69d84d661588278b9c602318a19 Mon Sep 17 00:00:00 2001 From: Alex Itkes <38556752+alexitkes@users.noreply.github.com> Date: Sat, 13 Jul 2019 08:33:14 +0300 Subject: [PATCH 04/13] Update docstring for FastICA Document the FastICA.mean_ attribute. --- sklearn/decomposition/fastica_.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sklearn/decomposition/fastica_.py b/sklearn/decomposition/fastica_.py index dd04e8e93a1c6..82a0345e01562 100644 --- a/sklearn/decomposition/fastica_.py +++ b/sklearn/decomposition/fastica_.py @@ -436,6 +436,9 @@ def my_g(x): mixing_ : array, shape (n_features, n_components) The mixing matrix. + mean_ : array, shape(n_features) + The mean over features. Only set if `self.whiten` is True. + n_iter_ : int If the algorithm is "deflation", n_iter is the maximum number of iterations run across all components. Else From bc7b78472e46adc03ba9c3bcfc382d2c10f0593a Mon Sep 17 00:00:00 2001 From: Alex Itkes <38556752+alexitkes@users.noreply.github.com> Date: Sat, 13 Jul 2019 18:24:28 +0300 Subject: [PATCH 05/13] Update docstring for FastICA Describe `whitening_` attribute. --- sklearn/decomposition/fastica_.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sklearn/decomposition/fastica_.py b/sklearn/decomposition/fastica_.py index 82a0345e01562..e3e1e1c7d6ba7 100644 --- a/sklearn/decomposition/fastica_.py +++ b/sklearn/decomposition/fastica_.py @@ -444,6 +444,10 @@ def my_g(x): maximum number of iterations run across all components. Else they are just the number of iterations taken to converge. + whitening_ : array, shape (n_components, n_features) or None. + Only set if whiten is 'True'. This is the pre-whitening matrix that projects + data onto the first `n_components` principal components. + Examples -------- >>> from sklearn.datasets import load_digits From 074d88e835702a14f9b9923d1d15f01c8e9575c1 Mon Sep 17 00:00:00 2001 From: Alex Itkes <38556752+alexitkes@users.noreply.github.com> Date: Sat, 13 Jul 2019 18:25:22 +0300 Subject: [PATCH 06/13] Update docstring for FastICA Just fix a typo. --- sklearn/decomposition/fastica_.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/decomposition/fastica_.py b/sklearn/decomposition/fastica_.py index e3e1e1c7d6ba7..8d9313112a3ec 100644 --- a/sklearn/decomposition/fastica_.py +++ b/sklearn/decomposition/fastica_.py @@ -444,7 +444,7 @@ def my_g(x): maximum number of iterations run across all components. Else they are just the number of iterations taken to converge. - whitening_ : array, shape (n_components, n_features) or None. + whitening_ : array, shape (n_components, n_features) Only set if whiten is 'True'. This is the pre-whitening matrix that projects data onto the first `n_components` principal components. From 7e536b2444e1c7a1b5adf729b993befbf67d7007 Mon Sep 17 00:00:00 2001 From: Alex Itkes <38556752+alexitkes@users.noreply.github.com> Date: Sat, 13 Jul 2019 18:37:34 +0300 Subject: [PATCH 07/13] Document some attributes for PCA Document PCA.n_features_ and PCA.n_samples_ --- sklearn/decomposition/pca.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sklearn/decomposition/pca.py b/sklearn/decomposition/pca.py index ccde667d0d20d..7aa8b496bb475 100644 --- a/sklearn/decomposition/pca.py +++ b/sklearn/decomposition/pca.py @@ -236,6 +236,14 @@ class PCA(_BasePCA): number is estimated from input data. Otherwise it equals the parameter n_components, or the lesser value of n_features and n_samples if n_components is None. + + n_features_ : int + The number of features in the data matrix the PCA transformed was + fitted on. + + n_samples_ : int + The number of samples in the data matrix the PCA transformed was + fitted on. noise_variance_ : float The estimated noise covariance following the Probabilistic PCA model From e876067d1e4e3dacb194ac5586516d95d752fe52 Mon Sep 17 00:00:00 2001 From: Alex Itkes <38556752+alexitkes@users.noreply.github.com> Date: Sat, 13 Jul 2019 18:40:26 +0300 Subject: [PATCH 08/13] Update pca.py --- sklearn/decomposition/pca.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sklearn/decomposition/pca.py b/sklearn/decomposition/pca.py index 7aa8b496bb475..81659a0b51a75 100644 --- a/sklearn/decomposition/pca.py +++ b/sklearn/decomposition/pca.py @@ -236,13 +236,13 @@ class PCA(_BasePCA): number is estimated from input data. Otherwise it equals the parameter n_components, or the lesser value of n_features and n_samples if n_components is None. - + n_features_ : int - The number of features in the data matrix the PCA transformed was + The number of features in the data matrix the PCA transformer was fitted on. n_samples_ : int - The number of samples in the data matrix the PCA transformed was + The number of samples in the data matrix the PCA transformer was fitted on. noise_variance_ : float From 66f616a2ed194f95003b691ebc7cf3b9ec15abb5 Mon Sep 17 00:00:00 2001 From: Alex Itkes <38556752+alexitkes@users.noreply.github.com> Date: Sat, 13 Jul 2019 18:41:31 +0300 Subject: [PATCH 09/13] Update fastica_.py Remove trailing whitespace --- sklearn/decomposition/fastica_.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/decomposition/fastica_.py b/sklearn/decomposition/fastica_.py index 8d9313112a3ec..b31498650e12d 100644 --- a/sklearn/decomposition/fastica_.py +++ b/sklearn/decomposition/fastica_.py @@ -447,7 +447,7 @@ def my_g(x): whitening_ : array, shape (n_components, n_features) Only set if whiten is 'True'. This is the pre-whitening matrix that projects data onto the first `n_components` principal components. - + Examples -------- >>> from sklearn.datasets import load_digits From 7c6c79376861c5b7ad6d1efd85a5ffa378d1c0b6 Mon Sep 17 00:00:00 2001 From: Alex Itkes <38556752+alexitkes@users.noreply.github.com> Date: Sat, 13 Jul 2019 18:48:14 +0300 Subject: [PATCH 10/13] Update FastICA docstring Break a line too long for Flake8 --- sklearn/decomposition/fastica_.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sklearn/decomposition/fastica_.py b/sklearn/decomposition/fastica_.py index b31498650e12d..d841926cdfc87 100644 --- a/sklearn/decomposition/fastica_.py +++ b/sklearn/decomposition/fastica_.py @@ -445,8 +445,8 @@ def my_g(x): they are just the number of iterations taken to converge. whitening_ : array, shape (n_components, n_features) - Only set if whiten is 'True'. This is the pre-whitening matrix that projects - data onto the first `n_components` principal components. + Only set if whiten is 'True'. This is the pre-whitening matrix + that projects data onto the first `n_components` principal components. Examples -------- From 6926f799a005e676348d6c94007d4e0c47231d8d Mon Sep 17 00:00:00 2001 From: Alex Itkes <38556752+alexitkes@users.noreply.github.com> Date: Sat, 13 Jul 2019 19:17:39 +0300 Subject: [PATCH 11/13] Update sklearn/decomposition/nmf.py Improve documentation string. Co-Authored-By: Andreas Mueller --- sklearn/decomposition/nmf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/decomposition/nmf.py b/sklearn/decomposition/nmf.py index 8282ff6ae495d..8efc30d4bce43 100644 --- a/sklearn/decomposition/nmf.py +++ b/sklearn/decomposition/nmf.py @@ -1193,7 +1193,7 @@ class NMF(BaseEstimator, TransformerMixin): Factorization matrix, sometimes called 'dictionary'. n_components_ : integer - The number of components. It is same to the `n_components` parameter + The number of components. It is same as the `n_components` parameter if it was given. Otherwise, it will be same with the number of features. From aaa28d669c26898ba4daff79c2cb2054c93fcd25 Mon Sep 17 00:00:00 2001 From: Alex Itkes <38556752+alexitkes@users.noreply.github.com> Date: Sat, 13 Jul 2019 19:20:34 +0300 Subject: [PATCH 12/13] Update sklearn/decomposition/nmf.py Update documentation string Co-Authored-By: Andreas Mueller --- sklearn/decomposition/nmf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/decomposition/nmf.py b/sklearn/decomposition/nmf.py index 8efc30d4bce43..f64bc34b7fad7 100644 --- a/sklearn/decomposition/nmf.py +++ b/sklearn/decomposition/nmf.py @@ -1194,7 +1194,7 @@ class NMF(BaseEstimator, TransformerMixin): n_components_ : integer The number of components. It is same as the `n_components` parameter - if it was given. Otherwise, it will be same with the number of + if it was given. Otherwise, it will be same as the number of features. reconstruction_err_ : number From a8c4886436935757762f7f0cf78886622376eb84 Mon Sep 17 00:00:00 2001 From: Alex Itkes <38556752+alexitkes@users.noreply.github.com> Date: Sat, 13 Jul 2019 19:25:35 +0300 Subject: [PATCH 13/13] Update pca.py Improved documentation for PCA attributes. --- sklearn/decomposition/pca.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sklearn/decomposition/pca.py b/sklearn/decomposition/pca.py index 81659a0b51a75..f8c28e1373b6e 100644 --- a/sklearn/decomposition/pca.py +++ b/sklearn/decomposition/pca.py @@ -238,12 +238,10 @@ class PCA(_BasePCA): if n_components is None. n_features_ : int - The number of features in the data matrix the PCA transformer was - fitted on. + Number of features in the training data. n_samples_ : int - The number of samples in the data matrix the PCA transformer was - fitted on. + Number of samples in the training data. noise_variance_ : float The estimated noise covariance following the Probabilistic PCA model