from mab import arm from mab import scorer as sc import time import pickle is_post_per_subject = False is_update_db = True param = common_params.CommonParams() bot = slack_news_bot.SlackNewsBot(param, is_update_db) df = bot.df num_arms = param.num_news path = 'log/mab.log' if util_funcs.check_file(path) is False: algorithm = bd.EpsilonGreedyAlgorithm(num_arms, 0.1) trials = 0 with open(path, 'wb') as f: pickle.dump(algorithm, f) pickle.dump(trials, f) print("MAB started") else: with open(path, 'rb') as f: algorithm = pickle.load(f) trials = pickle.load(f) print("MAB object loaded") print(trials) selected_arm = algorithm.select_arm() if is_update_db:
from mab import ArticleArms from mab import scorer as sc import numpy as np import time num_trials = 2000 print('total number of trials: {}'.format(num_trials)) arms = ArticleArms('yahoo_r6_full.db') num_arms = arms.get_num_arms() print('number of arms: {}'.format(num_arms)) param_c = 10000000 # very large c: not assuming mortality # param_c = None algorithms = [ bd.EpsilonGreedyAlgorithm(num_arms, 0.1, c=param_c), bd.UCB1Algorithm(num_arms, c=param_c) ] num_algorithms = len(algorithms) print('number of algorithms: {}'.format(num_algorithms)) total_cumulative_rewards = np.zeros(num_algorithms) total_cumulative_logging_rewards = np.zeros(num_algorithms) total_cumulative_diff_rewards = np.zeros(num_algorithms) trials = np.zeros(num_algorithms) num_arms_added = 0 removing_arms_indices = [] print_point_divisor = np.power(10, np.ceil(np.log10(num_trials)) - 2) print_num_trials_divisor = print_point_divisor * 10