From 441e35b572b5e9411164fc0606e734be4eb25c51 Mon Sep 17 00:00:00 2001 From: Lukas Novak <95358264+NovakLBUT@users.noreply.github.com> Date: Fri, 21 Apr 2023 20:31:28 +0200 Subject: [PATCH] Update test_pce.py new unit test for active learning --- tests/unit_tests/surrogates/test_pce.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/unit_tests/surrogates/test_pce.py b/tests/unit_tests/surrogates/test_pce.py index 2a0b9519..b0e6f8e5 100644 --- a/tests/unit_tests/surrogates/test_pce.py +++ b/tests/unit_tests/surrogates/test_pce.py @@ -382,3 +382,24 @@ def test_21(): assert all((np.argwhere(np.round(pce2_lar_sens.calculate_generalized_total_order_indices(), 3) > 0) == [[0], [2], [3]])) + +def test_22(): + """ + Test Active Learning based on Theta Criterion + """ + polynomial_basis = TotalDegreeBasis(dist, max_degree) + least_squares = LeastSquareRegression() + pce = PolynomialChaosExpansion(polynomial_basis=polynomial_basis, regression_method=least_squares) + uniform_x=np.zeros((3,1)) + uniform_x[:,0]=np.array([0,5,10]) + pce.fit(uniform_x, uniform_x) + + adapted_x=uniform_x + candidates_x=np.zeros((5,1)) + candidates_x[:,0]=np.array([1.1,4,5.1,6,9]) + + + ThetaSampling_complete=ThetaCriterionPCE([pce]) + pos=ThetaSampling_complete.run(adapted_x,candidates_x,nadd=2) + best_candidates=candidates_x[pos,:] + assert best_candidates[0,0]==1.1 and best_candidates[1,0]==9