-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrun_GeneticAlgorithm.py
58 lines (50 loc) · 1.37 KB
/
run_GeneticAlgorithm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from GeneticAlgorithm import *
from config import *
from run_HAR_model import load_data
# load data
df = load_data()
_lstm_instance = TimeSeriesDataPreparationLSTM(
df=df.copy(),
future=20,
lag=40,
standard_scaler=False,
min_max_scaler=True,
log_transform=True,
semi_variance=True,
jump_detect=True,
period_train=list(
[
pd.to_datetime("20030910", format="%Y%m%d"),
pd.to_datetime("20091231", format="%Y%m%d"),
]
),
period_test=list(
[
pd.to_datetime("20100101", format="%Y%m%d"),
pd.to_datetime("20101231", format="%Y%m%d"),
]
),
)
_lstm_instance.prepare_complete_data_set()
_ga_1 = GeneticAlgorithm(
training_set_ga=_lstm_instance.training_set,
testing_set_ga=_lstm_instance.testing_set,
network_architecture=OrderedDict(
[
("Layer1", [2, 43, 5]),
("Layer2", [1, 42, 4]),
("Layer3", [0, 21, 3]),
("Layer4", [0, 21, 4]),
]
),
learning_rate=[0.001, 0.062, 0.02],
initial_population_source_external=True,
build_grid_scenarios=False,
)
_ga_1.run_complete_genetic_algorithm(number_of_generations=20)
result = _ga_1.initial_population
result.to_csv(
folder_structure.output_GridSearch
+ "/"
+ "GeneticAlgorithm_{}_hist40_True_new_modelafterGA2.csv".format(20)
)