Commit 835a1ba9 authored by Anze Vavpetic's avatar Anze Vavpetic

mapper fix when the target table has exactly two attributes and no features...

mapper fix when the target table has exactly two attributes and no features are produced; isprogramirano
parent 2665962d
......@@ -117,8 +117,7 @@ class RSD_Converter(ILP_Converter):
'''
Converts the database context to RSD inputs.
'''
def all_examples(self):
target = self.db.target_table
def all_examples(self, target=self.db.target_table):
examples = self.db.rows(target, [self.db.target_att, self.db.pkeys[target]])
return '\n'.join(["%s('%s', %s)." % (target, cls, pk) for cls, pk in examples])
......
......@@ -29,8 +29,9 @@ def domain_map(features, feature_format, train_context, test_context,
if feature_format in ['rsd', 'aleph']:
train_rsd = RSD_Converter(train_context)
test_rsd = RSD_Converter(test_context, discr_intervals=intervals)
train_examples = train_rsd.all_examples()
test_examples = test_rsd.all_examples()
mapper_target_name = train_context.target_table + '_mapper'
train_examples = train_rsd.all_examples(target=mapper_target_name)
test_examples = test_rsd.all_examples(target=mapper_target_name)
if feature_format == 'aleph':
features = aleph_to_rsd_features(features)
......@@ -53,7 +54,7 @@ def domain_map(features, feature_format, train_context, test_context,
f = tempfile.NamedTemporaryFile(delete=False)
f.write(prolog_bk)
f.close()
cmd_args = ['yap', '-L', '--', '%s/mapper.pl' % THIS_DIR, f.name, train_context.target_table]
cmd_args = ['yap', '-L', '--', '%s/mapper.pl' % THIS_DIR, f.name, mapper_target_name]
evaluations = subprocess.check_output(cmd_args)
dataset = dump_dataset(features, feature_format, evaluations,
train_context,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment