-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #438 from GAA-UAM/feature/featureConstructionMoments
Feature Construction Moments
- Loading branch information
Showing
4 changed files
with
216 additions
and
3 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
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 @@ | ||
"""Test to check the per functional transformers.""" | ||
|
||
import unittest | ||
|
||
import numpy as np | ||
|
||
import skfda.representation.basis as basis | ||
from skfda.datasets import fetch_growth | ||
from skfda.exploratory.stats import unconditional_expected_value | ||
|
||
|
||
class TestUncondExpectedVals(unittest.TestCase): | ||
"""Tests for unconditional expected values method.""" | ||
|
||
def test_transform(self) -> None: | ||
"""Check the data transformation is done correctly.""" | ||
X = fetch_growth(return_X_y=True)[0] | ||
|
||
def f(x: np.ndarray) -> np.ndarray: # noqa: WPS430 | ||
return np.log(x) | ||
|
||
data_grid = unconditional_expected_value(X[:5], f) | ||
data_basis = unconditional_expected_value( | ||
X[:5].to_basis(basis.BSpline(n_basis=7)), | ||
f, | ||
) | ||
np.testing.assert_allclose(data_basis, data_grid, rtol=1e-3) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |