Skip to content

Commit

Permalink
Use RandomState
Browse files Browse the repository at this point in the history
  • Loading branch information
RAMitchell committed Jun 3, 2020
1 parent a5722a1 commit 8b2bb70
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tests/python/regression_test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def get_sparse():
n = 2000
sparsity = 0.75
X, y = datasets.make_regression(n, random_state=rng)
flag = np.random.binomial(1, sparsity, X.shape)
flag = rng.binomial(1, sparsity, X.shape)
for i in range(X.shape[0]):
for j in range(X.shape[1]):
if flag[i, j]:
Expand All @@ -85,16 +85,16 @@ def get_small_weights():

@memory.cache
def get_weights_regression(min_weight, max_weight):
np.random.seed(199)
rng = np.random.RandomState(199)
n = 2000
sparsity = 0.25
X, y = datasets.make_regression(n, random_state=199)
flag = np.random.binomial(1, sparsity, X.shape)
X, y = datasets.make_regression(n, random_state=rng)
flag = rng.binomial(1, sparsity, X.shape)
for i in range(X.shape[0]):
for j in range(X.shape[1]):
if flag[i, j]:
X[i, j] = np.nan
w = np.random.uniform(min_weight, max_weight, n)
w = rng.uniform(min_weight, max_weight, n)
return X, y, w


Expand Down

0 comments on commit 8b2bb70

Please sign in to comment.