File tree 1 file changed +22
-0
lines changed
sklearn/preprocessing/tests
1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -1498,3 +1498,25 @@ def test_one_hot_encoder_unknown_transform():
1498
1498
oh = OneHotEncoder (handle_unknown = '42' )
1499
1499
oh .fit (X )
1500
1500
assert_raises (ValueError , oh .transform , y )
1501
+
1502
+
1503
+ def test_fit_cold_start ():
1504
+ X = iris .data
1505
+ X_2d = X [:, :2 ]
1506
+
1507
+ # Scalers that have a partial_fit method
1508
+ scalers = [StandardScaler (with_mean = False , with_std = False ),
1509
+ MinMaxScaler (),
1510
+ MaxAbsScaler ()]
1511
+
1512
+ for scaler in scalers :
1513
+ scaler .fit_transform (X )
1514
+ # with a different shape, this may break the scaler unless the internal
1515
+ # state is re-set
1516
+ try :
1517
+ scaler .fit_transform (X_2d )
1518
+ except ValueError as err :
1519
+ print ("Cannot fit %s a second time with different shape "
1520
+ "of input. Error message: %s"
1521
+ % (scaler .__class__ .__name__ , str (err )))
1522
+ assert False
You can’t perform that action at this time.
0 commit comments