def main():
    file_name_labeled_examples = 'D:\\KUL\\KUL MAI\\Masterproef\\data\\ACE-examples-data\\ace\\mach\\keys\\mach.kb'
    file_name_settings = 'D:\\KUL\\KUL MAI\\Masterproef\\data\\ACE-examples-data\\ace\\mach\\keys\\mach.s'
    file_name_background = 'D:\\KUL\\KUL MAI\\Masterproef\\data\\ACE-examples-data\\ace\\mach\\keys\mach.bg'

    use_clausedb = True
    use_mle = False

    debug_printing_example_parsing = False
    debug_printing_tree_building = False
    debug_printing_tree_pruning = False
    debug_printing_program_conversion = False
    debug_printing_get_classifier = False
    debug_printing_classification = True

    parsed_settings = KeysSettingsParser().parse(file_name_settings)

    treebuilder_type = TreeBuilderType.DETERMINISTIC

    # background_knowledge = parse_background_knowledge(file_name_background)

    if use_clausedb:
        internal_ex_format = InternalExampleFormat.CLAUSEDB
    else:
        internal_ex_format = InternalExampleFormat.SIMPLEPROGRAM

    run_keys(file_name_labeled_examples, parsed_settings, internal_ex_format, treebuilder_type,
             fname_background_knowledge=file_name_background,
             debug_printing_example_parsing=debug_printing_example_parsing,
             debug_printing_tree_building=debug_printing_tree_building,
             debug_printing_tree_pruning=debug_printing_tree_pruning,
             debug_printing_program_conversion=debug_printing_program_conversion,
             debug_printing_get_classifier=debug_printing_get_classifier,
             debug_printing_classification=debug_printing_classification
             )
Example #2
0
def main():
    project_dir = '/home/joschout/Repos/tilde'

    dataset_name = 'mach'
    data_dir = os.path.join(project_dir, 'ACE-examples-data', dataset_name)

    keys_or_examples = 'keys'

    file_name_settings = os.path.join(data_dir, keys_or_examples, dataset_name + '.s')
    file_name_background = os.path.join(data_dir, keys_or_examples, dataset_name + '.bg')
    file_name_labeled_examples = os.path.join(data_dir, keys_or_examples, dataset_name + '.kb')

    use_clausedb = True
    use_mle = False

    debug_printing_example_parsing = False
    debug_printing_tree_building = False
    debug_printing_tree_pruning = False
    debug_printing_program_conversion = False
    debug_printing_get_classifier = False
    debug_printing_classification = True

    parsed_settings = KeysSettingsParser().parse(file_name_settings)

    treebuilder_type = TreeBuilderType.DETERMINISTIC

    # background_knowledge = parse_background_knowledge(file_name_background)

    if use_clausedb:
        internal_ex_format = InternalExampleFormat.CLAUSEDB
    else:
        internal_ex_format = InternalExampleFormat.SIMPLEPROGRAM

    run_keys(file_name_labeled_examples, parsed_settings, internal_ex_format, treebuilder_type,
             fname_background_knowledge=file_name_background,
             debug_printing_example_parsing=debug_printing_example_parsing,
             debug_printing_tree_building=debug_printing_tree_building,
             debug_printing_tree_pruning=debug_printing_tree_pruning,
             debug_printing_program_conversion=debug_printing_program_conversion,
             debug_printing_get_classifier=debug_printing_get_classifier,
             debug_printing_classification=debug_printing_classification
             )
from mai_version.run.run_keys import run_keys
from mai_version.trees.TreeBuilder import TreeBuilderType

file_name_labeled_examples = '/home/joschout/Documents/tilde_data/ACE-examples-data/ace/bongard/keys/bongard.kb'
file_name_settings = '/home/joschout/Documents/tilde_data/ACE-examples-data/ace/bongard/keys/bongard.s'

use_clausedb = True

debug_printing_example_parsing = False
debug_printing_tree_building = False
debug_printing_tree_pruning = False
debug_printing_program_conversion = True
debug_printing_get_classifier = False
debug_printing_classification = False

parsed_settings = KeysSettingsParser().parse(file_name_settings)

treebuilder_type = TreeBuilderType.DETERMINISTIC

if use_clausedb:
    internal_ex_format = InternalExampleFormat.CLAUSEDB
else:
    internal_ex_format = InternalExampleFormat.SIMPLEPROGRAM

times = []
#
for i in range(0, 10):
    #
    start = timeit.default_timer()

    run_keys(
Example #4
0


"""
from typing import Dict

from problog.logic import Constant
from problog.program import PrologString, SimpleProgram

from mai_version.IO.parsing_settings.setting_parser import KeysSettingsParser
from mai_version.IO.parsing_settings.utils import FileSettings

fname_kb = "D:\\KUL\\KUL MAI\\Masterproef\\TILDE\\tilde\\fold\\data\\sisya\\t-0-0-0\\sisy.kb"
fname_s = "D:\\KUL\\KUL MAI\\Masterproef\\TILDE\\tilde\\fold\\data\\sisya\\t-0-0-0\\sisy.s"

parsed_settings = KeysSettingsParser().parse(fname_s)  # type: FileSettings
language = parsed_settings.language

kb_pstr = PrologString(fname_kb)




example_key_type_name = "ptid"


example_databases = {}  # type: Dict[Constant, SimpleProgram]

# for statement in kb_pstr:
#
#
Example #5
0
                                   nb_folds=nb_folds,
                                   fold_suffix=fold_suffix)

# -- create output directory
if not os.path.exists(file_name_data.output_dir):
    os.makedirs(file_name_data.output_dir)

print("start bongard4")
save_stdout = sys.stdout
if hide_printouts:
    sys.stdout = open(os.devnull, "w")

    # read in the fold information
    # read in the examples

    parsed_settings = KeysSettingsParser().parse(file_name_data.fname_settings)

    language = parsed_settings.language  # type: TypeModeLanguage

    # TODO: unify this with models --> let models use a prediction goal predicate label()
    prediction_goal_handler = parsed_settings.get_prediction_goal_handler(
    )  # type: KeysPredictionGoalHandler
    prediction_goal = prediction_goal_handler.get_prediction_goal(
    )  # type: Term

    print('=== START parsing background ===')
    background_knowledge_wrapper \
        = parse_background_knowledge_keys(file_name_data.fname_background,
                                          prediction_goal)  # type: BackgroundKnowledgeWrapper

    full_background_knowledge_sp \