MCPcopy Index your code
hub / github.com/scikit-learn/scikit-learn / check_random_state

Function check_random_state

sklearn/utils/validation.py:1452–1482  ·  view source on GitHub ↗

Turn seed into an np.random.RandomState instance. Parameters ---------- seed : None, int or instance of RandomState If seed is None, return the RandomState singleton used by np.random. If seed is an int, return a new RandomState instance seeded with seed. If seed

(seed)

Source from the content-addressed store, hash-verified

1450
1451
1452def check_random_state(seed):
1453 """Turn seed into an np.random.RandomState instance.
1454
1455 Parameters
1456 ----------
1457 seed : None, int or instance of RandomState
1458 If seed is None, return the RandomState singleton used by np.random.
1459 If seed is an int, return a new RandomState instance seeded with seed.
1460 If seed is already a RandomState instance, return it.
1461 Otherwise raise ValueError.
1462
1463 Returns
1464 -------
1465 :class:`numpy:numpy.random.RandomState`
1466 The random state object based on `seed` parameter.
1467
1468 Examples
1469 --------
1470 >>> from sklearn.utils.validation import check_random_state
1471 >>> check_random_state(42)
1472 RandomState(MT19937) at 0x...
1473 """
1474 if seed is None or seed is np.random:
1475 return np.random.mtrand._rand
1476 if isinstance(seed, numbers.Integral):
1477 return np.random.RandomState(seed)
1478 if isinstance(seed, np.random.RandomState):
1479 return seed
1480 raise ValueError(
1481 f"{seed!r} cannot be used to seed a numpy.random.RandomState instance"
1482 )
1483
1484
1485def has_fit_parameter(estimator, parameter):

Callers 15

fitMethod · 0.90
fitMethod · 0.90
fitMethod · 0.90
fitMethod · 0.90
fitMethod · 0.90
fitMethod · 0.90
_gaussian_random_matrixFunction · 0.90
_sparse_random_matrixFunction · 0.90
_make_random_matrixMethod · 0.90
_make_random_matrixMethod · 0.90
predictMethod · 0.90
predict_probaMethod · 0.90

Calls

no outgoing calls

Tested by 15

test_query_haversineFunction · 0.72
test_lof_performanceFunction · 0.72
test_kernel_densityFunction · 0.72
test_neighbors_heapFunction · 0.72
test_node_heapFunction · 0.72
test_simultaneous_sortFunction · 0.72
test_gaussian_kdeFunction · 0.72
test_nn_tree_queryFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…