Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
glemaitre committed Jun 18, 2018
1 parent 553b5fb commit 37f7cb5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions sklearn/preprocessing/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,8 @@ def __init__(self, with_centering=True, with_scaling=True,
def _check_array(self, X, copy):
"""Makes sure centering is not enabled for sparse matrices."""
X = check_array(X, accept_sparse=('csr', 'csc'), copy=self.copy,
estimator=self, dtype=FLOAT_DTYPES)
estimator=self, dtype=FLOAT_DTYPES,
force_all_finite='allow-nan')

if sparse.issparse(X):
if self.with_centering:
Expand All @@ -1071,15 +1072,15 @@ def fit(self, X, y=None):
raise TypeError("RobustScaler cannot be fitted on sparse inputs")
X = self._check_array(X, self.copy)
if self.with_centering:
self.center_ = np.median(X, axis=0)
self.center_ = np.nanmedian(X, axis=0)

if self.with_scaling:
q_min, q_max = self.quantile_range
if not 0 <= q_min <= q_max <= 100:
raise ValueError("Invalid quantile range: %s" %
str(self.quantile_range))

q = np.percentile(X, self.quantile_range, axis=0)
q = np.nanpercentile(X, self.quantile_range, axis=0)
self.scale_ = (q[1] - q[0])
self.scale_ = _handle_zeros_in_scale(self.scale_, copy=False)
return self
Expand Down Expand Up @@ -1196,7 +1197,8 @@ def robust_scale(X, axis=0, with_centering=True, with_scaling=True,
(e.g. as part of a preprocessing :class:`sklearn.pipeline.Pipeline`).
"""
X = check_array(X, accept_sparse=('csr', 'csc'), copy=False,
ensure_2d=False, dtype=FLOAT_DTYPES)
ensure_2d=False, dtype=FLOAT_DTYPES,
force_all_finite='allow-nan')
original_ndim = X.ndim

if original_ndim == 1:
Expand Down

0 comments on commit 37f7cb5

Please sign in to comment.