Example #1
0
    def test_correlations(self):
        """
        Test correlation based coefficients: angular (abs, square), distance correlation.
        """
        angular_dist = angular_distance(self.x, self.y_1)
        sq_angular_dist = squared_angular_distance(self.x, self.y_1)
        abs_angular_dist = absolute_angular_distance(self.x, self.y_1)
        dist_corr = distance_correlation(self.x, self.y_1)
        kullback_dist = kullback_leibler_distance(self.corr_A, self.corr_B)
        norm_dist = norm_distance(self.corr_A, self.corr_B)
        # Assigns pd.DataFrame as input
        corr_A_df = pd.DataFrame(self.corr_A)
        corr_B_df = pd.DataFrame(self.corr_B)
        kullback_dist_df = kullback_leibler_distance(corr_A_df, corr_B_df)
        norm_dist_df = norm_distance(corr_A_df, corr_B_df)

        self.assertAlmostEqual(angular_dist, 0.67, delta=1e-2)
        self.assertAlmostEqual(abs_angular_dist, 0.6703, delta=1e-2)
        self.assertAlmostEqual(sq_angular_dist, 0.7, delta=1e-2)
        self.assertAlmostEqual(dist_corr, 0.529, delta=1e-2)
        self.assertAlmostEqual(kullback_dist, 0.250807852409, delta=1e-2)
        self.assertAlmostEqual(norm_dist, 0.58255075616, delta=1e-2)

        # Checking if return is consistent when input type is pd.DataFrame
        self.assertAlmostEqual(kullback_dist_df, kullback_dist, delta=1e-2)
        self.assertAlmostEqual(norm_dist_df, norm_dist, delta=1e-2)

        dist_corr_y_2 = distance_correlation(self.x, self.y_2)
        self.assertAlmostEqual(dist_corr_y_2, 0.5216, delta=1e-2)
Example #2
0
    def test_correlations(self):
        """
        Test correlation based coefficients: angular (abs, square), distance correlation.
        """
        angular_dist = angular_distance(self.x, self.y_1)
        sq_angular_dist = squared_angular_distance(self.x, self.y_1)
        abs_angular_dist = absolute_angular_distance(self.x, self.y_1)
        dist_corr = distance_correlation(self.x, self.y_1)

        self.assertAlmostEqual(angular_dist, 0.67, delta=1e-2)
        self.assertAlmostEqual(abs_angular_dist, 0.6703, delta=1e-2)
        self.assertAlmostEqual(sq_angular_dist, 0.7, delta=1e-2)
        self.assertAlmostEqual(dist_corr, 0.529, delta=1e-2)

        dist_corr_y_2 = distance_correlation(self.x, self.y_2)
        self.assertAlmostEqual(dist_corr_y_2, 0.5216, delta=1e-2)