How to use the pomegranate.Node function in pomegranate

To help you get started, we’ve selected a few pomegranate 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 DAI-Lab / SDGym / sdgym / utils / data / simulated / multivariate.py View on Github external
XRay = ConditionalProbabilityTable(
            [['T','T',0.9],
            ['T','F',0.1],
            ['F','T',0.2],
            ['F','F',0.8],
            ],[Cancer])
        Dyspnoea = ConditionalProbabilityTable(
            [['T','T',0.65],
            ['T','F',0.35],
            ['F','T',0.3],
            ['F','F',0.7],
            ],[Cancer])
        s1 = Node(Pollution, name="Pollution")
        s2 = Node(Smoker, name="Smoker")
        s3 = Node(Cancer, name="Cancer")
        s4 = Node(XRay, name="XRay")
        s5 = Node(Dyspnoea, name="Dyspnoea")

        model = BayesianNetwork("Lung Cancer")
        model.add_states(s1, s2, s3, s4, s5)
        model.add_edge(s1, s3)
        model.add_edge(s2, s3)
        model.add_edge(s3, s4)
        model.add_edge(s3, s5)
        model.bake()
        self.model = model

        meta = []
        name_mapper = ["Pollution", "Smoker", "Cancer", "XRay", "Dyspnoea"]
        for i in range(self.model.node_count()):
            meta.append({
                "name": name_mapper[i],
github DAI-Lab / SDGym / sdgym / utils / data / simulated / multivariate.py View on Github external
],[Pollution,Smoker])
        print(Cancer)
        XRay = ConditionalProbabilityTable(
            [['T','T',0.9],
            ['T','F',0.1],
            ['F','T',0.2],
            ['F','F',0.8],
            ],[Cancer])
        Dyspnoea = ConditionalProbabilityTable(
            [['T','T',0.65],
            ['T','F',0.35],
            ['F','T',0.3],
            ['F','F',0.7],
            ],[Cancer])
        s1 = Node(Pollution, name="Pollution")
        s2 = Node(Smoker, name="Smoker")
        s3 = Node(Cancer, name="Cancer")
        s4 = Node(XRay, name="XRay")
        s5 = Node(Dyspnoea, name="Dyspnoea")

        model = BayesianNetwork("Lung Cancer")
        model.add_states(s1, s2, s3, s4, s5)
        model.add_edge(s1, s3)
        model.add_edge(s2, s3)
        model.add_edge(s3, s4)
        model.add_edge(s3, s5)
        model.bake()
        self.model = model

        meta = []
        name_mapper = ["Pollution", "Smoker", "Cancer", "XRay", "Dyspnoea"]
        for i in range(self.model.node_count()):
github DAI-Lab / SDGym / sdgym / utils / data / simulated / multivariate.py View on Github external
['F','F','F',0.999],
            ],[Pollution,Smoker])
        print(Cancer)
        XRay = ConditionalProbabilityTable(
            [['T','T',0.9],
            ['T','F',0.1],
            ['F','T',0.2],
            ['F','F',0.8],
            ],[Cancer])
        Dyspnoea = ConditionalProbabilityTable(
            [['T','T',0.65],
            ['T','F',0.35],
            ['F','T',0.3],
            ['F','F',0.7],
            ],[Cancer])
        s1 = Node(Pollution, name="Pollution")
        s2 = Node(Smoker, name="Smoker")
        s3 = Node(Cancer, name="Cancer")
        s4 = Node(XRay, name="XRay")
        s5 = Node(Dyspnoea, name="Dyspnoea")

        model = BayesianNetwork("Lung Cancer")
        model.add_states(s1, s2, s3, s4, s5)
        model.add_edge(s1, s3)
        model.add_edge(s2, s3)
        model.add_edge(s3, s4)
        model.add_edge(s3, s5)
        model.bake()
        self.model = model

        meta = []
        name_mapper = ["Pollution", "Smoker", "Cancer", "XRay", "Dyspnoea"]
github DAI-Lab / SDGym / sdgym / utils / data / simulated / multivariate.py View on Github external
for v_name in todo:
                # print(v_name, type(var_nodes[v_name]))
                cond_p_table, cond = var_nodes[v_name]
                flag = True
                for y in cond[1:]:
                    if y in todo:
                        flag = False
                        break
                if flag:
                    cond_t = [var_nodes[x] for x in cond[1:]]
                    var_nodes[v_name] = ConditionalProbabilityTable(cond_p_table, cond_t)
                    todo.remove(v_name)
                    break

        for x in var_index_to_name:
            var_nodes[x] = Node(var_nodes[x], name=x)

        var_nodes_list = [var_nodes[x] for x in var_index_to_name]
        # print(var_nodes_list)
        model = BayesianNetwork("tmp")
        model.add_states(*var_nodes_list)

        for edge in edges:
            model.add_edge(var_nodes[edge[0]], var_nodes[edge[1]])
        model.bake()
        # print(model.to_json())
        self.model = model
github DAI-Lab / SDGym / sdgym / utils / data / simulated / multivariate.py View on Github external
['3','3',0.5],
            ],[A])
        C = ConditionalProbabilityTable(
            [['1','4',0.5],
            ['1','5',0.5],
            ['1','6',0],
            ['2','4',0],
            ['2','5',0.5],
            ['2','6',0.5],
            ['3','4',0.5],
            ['3','5',0],
            ['3','6',0.5],
            ],[A])

        s1 = Node(A, name="A")
        s2 = Node(B, name="B")
        s3 = Node(C, name="C")

        model = BayesianNetwork("tree")
        model.add_states(s1, s2, s3)
        model.add_edge(s1, s2)
        model.add_edge(s1, s3)
        model.bake()
        self.model = model

        meta = []
        for i in range(self.model.node_count()-1):
            meta.append({
                "name": chr(ord('A') + i),
                "type": "categorical",
                "size": 3,
                "i2s": ['1', '2', '3']
github DAI-Lab / SDGym / sdgym / utils / data / simulated / multivariate.py View on Github external
print(Cancer)
        XRay = ConditionalProbabilityTable(
            [['T','T',0.9],
            ['T','F',0.1],
            ['F','T',0.2],
            ['F','F',0.8],
            ],[Cancer])
        Dyspnoea = ConditionalProbabilityTable(
            [['T','T',0.65],
            ['T','F',0.35],
            ['F','T',0.3],
            ['F','F',0.7],
            ],[Cancer])
        s1 = Node(Pollution, name="Pollution")
        s2 = Node(Smoker, name="Smoker")
        s3 = Node(Cancer, name="Cancer")
        s4 = Node(XRay, name="XRay")
        s5 = Node(Dyspnoea, name="Dyspnoea")

        model = BayesianNetwork("Lung Cancer")
        model.add_states(s1, s2, s3, s4, s5)
        model.add_edge(s1, s3)
        model.add_edge(s2, s3)
        model.add_edge(s3, s4)
        model.add_edge(s3, s5)
        model.bake()
        self.model = model

        meta = []
        name_mapper = ["Pollution", "Smoker", "Cancer", "XRay", "Dyspnoea"]
        for i in range(self.model.node_count()):
            meta.append({
github DAI-Lab / SDGym / sdgym / utils / data / simulated / multivariate.py View on Github external
['3','2',0],
            ['3','3',0.5],
            ],[A])
        C = ConditionalProbabilityTable(
            [['1','1',0.5],
            ['1','2',0.5],
            ['1','3',0],
            ['2','1',0],
            ['2','2',0.5],
            ['2','3',0.5],
            ['3','1',0.5],
            ['3','2',0],
            ['3','3',0.5],
            ],[B])

        s1 = Node(A, name="A")
        s2 = Node(B, name="B")
        s3 = Node(C, name="C")

        model = BayesianNetwork("ChainSampler")
        model.add_states(s1, s2, s3)
        model.add_edge(s1, s2)
        model.add_edge(s2, s3)
        model.bake()
        self.model = model

        meta = []
        for i in range(self.model.node_count()):
            meta.append({
                "name": chr(ord('A') + i),
                "type": "categorical",
                "size": 3,
github DAI-Lab / SDGym / sdgym / utils / data / simulated / multivariate.py View on Github external
['3','3',0.5],
            ],[A])
        C = ConditionalProbabilityTable(
            [['1','1',0.5],
            ['1','2',0.5],
            ['1','3',0],
            ['2','1',0],
            ['2','2',0.5],
            ['2','3',0.5],
            ['3','1',0.5],
            ['3','2',0],
            ['3','3',0.5],
            ],[B])

        s1 = Node(A, name="A")
        s2 = Node(B, name="B")
        s3 = Node(C, name="C")

        model = BayesianNetwork("ChainSampler")
        model.add_states(s1, s2, s3)
        model.add_edge(s1, s2)
        model.add_edge(s2, s3)
        model.bake()
        self.model = model

        meta = []
        for i in range(self.model.node_count()):
            meta.append({
                "name": chr(ord('A') + i),
                "type": "categorical",
                "size": 3,
                "i2s": ['1', '2', '3']
github DAI-Lab / SDGym / sdgym / utils / data / simulated / multivariate.py View on Github external
],[A])
        C = ConditionalProbabilityTable(
            [['1','4',0.5],
            ['1','5',0.5],
            ['1','6',0],
            ['2','4',0],
            ['2','5',0.5],
            ['2','6',0.5],
            ['3','4',0.5],
            ['3','5',0],
            ['3','6',0.5],
            ],[A])

        s1 = Node(A, name="A")
        s2 = Node(B, name="B")
        s3 = Node(C, name="C")

        model = BayesianNetwork("tree")
        model.add_states(s1, s2, s3)
        model.add_edge(s1, s2)
        model.add_edge(s1, s3)
        model.bake()
        self.model = model

        meta = []
        for i in range(self.model.node_count()-1):
            meta.append({
                "name": chr(ord('A') + i),
                "type": "categorical",
                "size": 3,
                "i2s": ['1', '2', '3']
        })
github DAI-Lab / SDGym / sdgym / utils / data / simulated / multivariate.py View on Github external
['T','F',0.9],
            ],[Rain])
        Wet = ConditionalProbabilityTable(
            [['F','F','T',0.01],
            ['F','F','F',0.99],
            ['F','T','T',0.8],
            ['F','T','F',0.2],
            ['T','F','T',0.9],
            ['T','F','F',0.1],
            ['T','T','T',0.99],
            ['T','T','F',0.01],
            ],[Sprinkler,Rain])

        s1 = Node(Rain, name="Rain")
        s2 = Node(Sprinkler, name="Sprinkler")
        s3 = Node(Wet, name="Wet")

        model = BayesianNetwork("Simple fully connected")
        model.add_states(s1, s2, s3)
        model.add_edge(s1, s2)
        model.add_edge(s1, s3)
        model.add_edge(s2, s3)
        model.bake()
        self.model = model

        meta = []
        for i in range(self.model.node_count()):
            meta.append({
                "name": None,
                "type": "categorical",
                "size": 2,
                "i2s": ['T', 'F']