Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add seed parameter to BaseNetwork sample function #110

Merged
merged 1 commit into from
Jun 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion bamt/networks/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,17 +638,21 @@ def sample(
predict: bool = False,
parall_count: int = 1,
filter_neg: bool = True,
seed: Optional[int] = None,
) -> Union[None, pd.DataFrame, List[Dict[str, Union[str, int, float]]]]:
"""
Sampling from Bayesian Network
n: int number of samples
evidence: values for nodes from user
parall_count: number of threads. Defaults to 1.
filter_neg: either filter negative vals or not.
seed: seed value to use for random number generator
"""
from joblib import Parallel, delayed

random.seed()
random.seed(seed)
np.random.seed(seed)

if not self.distributions.items():
logger_network.error(
"Parameter learning wasn't done. Call fit_parameters method"
Expand Down
Loading