Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
eue
Commits
41d5b0e1
Commit
41d5b0e1
authored
Aug 09, 2021
by
KangMin An
Browse files
Merge branch 'yeni' into premaster
parents
060d5f35
96cf192f
Changes
2
Show whitespace changes
Inline
Side-by-side
server/src/data_processing/model.py
View file @
41d5b0e1
...
...
@@ -36,7 +36,7 @@ def modeling(standard_df):
model
=
tf
.
keras
.
Sequential
([
tf
.
keras
.
layers
.
LSTM
(
16
,
return_sequences
=
False
,
input_shape
=
(
6
,
7
)),
input_shape
=
(
6
,
8
)),
tf
.
keras
.
layers
.
Dense
(
1
)
])
...
...
@@ -44,7 +44,3 @@ def modeling(standard_df):
# model.fit(train_feature, train_label, epochs=50, batch_size=1000)
model
.
save
(
os
.
getcwd
()
+
'/src/data_processing/model.h5'
)
# 사용할때
# new = tf.keras.models.load_model('/src/dataprocessing/model.h5')
server/src/data_processing/prediction.py
View file @
41d5b0e1
...
...
@@ -5,6 +5,10 @@ import json
import
os
import
psycopg2
import
sys
import
pandas
as
pd
import
tensorflow
as
tf
import
numpy
as
np
if
__name__
==
"__main__"
:
...
...
@@ -66,7 +70,30 @@ if __name__ == "__main__":
data_file
.
close
()
cursor
.
close
()
prediction
=
"Result_of_Prediction_Process"
data_list
=
pd
.
read_csv
(
data_dir
)
new_data
=
data_list
[
-
6
:]
date_time
=
pd
.
to_datetime
(
new_data
[
'date'
],
format
=
'%Y-%m-%d %H:%M'
)
timestamp_s
=
date_time
.
map
(
datetime
.
datetime
.
timestamp
)
new_data
=
new_data
[[
'temp_out'
,
'humi_out'
,
'press'
,
'wind_speed'
]]
day
=
24
*
60
*
60
year
=
(
365.2425
)
*
day
new_data
[
'Day sin'
]
=
np
.
sin
(
timestamp_s
*
(
2
*
np
.
pi
/
day
))
new_data
[
'Day cos'
]
=
np
.
cos
(
timestamp_s
*
(
2
*
np
.
pi
/
day
))
new_data
[
'Year sin'
]
=
np
.
sin
(
timestamp_s
*
(
2
*
np
.
pi
/
year
))
new_data
[
'Year cos'
]
=
np
.
cos
(
timestamp_s
*
(
2
*
np
.
pi
/
year
))
feature_cols
=
[
'temp_out'
,
'humi_out'
,
'press'
,
'wind_speed'
,
'Day sin'
,
'Day cos'
,
'Year sin'
,
'Year cos'
]
for
col
in
feature_cols
:
new_data
[
col
]
=
(
new_data
[
col
]
-
mean
[
col
])
/
std
[
col
]
model_pro
=
tf
.
keras
.
models
.
load_model
(
model_dir
)
prediction
=
model_pro
.
predict
(
new_data
)
prediction
=
prediction
*
std
[
'temp_out'
]
+
mean
[
'temp_out'
]
# 사용한 파일 삭제
if
os
.
path
.
isfile
(
data_dir
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment