-
Notifications
You must be signed in to change notification settings - Fork 1
/
training_1-predictor-rpm.py
104 lines (76 loc) · 2.15 KB
/
training_1-predictor-rpm.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# Train a TPOT model
import pandas as pd
import sklearn
import time
import numpy as np
from tpot import TPOTRegressor
from sklearn.model_selection import train_test_split
from sklearn.externals import joblib
#%%
t1 = time.time()
print('Loading database ...')
df = pd.read_hdf('database/all_data_comp.h5','table')
print('Time to load database:', time.time()-t1)
#%%
# Variable names.
import var_names
d = var_names.d
# Check if variables exist in the dictonary..
# for names in d:
# if d[names] in list(df):
# pass
# else:
# print('*** VAR MISSING *** ', d[names], ' *** VAR MISSING ***')
#%%
gen = 50
cores=-1 # -1 = use all of them, can be
import train_model as tm
#
# def train_tpot(name,X,y,gen,cores):
#
#%%
####
#### Training the first set with only rpm predictor
####
##
# Features and target for Eng 1/3
test_name = str('gen_' + str(gen) + 'eng_13_rpm_predictor_'+time.strftime('%y%m%d'))
features = [d['ae1_rpm'],
d['ae3_rpm'],
d['me1_rpm'],
d['me3_rpm'],
d['fo_booster_13']
]
print('Features and predictions for training...:\n')
for n in features:
print('- ',d[n])
print('\nDate: ',time.strftime('%y%m%d'))
print('Time: ',time.strftime('%H:%M:%S'))
# Drop Nan from the DataFrame.
# Create training arrays, X_13 is the features for engine pair 1 and 3
df_train = df[features].dropna()
X = np.array(df_train.drop(labels=d['fo_booster_13'],axis=1))
y = np.array(df_train[d['fo_booster_13']])
tm.train_tpot(test_name,X,y,gen,cores)
##
##
##%%
## Training next engine pair.
##
# X_24 features for engine 2, 4
test_name = str('gen_' + str(gen) + 'eng_24_rpm_predictor_'+time.strftime('%y%m%d'))
features = [d['ae2_rpm'],
d['ae4_rpm'],
d['me2_rpm'],
d['me4_rpm'],
d['fo_booster_24']
]
print('Features and predictions for training...:\n')
for n in features:
print('- ',d[n])
print('\nDate: ',time.strftime('%y%m%d'))
print('Time: ',time.strftime('%H:%M:%S'))
df_train = df[features].dropna()
X = np.array(df_train.drop(labels=d['fo_booster_24'],axis=1))
y = np.array(df_train[d['fo_booster_24']])
tm.train_tpot(test_name,X,y,gen,cores)