-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to use RandomState to avoid compatibility issues with train_te…
…st_split
- Loading branch information
Showing
5 changed files
with
36 additions
and
22 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 was deleted.
Oops, something went wrong.
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,28 @@ | ||
from typing import Optional | ||
|
||
import numpy as np | ||
from numpy.random import RandomState | ||
|
||
_random_state = None | ||
|
||
|
||
def get_random_state() -> Optional[RandomState]: | ||
""" | ||
Get the global random state object. | ||
Returns: | ||
RandomState or None: The global random state object if initialized, else None. | ||
""" | ||
global _random_state | ||
return _random_state | ||
|
||
|
||
def initialize_random_state(seed: int): | ||
""" | ||
Initialize the global random state object with the provided seed. | ||
Args: | ||
seed (int): The seed value to initialize the random state object. | ||
""" | ||
global _random_state | ||
_random_state = np.random.RandomState(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