From 52477f4616a3b4aab969862b4d80c27bf157aa94 Mon Sep 17 00:00:00 2001 From: baam25simo Date: Thu, 7 Oct 2021 19:19:52 +0200 Subject: [PATCH 1/5] `KNNImputer` removed from `DOCSTRING_IGNORE_LIST` in test_docstrings.py --- maint_tools/test_docstrings.py | 1 - 1 file changed, 1 deletion(-) diff --git a/maint_tools/test_docstrings.py b/maint_tools/test_docstrings.py index 35ed4c515dd81..3d82608c9b6d7 100644 --- a/maint_tools/test_docstrings.py +++ b/maint_tools/test_docstrings.py @@ -9,7 +9,6 @@ # List of modules ignored when checking for numpydoc validation. DOCSTRING_IGNORE_LIST = [ - "KNNImputer", "LabelPropagation", "LabelSpreading", "LocallyLinearEmbedding", From 96cb29d53f09f3464b71a0bdb15ff22d2b8bc805 Mon Sep 17 00:00:00 2001 From: baam25simo Date: Thu, 7 Oct 2021 19:28:58 +0200 Subject: [PATCH 2/5] In `KNNImputer.__init__`: "See Also" section added. --- sklearn/impute/_knn.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sklearn/impute/_knn.py b/sklearn/impute/_knn.py index c2bd1410e8ecd..23ab0902357df 100644 --- a/sklearn/impute/_knn.py +++ b/sklearn/impute/_knn.py @@ -87,6 +87,12 @@ class KNNImputer(_BaseImputer): .. versionadded:: 1.0 + See Also + -------- + SimpleImputer : Imputation transformer for completing missing values. + IterativeImputer : Multivariate imputer that estimates each feature + from all the others. + References ---------- * Olga Troyanskaya, Michael Cantor, Gavin Sherlock, Pat Brown, Trevor @@ -261,7 +267,7 @@ def transform(self, X): dist_idx_map[row_missing_idx] = np.arange(row_missing_idx.shape[0]) def process_chunk(dist_chunk, start): - row_missing_chunk = row_missing_idx[start : start + len(dist_chunk)] + row_missing_chunk = row_missing_idx[start: start + len(dist_chunk)] # Find and impute missing by column for col in range(X.shape[1]): From 2a8521669a63ce7649802cd5b6fca37d83bd0b52 Mon Sep 17 00:00:00 2001 From: baam25simo Date: Thu, 7 Oct 2021 19:42:24 +0200 Subject: [PATCH 3/5] In `KNNImputer.fit`: `y` and `return`description parameters added. --- sklearn/impute/_knn.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sklearn/impute/_knn.py b/sklearn/impute/_knn.py index 23ab0902357df..8cc020225e53f 100644 --- a/sklearn/impute/_knn.py +++ b/sklearn/impute/_knn.py @@ -185,9 +185,13 @@ def fit(self, X, y=None): Input data, where `n_samples` is the number of samples and `n_features` is the number of features. + y : (ignored) + Ignored parameter. + Returns ------- self : object + KNNImputer class instance. """ # Check data integrity and calling arguments if not is_scalar_nan(self.missing_values): From 4e6d15686ddb56bd6f10826025baa940e232e49b Mon Sep 17 00:00:00 2001 From: baam25simo Date: Thu, 7 Oct 2021 19:59:32 +0200 Subject: [PATCH 4/5] Trying to fix linting --- sklearn/impute/_knn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/impute/_knn.py b/sklearn/impute/_knn.py index 8cc020225e53f..721faa36055fa 100644 --- a/sklearn/impute/_knn.py +++ b/sklearn/impute/_knn.py @@ -271,7 +271,7 @@ def transform(self, X): dist_idx_map[row_missing_idx] = np.arange(row_missing_idx.shape[0]) def process_chunk(dist_chunk, start): - row_missing_chunk = row_missing_idx[start: start + len(dist_chunk)] + row_missing_chunk = row_missing_idx[start : start + len(dist_chunk)] # Find and impute missing by column for col in range(X.shape[1]): From a2592503ce09eefaf1b68cd0e8eb687b251d8570 Mon Sep 17 00:00:00 2001 From: baam <83430343+baam25simo@users.noreply.github.com> Date: Thu, 7 Oct 2021 21:17:55 +0200 Subject: [PATCH 5/5] Update _knn.py Fix proposal --- sklearn/impute/_knn.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sklearn/impute/_knn.py b/sklearn/impute/_knn.py index 721faa36055fa..76aa7c5408e1e 100644 --- a/sklearn/impute/_knn.py +++ b/sklearn/impute/_knn.py @@ -185,8 +185,8 @@ def fit(self, X, y=None): Input data, where `n_samples` is the number of samples and `n_features` is the number of features. - y : (ignored) - Ignored parameter. + y : Ignored + Not used, present here for API consistency by convention. Returns -------