-
-
Notifications
You must be signed in to change notification settings - Fork 553
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
487341b
commit 2df17f1
Showing
3 changed files
with
34 additions
and
27 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 |
---|---|---|
|
@@ -130,3 +130,6 @@ benchmarks/.asv | |
|
||
# Cargo file | ||
Cargo.lock | ||
|
||
# WASM | ||
/*.html |
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 pytest | ||
import pandas as pd | ||
import numpy as np | ||
import math | ||
from river import proba | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"p", | ||
[ | ||
pytest.param( | ||
p, | ||
id=f"{p=}", | ||
) | ||
for p in [1, 3, 5] | ||
], | ||
) | ||
def test_univariate_multivariate_consistency(p): | ||
X = pd.DataFrame(np.random.random((30, p)), columns=range(p)) | ||
|
||
multi = proba.MultivariateGaussian() | ||
single = {c: proba.Gaussian() for c in X.columns} | ||
|
||
for x in X.to_dict(orient="records"): | ||
multi = multi.update(x) | ||
for c, s in single.items(): | ||
s.update(x[c]) | ||
|
||
for c in X.columns: | ||
assert math.isclose(multi.mu[c], single[c].mu) | ||
assert math.isclose(multi.sigma[c][c], single[c].sigma) |