in isoexp/contextual/contextual_models.py [0:0]
def __init__(self, arm_csvfile, user_csvfile, random_state=0, noise=0., arms_limit=None, context_limit=None):
temp_thetas = np.loadtxt(arm_csvfile, delimiter=',').T
temp_user_contexts = np.loadtxt(user_csvfile, delimiter=',')
K, d = temp_thetas.shape
N, _ = temp_user_contexts.shape
thetas = np.ones((K, d+1))
user_contexts = np.ones((N, d+1))
thetas[:, :-1] = temp_thetas.copy()
if arms_limit is not None:
thetas = thetas[:arms_limit]
user_contexts[:, :-1] = temp_user_contexts.copy()
if context_limit is not None:
user_contexts = user_contexts[:context_limit]
self.bound_context = np.linalg.norm(user_contexts, axis=1).max()
D = np.dot(temp_user_contexts, temp_thetas.T)
min_rwd = np.min(D)
max_rwd = np.max(D)
thetas[:, -1] = -min_rwd + 1
thetas = thetas / (max_rwd - min_rwd + 1)
self.context_lists = user_contexts.copy()
self.n_user, _ = user_contexts.shape
super(DatasetModel, self).__init__(random_state=random_state, noise=noise,
thetas=thetas)
self.theta = self.thetas