コード例 #1
0
 def __init__(self):
     BaseAlgorithm.__init__(self)
     self.get_config()
     self.table_data = self.exec_sql(self.config['tableName'],
                                     self.config['X'], self.config['Y'])
     self.model = self.load_model_by_database(self.config['algorithm'],
                                              self.config['model'])
コード例 #2
0
 def __init__(self):
     BaseAlgorithm.__init__(self)
     self.get_config()
     if self.config["oneSample"]:
         self.table_data = None
     else:
         self.table_data = self.exec_sql(self.config['tableName'], self.config['X'], None)
     self.model = self.load_model_by_database(self.config['algorithm'], self.config['model'])
コード例 #3
0
 def __init__(self, method):
     BaseAlgorithm.__init__(self)
     self.one_type = "Classifier"
     self.one_type_name = "分类"
     self.second_type = "logisticRegression"
     self.second_type_name = "逻辑回归"
     # super(logisticAlgorithm, self).__init__()
     if method == "train":
         self.get_train_config_from_web()
     elif method == "evaluate":
         self.get_evaluate_config_from_web()
     else:
         self.get_predict_config_from_web()
     if method == 'predict' and self.config["oneSample"]:
         self.table_data = None
     else:
         self.table_data = self.exec_sql(self.config['tableName'],
                                         self.config['X'], self.config['Y'])
コード例 #4
0
 def __init__(self, method):
     BaseAlgorithm.__init__(self)
     self.one_type = "Cluster"
     self.one_type_name = "聚类"
     self.second_type = "hierarchicalCluster"
     self.second_type_name = "层次聚类"
     # super(logisticAlgorithm, self).__init__()
     if method == "train":
         self.get_train_config_from_web()
     elif method == "evaluate":
         self.get_evaluate_config_from_web()
     else:
         self.get_predict_config_from_web()
     if method == 'predict':
         if self.config["oneSample"]:
             self.table_data = None
         else:
             self.table_data = self.exec_sql(self.config['tableName'], self.config['X'])
     else:
         self.table_data = self.exec_sql(self.config['tableName'], self.config['X'])
コード例 #5
0
 def __init__(self, method):
     BaseAlgorithm.__init__(self)
     self.one_type = "Regression"
     self.one_type_name = "回归"
     self.second_type = "linerRegression"
     self.second_type_name = "线性回归"
     # super(logisticAlgorithm, self).__init__()
     if method == "train":
         self.get_train_config_from_web()
     elif method == "evaluate":
         self.get_evaluate_config_from_web()
     elif method == "predict":
         self.get_predict_config_from_web()
     elif method == "visualization":
         self.get_visualization_config_from_web()
     else:
         raise ValueError("input method:{} is not supported".format(method))
     if method == 'predict' and self.config["oneSample"]:
         self.table_data = None
     else:
         self.table_data = self.exec_sql(self.config['tableName'],
                                         self.config['X'], self.config['Y'])
コード例 #6
0
ファイル: experiment.py プロジェクト: emiliojorge/ATRLDM
from dynaq_agent import DynaQAgent
from q_agent import QAgent
from random_agent import RandomAgent

repetitions = 1

single_model = True
path_to_experiment_configs = "experiments/"
default_config = 'config.json'

#algorithm = BaseAlgorithm(exploration=True, explorer=EpsilonGreedy(start=1.0, end=0.05, steps=10000),
#                          use_database=False, action_selection = "moving average")

algorithm = BaseAlgorithm(exploration=True,
                          explorer=EpsilonGreedy(start=1.0,
                                                 end=0.05,
                                                 steps=10000),
                          use_database=False,
                          action_selection="majority vote")

explorer = EpsilonGreedy(start=1., end=0.05, steps=10000)

#algorithm = QAgent(exploration=True, explorer=explorer)
#algorithm = DynaQAgent(exploration=True, explorer=explorer)
# algorithm = Bayesian_Qlearning()
#algorithm = Speedy_Qlearning(exploration=True, explorer=explorer)
#algorithm = MeanAgent(exploration=True, explorer=explorer)
#algorithm = RandomAgent()


def generate_experiments():
    for lamda in np.linspace(0, 0.9, num=3, endpoint=True):
コード例 #7
0
    if compare_random == True:
        random_scores = simulation.simulate_multiple_environment(envs, random_algorithm, T=horizon,
                                                                 num_trials=num_trials,
                                                                 discount=1)
        mean_random = np.mean(random_scores, axis=1)
        std_random = np.std(random_scores, axis=1)
        for i, (score, rand_score, score_std, rand_std) in enumerate(
                zip(mean_scores, mean_random, std_scores, std_random)):
            print(f'Environment: "{env_names[i]}"')
            print(f'-- Mean reward: {score} -- Std: {score_std}')
            print(f'-- Random reward: {rand_score} -- Std: {rand_std}')

    else:
        for i, (score, score_std) in enumerate(zip(mean_scores, std_scores)):
            print(f'Environment: "{env_names[i]}"')
            print(f'-- Mean reward: {score} -- Var: {score_std}')

    if save_results:
        with open('results.csv', 'w') as file:
            file.write('environment, runs, trials, mean_score, std_deviation\n')
            for env, mean, sigma in zip(env_names, mean_scores, std_scores):
                file.write('{}, {}, {}, {}, {}\n'.format(env, horizon, num_trials, mean, sigma))

    return env_names, scores

if __name__ == '__main__':
    algorithm = BaseAlgorithm(exploration=True, explorer=EpsilonGreedy(start=0.5, end=0.05, steps=1000),
                              use_database=True, action_selection = "epsilon greedy")

    main(algorithm)