def create_networks(self): network = BayesianModel([('goal_left', 'motor_left'), ('goal_right', 'motor_right'), ('obstacle_left', 'motor_left'), ('obstacle_right', 'motor_right'), ('obstacle_left', 'vision_1'), ('obstacle_left', 'vision_2'), ('obstacle_left', 'vision_3'), ('obstacle_right', 'vision_4'), ('obstacle_right', 'vision_5'), ('obstacle_right', 'vision_6')]) cpd_1 = double_hypo_cpd('motor_left', 'goal_left', 'obstacle_left') cpd_2 = double_hypo_cpd('motor_right', 'goal_right', 'obstacle_right') cpd_3 = wandering_hypo_cpd('goal_left') cpd_4 = wandering_hypo_cpd('goal_right') cpd_5 = obstacle_hypo_cpd('obstacle_left') cpd_6 = obstacle_hypo_cpd('obstacle_right') cpd_7 = single_hypo_cpd('vision_1', 'obstacle_left') cpd_8 = single_hypo_cpd('vision_2', 'obstacle_left') cpd_9 = single_hypo_cpd('vision_3', 'obstacle_left') cpd_10 = single_hypo_cpd('vision_4', 'obstacle_right') cpd_11 = single_hypo_cpd('vision_5', 'obstacle_right') cpd_12 = single_hypo_cpd('vision_6', 'obstacle_right') network.add_cpds(cpd_1, cpd_2, cpd_3, cpd_4, cpd_5, cpd_6, cpd_7, cpd_8, cpd_9, cpd_10, cpd_11, cpd_12) network.check_model() return { 'main': GenerativeModel(SensoryInputVirtualPeepo(self), network) }
def model_for_sorted(coin_set): network = BayesianModel([('previous', 'current')]) cpd_a = TabularCPD(variable='previous', variable_card=2, values=[[0.9, 0.1]]) cpd_b = TabularCPD(variable='current', variable_card=2, values=[[0.99, 0.01], [0.01, 0.99]], evidence=['previous'], evidence_card=[2]) network.add_cpds(cpd_a, cpd_b) network.check_model() model = GenerativeModel(SensoryInputCoin(coin_set), network) return model
def default_model(coin_set): network = BayesianModel([('hypo', 'coin')]) cpd_a = TabularCPD(variable='hypo', variable_card=2, values=[[0.5, 0.5]]) cpd_b = TabularCPD(variable='coin', variable_card=2, values=[[0.99, 0.01], [0.01, 0.99]], evidence=['hypo'], evidence_card=[2]) network.add_cpds(cpd_a, cpd_b) network.check_model() model = GenerativeModel(SensoryInputCoin(coin_set), network) return model
def create_network(): network = BayesianModel([('A', 'B')]) cpd_a = TabularCPD(variable='A', variable_card=2, values=[[0.2, 0.8]]) cpd_b = TabularCPD(variable='B', variable_card=2, values=[[0.1, 0.7], [0.9, 0.3]], evidence=['A'], evidence_card=[2]) network.add_cpds(cpd_a, cpd_b) network.check_model() return GenerativeModel(TestSensoryInput(), network)
def generic_model(coin_set): network = BayesianModel([('A', 'D'), ('B', 'D'), ('C', 'D')]) cpd_a = TabularCPD(variable='A', variable_card=2, values=[[0.9, 0.1]]) cpd_b = TabularCPD(variable='B', variable_card=2, values=[[0.1, 0.9]]) cpd_c = TabularCPD(variable='C', variable_card=2, values=[[0.1, 0.9]]) cpd_d = TabularCPD(variable='D', variable_card=2, values=[[0.1, 0.9, 0.1, 0.9, 0.1, 0.9, 0.9, 0.9], [0.9, 0.1, 0.9, 0.1, 0.9, 0.1, 0.1, 0.1]], evidence=['A', 'B', 'C'], evidence_card=[2, 2, 2]) network.add_cpds(cpd_a, cpd_b, cpd_c, cpd_d) network.check_model() model = GenerativeModel(SensoryInputCoin(coin_set), network) return model
def create_network_for_add_edge(): """ Note: adding an edge where the values are duplicated from the existing connecting nodes won't change predictions at all. Since it will just take on the value of the pre-existing state, given that we duplicate the values... Maybe go back to 0.5 0.5 defaults? """ network = BayesianModel([('A', 'B'), ('C', 'D')]) cpd_a = TabularCPD(variable='A', variable_card=2, values=[[0.4, 0.6]]) cpd_b = TabularCPD(variable='B', variable_card=2, values=[[0.1, 0.9], [0.9, 0.1]], evidence=['A'], evidence_card=[2]) cpd_c = TabularCPD(variable='C', variable_card=2, values=[[0.6, 0.4]]) cpd_d = TabularCPD(variable='D', variable_card=2, values=[[0.8, 0.9], [0.2, 0.1]], evidence=['C'], evidence_card=[2]) network.add_cpds(cpd_a, cpd_b, cpd_c, cpd_d) network.check_model() return GenerativeModel(TestSensoryInput(), network)
logging.basicConfig() logging.getLogger().setLevel(logging.DEBUG) logging.info('logging initialized') bot = PeepoBot() logging.info('bot initialized') network = BayesianModel([('hypo', 'infrared'), ('hypo', 'motor')]) cpd_a = TabularCPD(variable='hypo', variable_card=2, values=[[0.7, 0.3]]) cpd_b = TabularCPD(variable='infrared', variable_card=2, values=[[0.9, 0.1], [0.1, 0.9]], evidence=['hypo'], evidence_card=[2]) cpd_c = TabularCPD(variable='motor', variable_card=2, values=[[0.9, 0.1], [0.1, 0.9]], evidence=['hypo'], evidence_card=[2]) network.add_cpds(cpd_a, cpd_b, cpd_c) network.check_model() model = GenerativeModel(SensoryInput(bot), network) logging.info('starting predictive processing') while True: model.process()