Skip to content

Commit

Permalink
Fix test. Inverse transform does not yield original values, as it is …
Browse files Browse the repository at this point in the history
…not lossless.
  • Loading branch information
c-w-feldmann committed Sep 18, 2024
1 parent d36e2f2 commit c81b048
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions tests/test_elements/test_post_prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,19 @@ def test_fit_transform(self) -> None:
def test_inverse_transform(self) -> None:
"""Test inverse_transform method."""
rng = np.random.default_rng(20240918)
features = rng.random((100, 10))
features = rng.random((5, 10))

ppw = PostPredictionWrapper(PCA(n_components=3))
pca = PCA(n_components=3)
pca.fit(features)
pca_transformed = pca.transform(features)
pca_inverse = pca.inverse_transform(pca_transformed)

ppw = PostPredictionWrapper(clone(pca))
ppw.fit(features)
ppw_transformed = ppw.transform(features)
ppw_inverse = ppw.inverse_transform(ppw_transformed)

self.assertEqual(features.shape, ppw_inverse.shape)
self.assertTrue(np.allclose(features, ppw_inverse))
self.assertEqual(pca_inverse.shape, ppw_inverse.shape)

self.assertTrue(np.allclose(pca_inverse, ppw_inverse))

0 comments on commit c81b048

Please sign in to comment.