Ejemplo n.º 1
0
    def test__trasnform(self):
        # setup
        instance = MagicMock()
        trials = np.array([[0.1, 0.8, 0.2], [0.7, 0.6, 0.4], [0.4, 0.2, 0.3],
                           [0.7, 0.8, 0.9], [0.2, 0.3, 0.4]])

        distributions = []
        for column in trials.T:
            distribution = Univariate()
            distribution.fit(column)
            distributions.append(distribution)

        instance._distributions = distributions

        # run
        result = GaussianCopulaProcessMetaModel._transform(instance, trials)

        # assert
        expected_result = np.array([[-0.93051407, 0.72584367, -1.05823838],
                                    [0.78865964, 0.1155097, 0.3732126],
                                    [-0.04619363, -0.96388991, -0.49278658],
                                    [0.78865964, 0.72584367, 1.82607428],
                                    [-0.60472608, -0.66069297, 0.3732126]])

        np.testing.assert_allclose(result, expected_result)
Ejemplo n.º 2
0
    def _fit(self, trials, scores):
        self._distributions = []
        for column in trials.T:
            distribution = Univariate()
            distribution.fit(column)
            self._distributions.append(distribution)

        distribution = Univariate()
        distribution.fit(scores)
        self._score_distribution = distribution

        trans_trials = self._transform(trials)
        trans_scores = scipy.stats.norm.ppf(
            self._score_distribution.cdf(scores).clip(0 + EPSILON, 1 - EPSILON)
        )

        super()._fit(trans_trials, trans_scores)