refine_plan.learning.option_learning ==================================== .. py:module:: refine_plan.learning.option_learning .. autoapi-nested-parse:: Functions for processing datsets and learning DBNs. Author: Charlie Street Owner: Charlie Street Functions --------- .. autoapisummary:: refine_plan.learning.option_learning.mongodb_to_dict refine_plan.learning.option_learning.mongodb_to_yaml refine_plan.learning.option_learning.learn_bns_for_one_option refine_plan.learning.option_learning.learn_dbns Module Contents --------------- .. py:function:: 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. :param connection_str: The mongodb connection string :param db_name: The Mongo database name :param collection_name: The collection within the database :param sf_list: The list of state factors to expect in the MongoDB :param out_file: The path for the yaml file :param query: A query to filter the documents that get collected :param sort_by: A field to sort the documents by :param limit: A limit on the number of documents returned :param split_by_motion: Should the option datasets be split by motion parameter? :returns: The dataset from mongodb into a pyAgrum format dictionary :rtype: dataset_dict .. py:function:: 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. :param connection_str: The mongodb connection string :param db_name: The Mongo database name :param collection_name: The collection within the database :param sf_list: The list of state factors to expect in the MongoDB :param out_file: The path for the yaml file :param query: A query to filter the documents that get collected :param sort_by: A field to sort the documents by :param limit: A limit on the number of documents returned :param split_by_motion: Should the option datasets be split by motion parameter? .. py:function:: 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. :param option_dataset: A dictionary containing the dataset for this option :param 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 .. py:function:: 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. :param dataset_path: A yaml file containing the dataset. :param output_dir: The output directory for the DBNs. :param sf_list: The list of state factors we expect to see in the dataset