-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor likelihood, add small example
- Loading branch information
1 parent
ab3b4ed
commit 3df6534
Showing
5 changed files
with
74 additions
and
198 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from pymc_experimental.model.modular.components import Intercept, Regression, Spline | ||
from pymc_experimental.model.modular.likelihood import NormalLikelihood | ||
|
||
__all__ = [ | ||
"Intercept", | ||
"Regression", | ||
"Spline", | ||
"NormalLikelihood", | ||
] |
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
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,31 @@ | ||
import numpy as np | ||
import pandas as pd | ||
import pytest | ||
|
||
from pymc_experimental.model.modular.likelihood import NormalLikelihood | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def rng(): | ||
return np.random.default_rng() | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def data(rng): | ||
city = ["A", "B", "C"] | ||
race = ["white", "black", "hispanic"] | ||
|
||
df = pd.DataFrame( | ||
{ | ||
"city": np.random.choice(city, 1000), | ||
"age": rng.normal(size=1000), | ||
"race": rng.choice(race, size=1000), | ||
"income": rng.normal(size=1000), | ||
} | ||
) | ||
return df | ||
|
||
|
||
def test_normal_likelihood(data): | ||
model = NormalLikelihood(mu=None, sigma=None, target_col="income", data=data) | ||
idata = model.sample_prior_predictive() |