-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add random_state argument to HyperparameterOptimization class to ensu…
…re reproducibility of results. - Fixes for #125 (#131) * set seed for numpy * add a random_state argument to hyperparameter optimization module * add random state for hyperopt fmin function * add rstate for hyperparameter optimization and add a test for it * fixed MR comments * fix attempt for ci cd * version update for a minor fix release --------- Authored by: Panagiotis Papaemmanouil <[email protected]> Review changes authored by: @sayanchk
- Loading branch information
Showing
6 changed files
with
48 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .random_state_validation import check_random_state |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import numpy as np | ||
import numbers | ||
|
||
def check_random_state(seed): | ||
"""Turn seed into a np.random.RandomState instance | ||
:param int seed: seed for the random state | ||
:return: 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 is already a RandomState instance, return it. | ||
Otherwise raise ValueError. | ||
:rtype: np.random.RandomState or None | ||
""" | ||
if seed is None or seed is np.random: | ||
return np.random.mtrand._rand | ||
if isinstance(seed, numbers.Integral): | ||
return np.random.RandomState(seed) | ||
if isinstance(seed, np.random.RandomState): | ||
return seed | ||
raise ValueError( | ||
"%r cannot be used to seed a numpy.random.RandomState instance" % seed | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
|
||
setup( | ||
name='luminaire', | ||
version='0.4.2', | ||
version='0.4.3', | ||
|
||
license='Apache License 2.0', | ||
|
||
|