in isoexp/linear/linearmab_models.py [0:0]
def __init__(self, random_state=0, noise=0., n_actions=4, n_features=4, bound_features=1, bound_theta = 1, positive=True, max_one=True):
features = np.random.randn(n_actions, n_features)
real_theta = np.random.randn(n_features)
real_theta = np.random.uniform(low = 1/2, high = bound_theta)*real_theta/np.linalg.norm(real_theta)
if positive:
idxs = np.dot(features, real_theta) <= 0
idxs = np.arange(n_actions)[idxs]
for i in idxs:
mean = -1
feat = None
while mean <= 0:
feat = np.random.randn(1, n_features)
mean = np.dot(feat, real_theta)
features[i, :] = feat
features = np.random.uniform(low = 1/2, high = bound_features, size = (n_actions,1)) * features / max(np.linalg.norm(features, axis=1))
if max_one:
D = np.dot(features, real_theta)
min_rwd = min(D)
max_rwd = max(D)
min_features = features[np.argmin(D)]
features = (features - min_features) / (max_rwd - min_rwd)
super(RandomLinearArms, self).__init__(random_state=random_state, noise=noise,
features=features, theta=real_theta)