ca09dcecea454e6552a7f30e57aef1dc4f2f295e,pgmpy/estimators/StructureScore.py,BDeuScore,local_score,#BDeuScore#Any#Any#,178

Before Change


        var_states = self.state_names[variable]
        var_cardinality = len(var_states)
        state_counts = self.state_counts(variable, parents)
        num_parents_states = float(len(state_counts.columns))

        score = 0
        for (
            parents_state
        ) in state_counts:  // iterate over df columns (only 1 if no parents)
            conditional_sample_size = sum(state_counts[parents_state])

            score += lgamma(self.equivalent_sample_size / num_parents_states) - lgamma(
                conditional_sample_size
                + self.equivalent_sample_size / num_parents_states
            )

            for state in var_states:
                if state_counts[parents_state][state] > 0:
                    score += lgamma(

After Change


        state_counts = self.state_counts(variable, parents)
        num_parents_states = float(state_counts.shape[1])

        counts = np.asarray(state_counts)
        log_gamma_counts = np.zeros_like(counts, dtype=np.float_)

        alpha = self.equivalent_sample_size / num_parents_states
        beta = self.equivalent_sample_size / counts.size

        // Compute log(gamma(counts + beta))
        gammaln(counts + beta, out=log_gamma_counts)

        // Compute the log-gamma conditional sample size
        log_gamma_conds = np.sum(counts, axis=0, dtype=np.float_)
        gammaln(log_gamma_conds + alpha, out=log_gamma_conds)

        score = (
            np.sum(log_gamma_counts)
            - np.sum(log_gamma_conds)
            + num_parents_states * lgamma(alpha)
            - counts.size * lgamma(beta)
        )

        return score

Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 6

Instances


Project Name: pgmpy/pgmpy
Commit Name: ca09dcecea454e6552a7f30e57aef1dc4f2f295e
Time: 2020-08-11
Author: tristandeleu@users.noreply.github.com
File Name: pgmpy/estimators/StructureScore.py
Class Name: BDeuScore
Method Name: local_score


Project Name: pfnet/optuna
Commit Name: 40d975f2d040d02b1e6dfa93fb830f11d0e39e2d
Time: 2020-07-06
Author: phjgt308@gmail.com
File Name: optuna/visualization/_edf.py
Class Name:
Method Name: _get_edf_plot


Project Name: scikit-multiflow/scikit-multiflow
Commit Name: c758ff3b1b34c2f041306018f726306f4d7eee32
Time: 2018-10-11
Author: p.gijsbers@tue.nl
File Name: tests/meta/test_adaptive_random_forests.py
Class Name:
Method Name: test_adaptive_random_forests_labels_given