Exemple #1
0
        actionset = args.actionset
    else:
        actionset = "basis_vector"  # "basis_vector" or "random"

    testing_iterations = 500
    NoiseScale = 0.1  # standard deviation of Gaussian noise
    n_articles = 25
    n_users = 10
    poolArticleSize = None

    if actionset == "basis_vector":
        n_articles = context_dimension  # there can be at most context_dimension number of basis vectors

    ## Set Up Simulation ##
    UM = UserManager(context_dimension,
                     n_users,
                     thetaFunc=gaussianFeature,
                     argv={'l2_limit': 1})
    users = UM.simulateThetafromUsers()
    AM = ArticleManager(context_dimension,
                        n_articles=n_articles,
                        argv={'l2_limit': 1})
    articles = AM.simulateArticlePool(actionset)

    simExperiment = simulateOnlineData(
        context_dimension=context_dimension,
        testing_iterations=testing_iterations,
        plot=True,
        articles=articles,
        users=users,
        noise=lambda: np.random.normal(scale=NoiseScale),
        signature=AM.signature,
Exemple #2
0
	# Matrix parameters
	matrixNoise = 0.01
	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,
Exemple #3
0
    config["delta_1"] = 1e-1
    config["delta_2"] = 1e-1
    config["tilde_delta_1"] = config[
        "delta_1"]  #/ 5.0  # tilde_delta_1 should be a number between 0 and self.delta_1
    config["dLinUCB_alpha"] = 0.6
    #CoDBand
    config["memory_size"] = 70

    # Generate user and item vectors
    userFilename = os.path.join(
        sim_files_folder, "users_" + str(config["n_users"]) + "context_" +
        str(config["context_dimension"]) + "Ugroups" +
        str(config["UserGroups"]) + ".json")
    UM = UserManager(config["context_dimension"],
                     config["n_users"],
                     config["gamma"],
                     UserGroups=config["UserGroups"],
                     thetaFunc=gaussianFeature,
                     argv={'l2_limit': 1})
    users, global_parameter_set, parameter_index_for_users = UM.simulateThetafromUsers(
    )

    articlesFilename = os.path.join(
        sim_files_folder, "articles_" + str(config["n_articles"]) +
        "context_" + str(config["context_dimension"]) + "Agroups" +
        str(config["ArticleGroups"]) + ".json")
    AM = ArticleManager(config["context_dimension"],
                        n_articles=config["n_articles"],
                        ArticleGroups=config["ArticleGroups"],
                        FeatureFunc=gaussianFeature,
                        argv={'l2_limit': 1})
    articles = AM.simulateArticlePool()
Exemple #4
0
    # Generate simulated users dataset
    #-----------------------------------------------------------------------------------------------------------------------
    # Filename to save to if first run or read from.
    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 function
    # 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,  # 10
        UserGroups=UserGroups,  # 5 =>  10/5 = 2 => 2 users per group
        thetaFunc=
        featureUniform,  # initialization function for your parameters is uniform
        argv={'l2_limit': 1})
    # Get the users from simulation with the mask and user groups
    users = UM.simulateThetafromUsers()

    # Save the simulated users onto the file
    UM.saveUsers(users, userFilename,
                 force=True)  # Force overwrite the simulated users.
    #UM.saveUsers(users, userFilename, force = False) # Don't overwrite if the file already exist

    # Load from the saved file
    users = UM.loadUsers(userFilename)
    articlesFilename = os.path.join(
        sim_files_folder, "articles_" + str(n_articles) + "context_" +
Exemple #5
0
 def __init__(self, dimension, user_dict, argv=None):
     UserManager.__init__(self, dimension, user_dict, argv=None)
     self.matrixNoise = argv['matrixNoise']
     self.sparseLevel = argv['sparseLevel']
     self.W, self.W0 = self.constructAdjMatrix(self.sparseLevel)