Пример #1
0
 def learning(self):
     mln = MLN(mlnfile=self.mln_path, grammar='StandardGrammar')
     db = Database(mln, dbfile=self.db_path)
     for method in ('BPLL', 'BPLL_CG', 'CLL'):
         print('=== LEARNING TEST:', method, '===')
         learn(method=method, mln=mln, db=db, verbose=True,
               multicore=False).run()
Пример #2
0
def test_learning_taxonomies():
    p = '$PRACMLN_HOME/examples/taxonomies/taxonomies.pracmln'
    mln = MLN(mlnfile=('%s:senses_and_roles.mln' % p), grammar='PRACGrammar')
    mln.write()
    dbs = Database.load(mln, dbfiles='%s:training.db' % p)
    for method in ('DPLL', 'DBPLL_CG', 'DCLL'):
        for multicore in (True, False):
            print '=== LEARNING TEST:', method, '==='
            learn(method=method, mln=mln, db=dbs, verbose=True, multicore=multicore, epreds='is_a', discr_preds=EVIDENCE_PREDS).run()
Пример #3
0
def test_learning_smokers():
    p = '$PRACMLN_HOME/examples/smokers/smokers.pracmln'
    mln = MLN(mlnfile=('%s:smoking.mln' % p), grammar='StandardGrammar')
    mln.write()
    db = Database(mln, dbfile='%s:smoking-train.db' % p)
    for method in ('BPLL', 'BPLL_CG', 'CLL'):
        for multicore in (True, False):
            print '=== LEARNING TEST:', method, '==='
            learn(method=method, mln=mln, db=db, verbose=True, multicore=multicore).run()
Пример #4
0
def test_learning_smokers():
    p = os.path.join(locs.examples, 'smokers', 'smokers.pracmln')
    mln = MLN(mlnfile=('%s:smoking.mln' % p), grammar='StandardGrammar')
    mln.write()
    db = Database(mln, dbfile='%s:smoking-train.db' % p)
    for method in ('BPLL', 'BPLL_CG', 'CLL'):
        for multicore in (True, False):
            print('=== LEARNING TEST:', method, '===')
            learn(method=method,
                  mln=mln,
                  db=db,
                  verbose=True,
                  multicore=multicore).run()
Пример #5
0
def test_learning_taxonomies():
    p = os.path.join(locs.examples, 'taxonomies', 'taxonomies.pracmln')
    mln = MLN(mlnfile=('%s:senses_and_roles.mln' % p), grammar='PRACGrammar')
    mln.write()
    dbs = Database.load(mln, dbfiles='%s:training.db' % p)
    for method in ('DPLL', 'DBPLL_CG', 'DCLL'):
        for multicore in (True, False):
            print('=== LEARNING TEST:', method, '===')
            learn(method=method,
                  mln=mln,
                  db=dbs,
                  verbose=True,
                  multicore=multicore,
                  epreds='is_a',
                  discr_preds=EVIDENCE_PREDS).run()
Пример #6
0
def test_learning_smokers(arg='.', disp=False):
    pth = os.path.join(arg, 'smoking.mln')
    mln = MLN(mlnfile=pth, grammar='StandardGrammar')
    pth = os.path.join(arg, 'smoking-train.db')
    db = Database(mln, dbfile=pth)
    for method in ('BPLL', 'BPLL_CG', 'CLL'):
        for multicore in (True, False):
            print('=== LEARNING TEST:', method, '===')
            if disp:
                query(queries='Cancer,Smokes,Friends',
                      method=method,
                      mln=mln,
                      db=db,
                      verbose=disp,
                      multicore=multicore).run().write()
            else:
                learn(method=method,
                      mln=mln,
                      db=db,
                      verbose=disp,
                      multicore=multicore).run()