@@ -276,6 +276,9 @@ class MinMaxScaler(BaseEstimator, TransformerMixin):
276
276
277
277
Notes
278
278
-----
279
+ NaNs are treated as missing values: disregarded in fit, and maintained in
280
+ transform.
281
+
279
282
For a comparison of the different scalers, transformers, and normalizers,
280
283
see :ref:`examples/preprocessing/plot_all_scaling.py
281
284
<sphx_glr_auto_examples_preprocessing_plot_all_scaling.py>`.
@@ -340,10 +343,11 @@ def partial_fit(self, X, y=None):
340
343
"You may consider to use MaxAbsScaler instead." )
341
344
342
345
X = check_array (X , copy = self .copy , warn_on_dtype = True ,
343
- estimator = self , dtype = FLOAT_DTYPES )
346
+ estimator = self , dtype = FLOAT_DTYPES ,
347
+ force_all_finite = "allow-nan" )
344
348
345
- data_min = np .min (X , axis = 0 )
346
- data_max = np .max (X , axis = 0 )
349
+ data_min = np .nanmin (X , axis = 0 )
350
+ data_max = np .nanmax (X , axis = 0 )
347
351
348
352
# First pass
349
353
if not hasattr (self , 'n_samples_seen_' ):
@@ -373,7 +377,8 @@ def transform(self, X):
373
377
"""
374
378
check_is_fitted (self , 'scale_' )
375
379
376
- X = check_array (X , copy = self .copy , dtype = FLOAT_DTYPES )
380
+ X = check_array (X , copy = self .copy , dtype = FLOAT_DTYPES ,
381
+ force_all_finite = "allow-nan" )
377
382
378
383
X *= self .scale_
379
384
X += self .min_
@@ -389,7 +394,8 @@ def inverse_transform(self, X):
389
394
"""
390
395
check_is_fitted (self , 'scale_' )
391
396
392
- X = check_array (X , copy = self .copy , dtype = FLOAT_DTYPES )
397
+ X = check_array (X , copy = self .copy , dtype = FLOAT_DTYPES ,
398
+ force_all_finite = "allow-nan" )
393
399
394
400
X -= self .min_
395
401
X /= self .scale_
0 commit comments