コード例 #1
0
ファイル: test_resampling.py プロジェクト: bds-ailab/shaman
 def test_dynamic_resampling_effect_threshold(self):
     """Tests that the resampling behavior depends on the error of the IC.
     """
     test_dynamic_resampling = DynamicResamplingNonParametric(
         0.2, threshold=0.95)
     history = {
         "fitness":
         np.array([10, 5, 4, 8, 10, 12, 16, 15, 10, 12, 16, 14]),
         "parameters":
         np.array([
             [1, 2],
             [2, 3],
             [1, 3],
             [2, 1],
             [2, 1],
             [2, 1],
             [2, 1],
             [2, 1],
             [2, 1],
             [2, 1],
             [2, 1],
             [2, 1],
         ]),
     }
     self.assertTrue(test_dynamic_resampling.resample(history))
     test_dynamic_resampling = DynamicResamplingNonParametric(0.2,
                                                              threshold=0.1)
     self.assertFalse(test_dynamic_resampling.resample(history))
コード例 #2
0
ファイル: test_resampling.py プロジェクト: bds-ailab/shaman
 def test_dynamic_resampling_non_parametric_ci_bounds(self):
     """Tests that the CI bounds of the non parametric intervals are properly computed.
     """
     test_dynamic_resampling = DynamicResamplingNonParametric(
         0.2, resampling_schedule="constant")
     history = {
         "fitness":
         np.array([10, 5, 4, 12, 4, 5]),
         "parameters":
         np.array([[1, 2], [2, 3], [1, 3], [2, 1], [2, 1], [2, 1]]),
     }
     test_dynamic_resampling.resample(history)
     print(f"Interval ranks: {test_dynamic_resampling.ic_length()}")
コード例 #3
0
ファイル: test_resampling.py プロジェクト: bds-ailab/shaman
 def test_dynamic_resampling_non_parametric_no_resample(self):
     """Tests that there is no resampling when the median of the resampled data point is higher
     than the current median.
     """
     test_dynamic_resampling = DynamicResamplingNonParametric(
         0.2, resampling_schedule="constant")
     history = {
         "fitness":
         np.array([10, 5, 4, 12, 12, 12, 12]),
         "parameters":
         np.array([[1, 2], [2, 3], [1, 3], [2, 1], [2, 1], [2, 1], [2, 1]]),
     }
     self.assertFalse(test_dynamic_resampling.resample(history))
     test_dynamic_resampling.resample(history)
コード例 #4
0
ファイル: test_resampling.py プロジェクト: bds-ailab/shaman
 def test_dynamic_resampling_non_parametric_one_resample(self):
     """Tests that when there is only one resampling for a parametrization the parametrization
     is automatically repeated.
     """
     test_dynamic_resampling = DynamicResamplingNonParametric(
         0.2, resampling_schedule="constant")
     history = {
         "fitness": np.array([10, 5, 4, 12]),
         "parameters": np.array([[1, 2], [2, 3], [1, 3], [2, 1]]),
     }
     self.assertTrue(test_dynamic_resampling.resample(history))
コード例 #5
0
ファイル: test_resampling.py プロジェクト: bds-ailab/shaman
 def test_dynamic_resampling_non_parametric_resample(self):
     """Tests that there is resampling when the size of the IC is higher than the threshold.
     """
     test_dynamic_resampling = DynamicResamplingNonParametric(0.2,
                                                              threshold=0.9)
     history = {
         "fitness":
         np.array([10, 5, 4, 8, 10, 12, 16]),
         "parameters":
         np.array([[1, 2], [2, 3], [1, 3], [2, 1], [2, 1], [2, 1], [2, 1]]),
     }
     self.assertTrue(test_dynamic_resampling.resample(history))
コード例 #6
0
ファイル: test_resampling.py プロジェクト: bds-ailab/shaman
 def test_dynamic_resampling_non_parametric_resample2(self):
     """Tests that there is resampling when the size of the IC is higher than the threshold and
     the median of the resampled data point lower than the current median.
     """
     test_dynamic_resampling = DynamicResamplingNonParametric(
         0.2, resampling_schedule="constant")
     history = {
         "fitness":
         np.array([10, 5, 4, 2, 5, 3, 7]),
         "parameters":
         np.array([[1, 2], [2, 3], [1, 3], [2, 1], [2, 1], [2, 1], [2, 1]]),
     }
     self.assertTrue(test_dynamic_resampling.resample(history))