1. Syntactic similarity metrics
AMLGym provides several measures for evaluation an action model w.r.t. a reference model or simulator.
[ ]:
!pip install amlgym
[ ]:
from amlgym.metrics import print_metrics
print_metrics()
Learn a model to be evaluated:
[ ]:
from amlgym.benchmarks import get_domain_path, get_trajectories_path
from amlgym.algorithms import get_algorithm
from amlgym.util.util import empty_domain
# Get learning algorithm
learner = get_algorithm('rosame')
# Get an input domain with no preconditions and effects
domain_ref_path = get_domain_path('blocksworld')
domain_empty_path = empty_domain(domain_ref_path)
# Get a set of trajectories to learn from
traj_paths = get_trajectories_path('blocksworld')
# Learn a domain model
model = learner.learn(domain_empty_path, traj_paths)
Print the learned model
[ ]:
print(model)
Save the learned model to a file:
[ ]:
domain_eval_path = 'domain_learned.pddl'
with open(domain_eval_path, 'w') as f:
f.write(model)
Syntactic similarity can be measured by means of precision and recall:
[ ]:
from amlgym.metrics import syntactic_precision
precision = syntactic_precision(domain_eval_path, domain_ref_path)
print(precision)
[ ]:
from amlgym.metrics import syntactic_recall
recall = syntactic_recall(domain_eval_path, domain_ref_path)
print(recall)