How to use the pgmpy.estimators.CITests.chi_square function in pgmpy

To help you get started, we’ve selected a few pgmpy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pgmpy / pgmpy / pgmpy / estimators / MmhcEstimator.py View on Github external
def assoc(X, Y, Zs):
            """Measure for (conditional) association between variables. Use negative
            p-value of independence test.
            """
            return 1 - chi_square(X, Y, Zs, self.data)[1]
github pgmpy / pgmpy / pgmpy / estimators / base.py View on Github external
def test_conditional_independence(
        self, X, Y, Zs=[], method="chi_square", tol=0.01, **kwargs
    ):
        if method == "chi_square":
            param, p_value = chi_square(
                X=X, Y=Y, Z=Zs, data=self.data, state_names=self.state_names
            )
            if p_value >= tol:
                return True
            else:
                return False

        elif method == "pearsonr":
            param, p_value = pearsonr(X=X, Y=Y, Z=Zs, data=self.data, **kwargs)
            if abs(param) <= tol:
                return True
            else:
                return False