Пример #1
0
    def test_gmm_joint_prob(self):
        """Testing the GMM method
        for calculating the joint
        log probability of a given point.
        Should return -0.9413.

        returns:
        joint_prob = float
        """

        image_file = 'images/self_driving.png'
        image_matrix = image_to_matrix(image_file)
        num_components = 5
        gmm = GaussianMixtureModel(image_matrix, num_components)
        gmm.initialize_training()
        gmm.means = np.array([0.03921569, 0.1764706,  0.06666667, 0.42745098, 0.2784314])
        test_val = 0.03921569
        joint_prob = gmm.joint_prob(test_val)
        self.assertEqual(round(joint_prob, 4), -0.9413,
                         msg="Incorrect joint log probability")
Пример #2
0
    def test_gmm_joint_prob(self):
        """Testing the GMM method
        for calculating the joint
        log probability of a given point.
        Should return -0.98196.

        returns:
        joint_prob = float
        """

        image_file = 'images/party_spock.png'
        image_matrix = image_to_matrix(image_file)
        num_components = 5
        gmm = GaussianMixtureModel(image_matrix, num_components)
        gmm.initialize_training()
        gmm.means = [0.4627451, 0.10196079, 0.027450981,
                     0.011764706, 0.1254902]
        test_val = 0.4627451
        joint_prob = gmm.joint_prob(test_val)
        self.assertEqual(round(joint_prob, 4), -0.982,
                         msg="Incorrect joint log probability")