Skip to content

Commit 1175831

Browse files
FIX: Allow KNN with missing values (#2822)
* better fix without validating data twice * fix
1 parent e9120ae commit 1175831

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

sklearnex/neighbors/common.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030

3131
from .._utils import PatchingConditionsChain
3232
from ..base import oneDALEstimator
33-
from ..utils._array_api import get_namespace
3433
from ..utils.validation import check_feature_names
3534

3635

@@ -68,7 +67,13 @@ def _fit_validation(self, X, y=None):
6867

6968
if not isinstance(X, (KDTree, BallTree, _sklearn_NeighborsBase)):
7069
self._fit_X = _check_array(
71-
X, dtype=[np.float64, np.float32], accept_sparse=True
70+
X,
71+
dtype=[np.float64, np.float32],
72+
accept_sparse=True,
73+
force_all_finite=not (
74+
isinstance(self.effective_metric_, str)
75+
and self.effective_metric_.startswith("nan")
76+
),
7277
)
7378
self.n_samples_fit_ = _num_samples(self._fit_X)
7479
self.n_features_in_ = _num_features(self._fit_X)

0 commit comments

Comments
 (0)