当前位置: 首页>>代码示例>>Python>>正文


Python GraphSkeleton.load方法代码示例

本文整理汇总了Python中libpgm.graphskeleton.GraphSkeleton.load方法的典型用法代码示例。如果您正苦于以下问题:Python GraphSkeleton.load方法的具体用法?Python GraphSkeleton.load怎么用?Python GraphSkeleton.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在libpgm.graphskeleton.GraphSkeleton的用法示例。


在下文中一共展示了GraphSkeleton.load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

# 需要导入模块: from libpgm.graphskeleton import GraphSkeleton [as 别名]
# 或者: from libpgm.graphskeleton.GraphSkeleton import load [as 别名]
    def setUp(self):
        nodedata = NodeData.load("unittestlgdict.txt")
        skel = GraphSkeleton()
        skel.load("unittestdict.txt")
        skel.toporder()

        self.lgb = LGBayesianNetwork(nodedata)
开发者ID:Anaphory,项目名称:libpgm,代码行数:9,代码来源:run_unit_tests.py

示例2: setUp

# 需要导入模块: from libpgm.graphskeleton import GraphSkeleton [as 别名]
# 或者: from libpgm.graphskeleton.GraphSkeleton import load [as 别名]
 def setUp(self):
     skel = GraphSkeleton()
     skel.load("unittestdict.txt")
     skel.toporder()
     nodedata = NodeData()
     nodedata.load("unittestdict.txt")
     self.instance = DiscreteBayesianNetwork(skel, nodedata)
开发者ID:CyberPoint,项目名称:libpgm,代码行数:9,代码来源:run_unit_tests.py

示例3: test_hybn_mte_estimateparams

# 需要导入模块: from libpgm.graphskeleton import GraphSkeleton [as 别名]
# 或者: from libpgm.graphskeleton.GraphSkeleton import load [as 别名]
    def test_hybn_mte_estimateparams(self):
        skel = GraphSkeleton()
        skel.load("../tests/bn_skeleton.txt")
        skel.toporder()
        
        with open('../tests/dataBR2.json', 'r') as f:
            samples = eval(f.read())

        result = self.l.hybn_mte_estimateparams(self.skel, self.samplelgseq)        
开发者ID:stchepanhagn,项目名称:libpgm,代码行数:11,代码来源:run_unit_tests.py

示例4: getTableCPD

# 需要导入模块: from libpgm.graphskeleton import GraphSkeleton [as 别名]
# 或者: from libpgm.graphskeleton.GraphSkeleton import load [as 别名]
def getTableCPD():
   nd = NodeData()
   skel = GraphSkeleton()
   jsonpath = "job_interview.txt"
   nd.load(jsonpath)
   skel.load(jsonpath)

   #load bayesian network
   bn = DiscreteBayesianNetwork(skel, nd)
   tablecpd = TableCPDFactorization(bn)
   return tablecpd
开发者ID:gregory2000,项目名称:pycharm_projects,代码行数:13,代码来源:causal_reasoning.py

示例5: load

# 需要导入模块: from libpgm.graphskeleton import GraphSkeleton [as 别名]
# 或者: from libpgm.graphskeleton.GraphSkeleton import load [as 别名]
    def load(self, file_name):
        #### Load BN
        nd = NodeData()
        skel = GraphSkeleton()
        nd.load(file_name)  # any input file
        skel.load(file_name)

        # topologically order graphskeleton
        skel.toporder()

        super(DiscreteBayesianNetworkExt, self).__init__(skel, nd)
        ##TODO load evidence
开发者ID:aurora1625,项目名称:sally-bn,代码行数:14,代码来源:DiscreteBayesianNetworkExt.py

示例6: TestOrderedSkeleton

# 需要导入模块: from libpgm.graphskeleton import GraphSkeleton [as 别名]
# 或者: from libpgm.graphskeleton.GraphSkeleton import load [as 别名]
class TestOrderedSkeleton(unittest.TestCase):

    def setUp(self):
        self.os = OrderedSkeleton()
        self.os.load("unittestdict.txt")
        self.gs = GraphSkeleton()
        self.gs.load("unittestdict.txt")

    def test_constructor(self):
        self.assertNotEqual(self.os.V, self.gs.V)
        self.gs.toporder()
        self.assertEqual(self.os.V, self.gs.V)
开发者ID:CyberPoint,项目名称:libpgm,代码行数:14,代码来源:run_unit_tests.py

示例7: TestDynDiscBayesianNetwork

# 需要导入模块: from libpgm.graphskeleton import GraphSkeleton [as 别名]
# 或者: from libpgm.graphskeleton.GraphSkeleton import load [as 别名]
class TestDynDiscBayesianNetwork(unittest.TestCase):

    def setUp(self):
        self.nd = NodeData.load("unittestdyndict.txt")
        self.skel = GraphSkeleton()
        self.skel.load("unittestdyndict.txt")
        self.skel.toporder()
        self.d = DynDiscBayesianNetwork(self.skel, self.nd)

    def test_randomsample(self):
        sample = self.d.randomsample(10)
        for i in range(1, 10):
            self.assertEqual(sample[0]['Difficulty'], sample[i]['Difficulty'])
开发者ID:Anaphory,项目名称:libpgm,代码行数:15,代码来源:run_unit_tests.py

示例8: TestHyBayesianNetwork

# 需要导入模块: from libpgm.graphskeleton import GraphSkeleton [as 别名]
# 或者: from libpgm.graphskeleton.GraphSkeleton import load [as 别名]
class TestHyBayesianNetwork(unittest.TestCase):

    def setUp(self):
        self.nd = HybridNodeData.load("unittesthdict.txt")
        self.nd.entriestoinstances()
        self.skel = GraphSkeleton()
        self.skel.load("unittestdict.txt")
        self.skel.toporder()
        self.hybn = HyBayesianNetwork(self.skel, self.nd)

    def test_randomsample(self):
        sample = self.hybn.randomsample(1)[0]
        self.assertTrue(isinstance(sample['Grade'], float))
        self.assertTrue(isinstance(sample['Intelligence'], str))
        self.assertEqual(sample["SAT"][-12:], 'blueberries!')
开发者ID:Anaphory,项目名称:libpgm,代码行数:17,代码来源:run_unit_tests.py

示例9: createData

# 需要导入模块: from libpgm.graphskeleton import GraphSkeleton [as 别名]
# 或者: from libpgm.graphskeleton.GraphSkeleton import load [as 别名]
def createData():
   nd = NodeData()
   skel = GraphSkeleton()
   fpath = "job_interview.txt"
   nd.load(fpath)
   skel.load(fpath)
   skel.toporder()
   bn = DiscreteBayesianNetwork(skel, nd)

   learner = PGMLearner()
   data = bn.randomsample(1000)
   X, Y = 'Grades', 'Offer'
   c,p,w=learner.discrete_condind(data, X, Y, ['Interview'])
   print "independence between X and Y: ", c, " p-value ", p, " witness node: ", w
   result = learner.discrete_constraint_estimatestruct(data)
   print result.E
开发者ID:gregory2000,项目名称:pycharm_projects,代码行数:18,代码来源:learn_structure.py

示例10: net2

# 需要导入模块: from libpgm.graphskeleton import GraphSkeleton [as 别名]
# 或者: from libpgm.graphskeleton.GraphSkeleton import load [as 别名]
def net2():
    nd = NodeData()
    skel = GraphSkeleton()
    nd.load("net.txt")  # an input file
    skel.load("net.txt")

    # topologically order graphskeleton
    skel.toporder()

    # load bayesian network
    lgbn = LGBayesianNetwork(skel, nd)

    in_data=read_data.getdata2()
    learner = PGMLearner()
    bn=learner.lg_mle_estimateparams(skel,in_data)

    p=cal_prob(in_data[300:500],bn)
    print p
    return 0
开发者ID:hendrikTpl,项目名称:Bayesian_TrafficPrediction,代码行数:21,代码来源:model2.py

示例11: test_structure_estimation

# 需要导入模块: from libpgm.graphskeleton import GraphSkeleton [as 别名]
# 或者: from libpgm.graphskeleton.GraphSkeleton import load [as 别名]
    def test_structure_estimation(self):
        req = DiscreteStructureEstimationRequest()

        skel = GraphSkeleton()
        skel.load(self.data_path)
        skel.toporder()
        teacher_nd = NodeData()
        teacher_nd.load(self.teacher_data_path)
        bn = DiscreteBayesianNetwork(skel, teacher_nd)
        data = bn.randomsample(8000)
        for v in data:
            gs = DiscreteGraphState()
            for k_s, v_s in v.items():
                gs.node_states.append(DiscreteNodeState(node=k_s, state=v_s))
            req.states.append(gs)

        res = self.struct_estimate(req)
        self.assertIsNotNone(res.graph)
        self.assertEqual(len(res.graph.nodes), 5)
        self.assertGreater(len(res.graph.edges), 0)
开发者ID:1224830613,项目名称:jsk_3rdparty,代码行数:22,代码来源:test_discrete_bn.py

示例12: test_param_estimation

# 需要导入模块: from libpgm.graphskeleton import GraphSkeleton [as 别名]
# 或者: from libpgm.graphskeleton.GraphSkeleton import load [as 别名]
    def test_param_estimation(self):
        req = DiscreteParameterEstimationRequest()

        # load graph structure
        skel = GraphSkeleton()
        skel.load(self.data_path)
        req.graph.nodes = skel.V
        req.graph.edges = [GraphEdge(k, v) for k,v in skel.E]
        skel.toporder()

        # generate trial data
        teacher_nd = NodeData()
        teacher_nd.load(self.teacher_data_path)
        bn = DiscreteBayesianNetwork(skel, teacher_nd)
        data = bn.randomsample(200)
        for v in data:
            gs = DiscreteGraphState()
            for k_s, v_s in v.items():
                gs.node_states.append(DiscreteNodeState(node=k_s, state=v_s))
            req.states.append(gs)

        self.assertEqual(len(self.param_estimate(req).nodes), 5)
开发者ID:1224830613,项目名称:jsk_3rdparty,代码行数:24,代码来源:test_discrete_bn.py

示例13: main

# 需要导入模块: from libpgm.graphskeleton import GraphSkeleton [as 别名]
# 或者: from libpgm.graphskeleton.GraphSkeleton import load [as 别名]
def main():

    in_data=read_data.getdata()
    f_data=format_data(in_data)
    nd = NodeData()
    nd.load("net4.txt")    # an input file
    skel = GraphSkeleton()
    skel.load("net4.txt")
    skel.toporder()
    bn=DiscreteBayesianNetwork(skel,nd)


#training dataset:70%
    bn2=em(f_data[1:6000],bn,skel)

    pr_training = precision(f_data[1:6000],bn2)

    print "Prediction accuracy for training data:" , pr_training[1]

#testing dataset:30%
    pr=precision(f_data[6700:6800],bn2)
    print "Prediction accuracy for test data:", pr[1]
开发者ID:hendrikTpl,项目名称:Bayesian_TrafficPrediction,代码行数:24,代码来源:model2.py

示例14: NodeData

# 需要导入模块: from libpgm.graphskeleton import GraphSkeleton [as 别名]
# 或者: from libpgm.graphskeleton.GraphSkeleton import load [as 别名]
import json

from libpgm.nodedata import NodeData
from libpgm.graphskeleton import GraphSkeleton
from libpgm.discretebayesiannetwork import DiscreteBayesianNetwork
from libpgm.pgmlearner import PGMLearner

# generate some data to use
nd = NodeData()
nd.load("grades.txt")    # an input file
skel = GraphSkeleton()
skel.load("grades.txt")
skel.toporder()
bn = DiscreteBayesianNetwork(skel, nd)
data = bn.randomsample(80000)

# instantiate my learner 
learner = PGMLearner()

# estimate structure
result = learner.discrete_constraint_estimatestruct(data)

# output
print json.dumps(result.E, indent=2)
开发者ID:dropzonemathmo,项目名称:BayesNetCancer,代码行数:26,代码来源:learner.py

示例15: NodeData

# 需要导入模块: from libpgm.graphskeleton import GraphSkeleton [as 别名]
# 或者: from libpgm.graphskeleton.GraphSkeleton import load [as 别名]
import json

from libpgm.nodedata import NodeData
from libpgm.graphskeleton import GraphSkeleton
from libpgm.lgbayesiannetwork import LGBayesianNetwork
from libpgm.pgmlearner import PGMLearner

# generate some data to use
nd = NodeData()
nd.load("gaussGrades.txt")    # an input file
skel = GraphSkeleton()
skel.load("gaussGrades.txt")
skel.toporder()
lgbn = LGBayesianNetwork(skel, nd)
data = lgbn.randomsample(8000)

print data

# instantiate my learner 
learner = PGMLearner()

# estimate structure
result = learner.lg_constraint_estimatestruct(data)

# output
print json.dumps(result.E, indent=2)
开发者ID:dropzonemathmo,项目名称:BayesNetCancer,代码行数:28,代码来源:learnerGauss.py


注:本文中的libpgm.graphskeleton.GraphSkeleton.load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。