sparseLevel = 10 # if smaller or equal to 0 or larger or enqual to usernum, matrix is fully connected # Parameters for GOBLin G_alpha = alpha G_lambda_ = lambda_ Gepsilon = 1 userFilename = os.path.join(sim_files_folder, "users_"+str(n_users)+"context_"+str(context_dimension)+"latent_"+str(latent_dimension)+ "Ugroups" + str(UserGroups)+".json") #"Run if there is no such file with these settings; if file already exist then comment out the below funciton" # we can choose to simulate users every time we run the program or simulate users once, save it to 'sim_files_folder', and keep using it. UM = UserManager(context_dimension+latent_dimension, n_users, UserGroups = UserGroups, thetaFunc=featureUniform, argv={'l2_limit':1}) # users = UM.simulateThetafromUsers() # UM.saveUsers(users, userFilename, force = False) users = UM.loadUsers(userFilename) articlesFilename = os.path.join(sim_files_folder, "articles_"+str(n_articles)+"context_"+str(context_dimension)+"latent_"+str(latent_dimension)+ "Agroups" + str(ArticleGroups)+".json") # Similarly, we can choose to simulate articles every time we run the program or simulate articles once, save it to 'sim_files_folder', and keep using it. AM = ArticleManager(context_dimension+latent_dimension, n_articles=n_articles, ArticleGroups = ArticleGroups, FeatureFunc=featureUniform, argv={'l2_limit':1}) # articles = AM.simulateArticlePool() # AM.saveArticles(articles, articlesFilename, force=False) articles = AM.loadArticles(articlesFilename) for i in range(len(articles)): articles[i].contextFeatureVector = articles[i].featureVector[:context_dimension] simExperiment = simulateOnlineData(context_dimension = context_dimension, latent_dimension = latent_dimension, training_iterations = training_iterations, testing_iterations = testing_iterations,
str(context_dimension) + "latent_" + str(latent_dimension) + "Ugroups" + str(UserGroups) + ".json") #"Run if there is no such file with these settings; if file already exist then comment out the below funciton" # we can choose to simulate users every time we run the program or simulate users once, save it to 'sim_files_folder', and keep using it. UM = UserManager(context_dimension + latent_dimension, n_users, UserGroups=UserGroups, thetaFunc=featureUniform, argv={'l2_limit': 1}) # users = UM.simulateThetafromUsers() # UM.saveUsers(users, userFilename, force = False) # Here, the [0.15, 0.9] means that the user has a 0.15 chance of clicking on an article given that it is irrelevant, # and 0.9 chance of clicking on an article given that it is relevant users = UM.loadUsers(userFilename, [0.15, 0.9]) articlesFilename = os.path.join( sim_files_folder, "articles_" + str(n_articles) + "context_" + str(context_dimension) + "latent_" + str(latent_dimension) + "Agroups" + str(ArticleGroups) + ".json") # Similarly, we can choose to simulate articles every time we run the program or simulate articles once, save it to 'sim_files_folder', and keep using it. AM = ArticleManager(context_dimension + latent_dimension, n_articles=n_articles, ArticleGroups=ArticleGroups, FeatureFunc=featureUniform, argv={'l2_limit': 1}) #articles = AM.simulateArticlePool() #AM.saveArticles(articles, articlesFilename, force=False) articles = AM.loadArticles(articlesFilename)