},
        outfile,
        sort_keys=True,
        indent=4,
        ensure_ascii=False)

np.savetxt('mix_scaled_pWorse_init.txt',
           X[:2])  # first two plays for later init.

bounds = np.array(31 * [[-1., 1.]])

soln = CovarianceEstimate(X, y, bounds=bounds, alpha=10.)
# sig_test = np.zeros(31)
# sig_test[-1] = 2.6
# soln.model.f_path(sig_test)
[obj_set, sigma_set] = soln.solve(plot=True)

# # pick the best solution
obj = obj_set.min(axis=0)
sigma = sigma_set[obj_set.argmin(axis=0), :]
print obj, sigma

# # load bounds
# from numpy import loadtxt
# bounds = loadtxt("ego_bounds.txt", comments="#", delimiter=",", unpack=False)
#
# # store sigma for simulation
# # TODO: need to specify file name based on settings, e.g., optimization algorithm and input data source (best player?)

file_address = 'pWorse_bfgs_sigma_alpha' + str(soln.alpha) + '.json'
with open(file_address, 'wb') as f:
Beispiel #2
0


sample_size = 100
num_ini_guess = 2
alpha = 10.0
soln = CovarianceEstimate(X, y, bounds=bounds, xbounds=xbounds, alpha=alpha, sample_size=sample_size,
                          num_ini_guess=num_ini_guess, initial_guess=initial_guess, l_INI=l_INI_10[:(n_trajectory-2)])
# x_temp =np.random.normal(initial_guess, scale=0.1, size=(1,31))
# # x_temp = np.ones((31,))*10.0
f0 = soln.model.obj(initial_guess, alpha=alpha, l_INI=l_INI_10[:(n_trajectory-2)])
print f0
# sig_test = np.zeros(31)
# sig_test[-1] = 2.6
# soln.model.f_path(sig_test)
[obj_set, sigma_set] = soln.solve(plot=False)

# # pick the best solution
obj = obj_set.min(axis=0)
sigma = sigma_set[obj_set.argmin(axis=0), :]
print obj, sigma

# # load bounds
# from numpy import loadtxt
# bounds = loadtxt("ego_bounds.txt", comments="#", delimiter=",", unpack=False)
#
# # store sigma for simulation
# # TODO: need to specify file name based on settings, e.g., optimization algorithm and input data source (best player?)

file_address = 'p3_bfgs_sigma_alpha'+str(soln.alpha)+'_0220_sample100_aroundx1_first71.json'
# x0: thurston optimal for 31 plays


sample_size = 100
num_ini_guess = 2
alpha = 10.0
soln = CovarianceEstimate(X, y, bounds=bounds, xbounds=xbounds, alpha=alpha, sample_size=sample_size,
                          num_ini_guess=num_ini_guess, initial_guess=initial_guess, l_INI=l_INI_10[:(n_trajectory-2)])
# x_temp =np.random.normal(initial_guess, scale=0.1, size=(1,31))
# # x_temp = np.ones((31,))*10.0
f0 = soln.model.obj(initial_guess, alpha=alpha, l_INI=l_INI_10[:(n_trajectory-2)])
print f0
# sig_test = np.zeros(31)
# sig_test[-1] = 2.6
# soln.model.f_path(sig_test)
[obj_set, sigma_set] = soln.solve(plot=False)

# # pick the best solution
obj = obj_set.min(axis=0)
sigma = sigma_set[obj_set.argmin(axis=0), :]
print obj, sigma

# # load bounds
# from numpy import loadtxt
# bounds = loadtxt("ego_bounds.txt", comments="#", delimiter=",", unpack=False)
#
# # store sigma for simulation
# # TODO: need to specify file name based on settings, e.g., optimization algorithm and input data source (best player?)

file_address = 'p2_bfgs_sigma_alpha'+str(soln.alpha)+'_0813_sample100_aroundx1_first12.json'
# x0: thurston optimal for 31 plays
Beispiel #4
0
pre = Preprocess(pca_model='../eco_full_pca.pkl', all_dat='../all_games.pkl')
# pre = Preprocess()
# pre.get_json('alluser_control.json')  # uncomment this to create the pkl file needed!!
# pre.train_pca()
X, y = pre.ready_player_one(3)

from sklearn.preprocessing import StandardScaler, MinMaxScaler

# scale = StandardScaler()
scale = MinMaxScaler((-1., 1.))
X = scale.fit_transform(X)
#
bounds = np.array(30 * [[-1., 1.]])
# # get sigma estimate that maximizes the sum of expected improvements
soln = CovarianceEstimate(X, y, bounds=bounds)
[obj_set, sigma_set] = soln.solve()

# # pick the best solution
obj = obj_set.min(axis=0)
sigma = sigma_set[obj_set.argmin(axis=0), :]
print obj, sigma

# # load bounds
# from numpy import loadtxt
# bounds = loadtxt("ego_bounds.txt", comments="#", delimiter=",", unpack=False)
#
# # store sigma for simulation
# # TODO: need to specify file name based on settings, e.g., optimization algorithm and input data source (best player?)

file_address = 'p3_slsqp_sigma_oldICA.json'
with open(file_address, 'w') as f:
with open('pWorse_range_transform.json', 'wb') as outfile:
    json.dump({'range':scale.scale_.tolist(), 'min':scale.min_.tolist()},
              outfile, sort_keys=True, indent=4, ensure_ascii=False)
with open('pWorse_ICA_transform.json', 'wb') as outfile:
    json.dump({'mix':pre.pca.mixing_.tolist(), 'unmix':pre.pca.components_.tolist(), 'mean':pre.pca.mean_.tolist()},
              outfile, sort_keys=True, indent=4, ensure_ascii=False)

np.savetxt('mix_scaled_pWorse_init.txt', X[:2])  # first two plays for later init.

bounds = np.array(31*[[-1., 1.]])

soln = CovarianceEstimate(X, y, bounds=bounds, alpha=10.)
# sig_test = np.zeros(31)
# sig_test[-1] = 2.6
# soln.model.f_path(sig_test)
[obj_set, sigma_set] = soln.solve(plot=True)

# # pick the best solution
obj = obj_set.min(axis=0)
sigma = sigma_set[obj_set.argmin(axis=0), :]
print obj, sigma

# # load bounds
# from numpy import loadtxt
# bounds = loadtxt("ego_bounds.txt", comments="#", delimiter=",", unpack=False)
#
# # store sigma for simulation
# # TODO: need to specify file name based on settings, e.g., optimization algorithm and input data source (best player?)

file_address = 'pWorse_bfgs_sigma_alpha'+str(soln.alpha)+'.json'
with open(file_address, 'wb') as f:
pre = Preprocess(pca_model='../eco_full_pca.pkl', all_dat='../all_games.pkl')
# pre = Preprocess()
# pre.get_json('alluser_control.json')  # uncomment this to create the pkl file needed!!
# pre.train_pca()
X, y = pre.ready_player_one(2)

from sklearn.preprocessing import StandardScaler, MinMaxScaler

# scale = StandardScaler()
scale = MinMaxScaler((-1., 1.))
X = scale.fit_transform(X)
#
bounds = np.array(30*[[-1., 1.]])
# # get sigma estimate that maximizes the sum of expected improvements
soln = CovarianceEstimate(X, y, bounds=bounds)
[obj_set, sigma_set] = soln.solve()

# # pick the best solution
obj = obj_set.min(axis=0)
sigma = sigma_set[obj_set.argmin(axis=0), :]
print obj, sigma

# # load bounds
# from numpy import loadtxt
# bounds = loadtxt("ego_bounds.txt", comments="#", delimiter=",", unpack=False)
#
# # store sigma for simulation
# # TODO: need to specify file name based on settings, e.g., optimization algorithm and input data source (best player?)

file_address = 'p3_slsqp_sigma_oldICA.json'
with open(file_address, 'w') as f: