rfgb.rdn package

New in version 0.3.0.

Learn and infer with relational dependency networks.

# Example script for performing learning and inference.

from rfgb import rdn

# rdn.learn requires a list of targets as strings.
trees = rdn.learn(['cancer'], path='testDomains/ToyCancer/train/')

# rdn.learn returns a dictionary mapping targets to trees.
cancer_trees = trees['cancer']

# rdn.infer classification returns a tuple of pos and neg.
results = rdn.infer('cancer', cancer_trees, path='testDomains/ToyCancer/test/')

# ({'cancer(xena)': 0.34460796550872186,
#   'cancer(yoda)': 0.34460796550872186,
#   'cancer(zod)': 0.34460796550872186},
#  {'cancer(watson)': 0.34460796550872186,
#   'cancer(voldemort)': 0.34460796550872186})

rfgb.rdn.learn module

rfgb.rdn.learn.learn(targets, numTrees=10, path='', regression=False, advice=False, softm=False, alpha=0.0, beta=0.0, saveJson=True)[source]

New in version 0.3.0.

Learn a relational dependency network from facts and positive/negative examples via relational regression trees.

Note

This currently requires that training data is stored as files on disk.

Parameters:
  • targets (list of str.) – List of target predicates to learn models for.
  • numTrees (int.) – Number of trees to learn.
  • path (str.) – Path to the location training data is stored.
  • regression (bool.) – Learn a regression model instead of classification.
  • advice (bool.) – Read an advice file from the same directory as trainPath.
Default regression:
 

False

Default advice:

False

Returns:

Dictionary where the key is the target and the value is the set of trees returned for that target.

Return type:

dict.

rfgb.rdn.infer module

rfgb.rdn.infer.infer(target, trees, path='', regression=False)[source]

New in version 0.3.0.

Perform inference on data with a set of trees.

Note

This currently requires that test data is stored as files on disk.

Parameters:
  • trees (list of str.) – Trees to perform inference with.
  • path (str.) – Path to the location test data is stored.
  • regression (bool.) – Infer with a regression model instead of classification.
Default regression:
 

False

Returns:

Tuple of results. In classification these results will be a tuple of positive and negative examples. In regression this will be the examples.

Return type:

tuple