ca25da7c55ba436ab557410d5f2e2e9b557d2840,pgmpy/models/MarkovModel.py,MarkovModel,to_junction_tree,#MarkovModel#,412

Before Change


        clique_trees = JunctionTree(nx.minimum_spanning_tree(complete_graph).edges())

        factor = self.factors[0]
        factor = factor.product(*[self.factors[i] for i in
                                  range(1, len(self.factors))])
        if set(factor.scope()) != set(self.nodes()):
            ValueError("Factor for all the random variables not specified")

        all_vars = set(self.nodes())

        for node in clique_trees.nodes():
            marginalised_nodes = all_vars - set(node)
            factor_copy = factor.marginalize(list(marginalised_nodes),
                                             inplace=False)
            clique_trees.add_factors(factor_copy)

        return clique_trees

After Change


        if set(all_vars) != set(self.nodes()):
            ValueError("Factor for all the random variables not specified")

        is_used = {factor: False for factor in self.factors}

        for node in clique_trees.nodes():
            clique_factors = []
            for factor in self.factors:
                if not is_used[factor] and set(factor.scope()).issubset(node):
                    clique_factors.append(factor)
                    is_used[factor] = True

            clique_potential = factor_product(*clique_factors)
            clique_trees.add_factors(clique_potential)

        if not all(is_used.values()):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 8

Instances


Project Name: pgmpy/pgmpy
Commit Name: ca25da7c55ba436ab557410d5f2e2e9b557d2840
Time: 2015-03-02
Author: abinash.panda.ece10@itbhu.ac.in
File Name: pgmpy/models/MarkovModel.py
Class Name: MarkovModel
Method Name: to_junction_tree


Project Name: ClimbsRocks/auto_ml
Commit Name: 33851dea0f6c75ca1e685037393ea7160506b53a
Time: 2016-10-08
Author: climbsbytes@gmail.com
File Name: auto_ml/predictor.py
Class Name: Predictor
Method Name: _prepare_for_training


Project Name: biolab/orange3
Commit Name: 8d4d199c35f5163ed21ae705a16ce3c8548d60c6
Time: 2012-11-28
Author: janez.demsar@fri.uni-lj.si
File Name: Orange/data/io.py
Class Name: BasketReader
Method Name: prescan_file