refine_plan.learning.option_learning

Functions for processing datsets and learning DBNs.

Author: Charlie Street Owner: Charlie Street

Functions

mongodb_to_dict(connection_str, db_name, ...[, query, ...])

Process a mongodb collection into a dictionary for learning.

mongodb_to_yaml(connection_str, db_name, ...[, query, ...])

Processes a mongodb collection into a yaml dataset for DBN learning.

learn_bns_for_one_option(option_dataset, sf_list)

Learn a transition DBN and a reward BN for a single option.

learn_dbns(dataset_path, output_dir, sf_list)

Learn a set of DBNs representing options.

Module Contents

refine_plan.learning.option_learning.mongodb_to_dict(connection_str, db_name, collection_name, sf_list, query={}, sort_by=None, limit=None, split_by_motion=False)

Process a mongodb collection into a dictionary for learning.

Parameters:
  • connection_str – The mongodb connection string

  • db_name – The Mongo database name

  • collection_name – The collection within the database

  • sf_list – The list of state factors to expect in the MongoDB

  • out_file – The path for the yaml file

  • query – A query to filter the documents that get collected

  • sort_by – A field to sort the documents by

  • limit – A limit on the number of documents returned

  • split_by_motion – Should the option datasets be split by motion parameter?

Returns:

The dataset from mongodb into a pyAgrum format dictionary

Return type:

dataset_dict

refine_plan.learning.option_learning.mongodb_to_yaml(connection_str, db_name, collection_name, sf_list, out_file, query={}, sort_by=None, limit=None, split_by_motion=False)

Processes a mongodb collection into a yaml dataset for DBN learning.

Parameters:
  • connection_str – The mongodb connection string

  • db_name – The Mongo database name

  • collection_name – The collection within the database

  • sf_list – The list of state factors to expect in the MongoDB

  • out_file – The path for the yaml file

  • query – A query to filter the documents that get collected

  • sort_by – A field to sort the documents by

  • limit – A limit on the number of documents returned

  • split_by_motion – Should the option datasets be split by motion parameter?

refine_plan.learning.option_learning.learn_bns_for_one_option(option_dataset, sf_list)

Learn a transition DBN and a reward BN for a single option.

This function is slightly different to learn_dbns. learn_dbns is the general recommended function, but this function allows for one option model to be learned without reading or writing anything. It’s intended use is for updating models online for exploration.

The dataset should be a dictionary with two keys: ‘transition’ and ‘reward’. In ‘transition’ there should be a dictionary with keys sf0 and sft for each state factor sf. At each of these keys is a list of data. In ‘reward’ there should be a dictionary with keys sf for each state factor sf, and ‘r’ to represent the reward. At each of these keys is a list of data.

Parameters:
  • option_dataset – A dictionary containing the dataset for this option

  • sf_list – The list of state factors we expect to see in the dataset

Returns:

The DBN for the transition function and the BN for the reward function

refine_plan.learning.option_learning.learn_dbns(dataset_path, output_dir, sf_list)

Learn a set of DBNs representing options.

The dataset should be a dictionary from options to a dictionary with two keys: ‘transition’ and ‘reward’. In ‘transition’ there should be a dictionary with keys sf0 and sft for each state factor sf. At each of these keys is a list of data. In ‘reward’ there should be a dictionary with keys sf for each state factor sf, and ‘r’ to represent the reward. At each of these keys is a list of data.

Parameters:
  • dataset_path – A yaml file containing the dataset.

  • output_dir – The output directory for the DBNs.

  • sf_list – The list of state factors we expect to see in the dataset