1717
1818from sklearn .cross_validation import KFold
1919
20+ rng = np .random .RandomState (0 )
2021diabetes = datasets .load_diabetes ()
21-
2222X_diabetes , y_diabetes = diabetes .data , diabetes .target
2323ind = np .arange (X_diabetes .shape [0 ])
24- np . random .shuffle (ind )
24+ rng .shuffle (ind )
2525ind = ind [:200 ]
2626X_diabetes , y_diabetes = X_diabetes [ind ], y_diabetes [ind ]
2727
3030X_iris = sp .csr_matrix (iris .data )
3131y_iris = iris .target
3232
33- np .random .seed (0 )
34-
3533DENSE_FILTER = lambda X : X
3634SPARSE_FILTER = lambda X : sp .csr_matrix (X )
3735
@@ -46,8 +44,8 @@ def test_ridge():
4644
4745 # With more samples than features
4846 n_samples , n_features = 6 , 5
49- y = np . random .randn (n_samples )
50- X = np . random .randn (n_samples , n_features )
47+ y = rng .randn (n_samples )
48+ X = rng .randn (n_samples , n_features )
5149
5250 ridge = Ridge (alpha = alpha )
5351 ridge .fit (X , y )
@@ -59,8 +57,8 @@ def test_ridge():
5957
6058 # With more features than samples
6159 n_samples , n_features = 5 , 10
62- y = np . random .randn (n_samples )
63- X = np . random .randn (n_samples , n_features )
60+ y = rng .randn (n_samples )
61+ X = rng .randn (n_samples , n_features )
6462 ridge = Ridge (alpha = alpha )
6563 ridge .fit (X , y )
6664 assert_greater (ridge .score (X , y ), .9 )
@@ -73,8 +71,8 @@ def test_ridge_shapes():
7371 """Test shape of coef_ and intercept_
7472 """
7573 n_samples , n_features = 5 , 10
76- X = np . random .randn (n_samples , n_features )
77- y = np . random .randn (n_samples )
74+ X = rng .randn (n_samples , n_features )
75+ y = rng .randn (n_samples )
7876 Y1 = y [:, np .newaxis ]
7977 Y = np .c_ [y , 1 + y ]
8078
@@ -97,8 +95,8 @@ def test_ridge_intercept():
9795 """Test intercept with multiple targets GH issue #708
9896 """
9997 n_samples , n_features = 5 , 10
100- X = np . random .randn (n_samples , n_features )
101- y = np . random .randn (n_samples )
98+ X = rng .randn (n_samples , n_features )
99+ y = rng .randn (n_samples )
102100 Y = np .c_ [y , 1. + y ]
103101
104102 ridge = Ridge ()
@@ -140,9 +138,8 @@ def test_ridge_vs_lstsq():
140138
141139 # we need more samples than features
142140 n_samples , n_features = 5 , 4
143- np .random .seed (0 )
144- y = np .random .randn (n_samples )
145- X = np .random .randn (n_samples , n_features )
141+ y = rng .randn (n_samples )
142+ X = rng .randn (n_samples , n_features )
146143
147144 ridge = Ridge (alpha = 0. , fit_intercept = False )
148145 ols = LinearRegression (fit_intercept = False )
0 commit comments