@@ -179,6 +179,8 @@ def test_transformers():
179
179
# than the number of features.
180
180
# So we impose a smaller number (avoid "auto" mode)
181
181
transformer .n_components = 1
182
+ elif name == "MiniBatchDictionaryLearning" :
183
+ transformer .set_params (n_iter = 5 ) # default = 1000
182
184
183
185
# fit
184
186
@@ -677,14 +679,27 @@ def test_classifiers_pickle():
677
679
assert_true (succeeded )
678
680
679
681
682
+ BOSTON = None
683
+
684
+
685
+ def _boston_subset ():
686
+ global BOSTON
687
+ if BOSTON is None :
688
+ boston = load_boston ()
689
+ X , y = boston .data , boston .target
690
+ X , y = shuffle (X , y , random_state = 0 )
691
+ X , y = X [:200 ], y [:200 ]
692
+ X = StandardScaler ().fit_transform (X )
693
+ BOSTON = X , y
694
+ return BOSTON
695
+
696
+
680
697
def test_regressors_int ():
681
698
# test if regressors can cope with integer labels (by converting them to
682
699
# float)
683
700
regressors = all_estimators (type_filter = 'regressor' )
684
- boston = load_boston ()
685
- X , y = boston .data , boston .target
686
- X , y = shuffle (X , y , random_state = 0 )
687
- X = StandardScaler ().fit_transform (X )
701
+ X , _ = _boston_subset ()
702
+ X = X [:50 ]
688
703
rnd = np .random .RandomState (0 )
689
704
y = rnd .randint (2 , size = X .shape [0 ])
690
705
for name , Regressor in regressors :
@@ -714,13 +729,10 @@ def test_regressors_int():
714
729
715
730
def test_regressors_train ():
716
731
regressors = all_estimators (type_filter = 'regressor' )
717
- boston = load_boston ()
718
- X , y = boston .data , boston .target
719
- X , y = shuffle (X , y , random_state = 0 )
720
732
# TODO: test with intercept
721
733
# TODO: test with multiple responses
722
- X = StandardScaler (). fit_transform ( X )
723
- y = StandardScaler ().fit_transform (y )
734
+ X , y = _boston_subset ( )
735
+ y = StandardScaler ().fit_transform (y ) # X is already scaled
724
736
rnd = np .random .RandomState (0 )
725
737
succeeded = True
726
738
for name , Regressor in regressors :
@@ -760,13 +772,10 @@ def test_regressor_pickle():
760
772
# Test that estimators can be pickled, and once pickled
761
773
# give the same answer as before.
762
774
regressors = all_estimators (type_filter = 'regressor' )
763
- boston = load_boston ()
764
- X , y = boston .data , boston .target
765
- X , y = shuffle (X , y , random_state = 0 )
775
+ X , y = _boston_subset ()
766
776
# TODO: test with intercept
767
777
# TODO: test with multiple responses
768
- X = StandardScaler ().fit_transform (X )
769
- y = StandardScaler ().fit_transform (y )
778
+ y = StandardScaler ().fit_transform (y ) # X is already scaled
770
779
rnd = np .random .RandomState (0 )
771
780
succeeded = True
772
781
for name , Regressor in regressors :
0 commit comments