Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
ffm-baseline
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ML
ffm-baseline
Commits
6ff78a67
Commit
6ff78a67
authored
Aug 22, 2018
by
张彦钊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add prints for test
parent
524b17b0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
diaryQueueUpdate.py
diaryQueueUpdate.py
+9
-3
No files found.
diaryQueueUpdate.py
View file @
6ff78a67
...
...
@@ -91,9 +91,7 @@ def feature_en(x_list, device_id):
def
transform_ffm_format
(
df
,
queue_name
):
with
open
(
DIRECTORY_PATH
+
"ffm.pkl"
,
"rb"
)
as
f
:
ffm_format_pandas
=
pickle
.
load
(
f
)
print
(
"1"
)
data
=
ffm_format_pandas
.
transform
(
df
)
predict_file_name
=
DIRECTORY_PATH
+
"result/{0}_{1}.csv"
.
format
(
device_id
,
queue_name
)
data
.
to_csv
(
predict_file_name
,
index
=
False
,
header
=
None
)
print
(
"done ffm"
)
...
...
@@ -111,8 +109,9 @@ def predict(queue_name, x_list):
ffm_model
.
predict
(
DIRECTORY_PATH
+
"model.out"
,
DIRECTORY_PATH
+
"result/output{0}_{1}.csv"
.
format
(
device_id
,
queue_name
))
save_result
(
queue_name
,
x_list
)
print
(
"done predict"
)
save_result
(
queue_name
,
x_list
)
def
save_result
(
queue_name
,
x_list
):
...
...
@@ -126,6 +125,7 @@ def save_result(queue_name, x_list):
def
merge_score
(
x_list
,
score_df
):
db
=
pymysql
.
connect
(
host
=
'10.66.157.22'
,
port
=
4000
,
user
=
'root'
,
passwd
=
'3SYz54LS9#^9sBvC'
,
db
=
'eagle'
)
cursor
=
db
.
cursor
()
print
(
"连接蔡成功"
)
score_list
=
[]
# 去除diary_id 前面的"diary|"
x_list
=
list
(
map
(
lambda
x
:
x
[
6
:],
x_list
))
...
...
@@ -136,13 +136,16 @@ def merge_score(x_list, score_df):
if
cursor
.
execute
(
sql
)
!=
0
:
result
=
cursor
.
fetchone
()[
0
]
score_list
.
append
(
result
)
print
(
"成功获取"
)
# 没有查到这个diary_id,默认score值是0
else
:
print
(
"结果是空"
)
score_list
.
append
(
0
)
db
.
close
()
score_df
[
"score"
]
=
score_df
[
"score"
]
+
score_list
print
(
"done merge"
)
update_dairy_queue
(
score_df
)
...
...
@@ -170,17 +173,20 @@ def update_dairy_queue(score_df):
else
:
score_df
=
score_df
.
sort_values
(
by
=
"score"
,
ascending
=
False
)
return
score_df
[
"cid"
]
.
values
.
tolist
()
print
(
"排序成功"
)
def
update_sql_dairy_queue
(
queue_name
,
diary_id
):
db
=
pymysql
.
connect
(
host
=
'rm-m5e842126ng59jrv6.mysql.rds.aliyuncs.com'
,
port
=
3306
,
user
=
'doris'
,
passwd
=
'o5gbA27hXHHm'
,
db
=
'doris_prod'
)
cursor
=
db
.
cursor
()
print
(
"写入连接成功"
)
## 去除diary_id 前面的"diary|"
diary_id
=
list
(
map
(
lambda
x
:
x
[
6
:],
diary_id
))
sql
=
"update device_diary_queue set {}='{}' where device_id = '{}'"
.
format
(
queue_name
,
diary_id
,
device_id
)
cursor
.
execute
(
sql
)
db
.
close
()
print
(
"成功写入"
)
def
multi_update
(
key
,
name_dict
):
...
...
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