23d57c2f5ea599912459f1c7c44bfb0a83f5bdc6,pgmpy/readwrite/BIF.py,BIFReader,get_cpd,#BIFReader#,234

Before Change


            self.grammar.variable_cpds
        except AttributeError:
            self.grammar = self.Get_grammar(self.network)
        return self.grammar.variable_cpds

    def get_parents(self):

        

After Change


            variable_parents[names[0]] = names[1:]
        return variable_parents

    def get_cpd(self):

        
        Returns the CPD of the variables present in the network

        Example
        --------
        >>> from pgmpy.readwrite import BIFReader
        >>> reader = BIFReader("bif_test.bif")
        >>> reader.get_cpd()
        {"bowel-problem": np.array([[0.01],
                                    [0.99]]),
        "dog-out": np.array([[0.99, 0.97, 0.9, 0.3],
                            [0.01, 0.03, 0.1, 0.7]]),
        "family-out": np.array([[0.15],
                                [0.85]]),
        "hear-bark": np.array([[0.7, 0.01],
                                [0.3, 0.99]]),
        "light-on": np.array([[0.6, 0.05],
                            [0.4, 0.95]])}
         
        variable_cpds = {}
        for block in self.probability_block:
            name = self.probability_expr.searchString(block)[0][0]
            cpds = self.cpd_expr.searchString(block)
            arr = [float(j) for i in cpds for j in i]
            arr = numpy.array(arr)
            arr = arr.reshape((len(self.variable_states[name]),
                              arr.size//len(self.variable_states[name])))
            variable_cpds[name] = arr

        return variable_cpds

    def get_edges(self):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 10

Instances


Project Name: pgmpy/pgmpy
Commit Name: 23d57c2f5ea599912459f1c7c44bfb0a83f5bdc6
Time: 2015-11-16
Author: utkarsh.gupta550@gmail.com
File Name: pgmpy/readwrite/BIF.py
Class Name: BIFReader
Method Name: get_cpd


Project Name: pgmpy/pgmpy
Commit Name: 23d57c2f5ea599912459f1c7c44bfb0a83f5bdc6
Time: 2015-11-16
Author: utkarsh.gupta550@gmail.com
File Name: pgmpy/readwrite/BIF.py
Class Name: BIFReader
Method Name: get_cpd


Project Name: pgmpy/pgmpy
Commit Name: 23d57c2f5ea599912459f1c7c44bfb0a83f5bdc6
Time: 2015-11-16
Author: utkarsh.gupta550@gmail.com
File Name: pgmpy/readwrite/BIF.py
Class Name: BIFReader
Method Name: get_variables


Project Name: pgmpy/pgmpy
Commit Name: 23d57c2f5ea599912459f1c7c44bfb0a83f5bdc6
Time: 2015-11-16
Author: utkarsh.gupta550@gmail.com
File Name: pgmpy/readwrite/BIF.py
Class Name: BIFReader
Method Name: get_parents