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
7acd559c
Commit
7acd559c
authored
Aug 23, 2018
by
张彦钊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change sql for test
parent
694e9f01
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
diaryQueueUpdate.py
diaryQueueUpdate.py
+7
-4
No files found.
diaryQueueUpdate.py
View file @
7acd559c
...
...
@@ -205,7 +205,8 @@ def update_dairy_queue(score_df):
return
diary_id
else
:
score_df
=
score_df
.
sort_values
(
by
=
"score"
,
ascending
=
False
)
print
(
"排序后"
)
print
(
score_df
[
"cid"
]
.
values
.
tolist
())
return
score_df
[
"cid"
]
.
values
.
tolist
()
...
...
@@ -216,7 +217,8 @@ def update_sql_dairy_queue(queue_name, diary_id):
cursor
=
db
.
cursor
()
## 去除diary_id 前面的"diary|"
diary_id
=
json
.
dumps
(
list
(
map
(
lambda
x
:
x
[
6
:],
diary_id
)))
print
(
"写入前"
)
print
(
diary_id
)
sql
=
"update device_diary_queue set {}='{}' where device_id = '{}'"
.
format
(
queue_name
,
diary_id
,
device_id
)
cursor
.
execute
(
sql
)
db
.
close
()
...
...
@@ -240,7 +242,7 @@ def user_update(device_id):
if
not_empty
:
name_dict
=
{
"native_queue"
:
native_queue_list
,
"nearby_queue"
:
nearby_queue_list
,
"nation_queue"
:
nation_queue_list
,
"megacity_queue"
:
megacity_queue_list
}
pool
=
Pool
(
4
)
pool
=
Pool
(
1
)
for
key
in
name_dict
.
keys
():
pool
.
apply_async
(
multi_update
,
(
key
,
name_dict
,
native_queue_list
,))
pool
.
close
()
...
...
@@ -258,7 +260,7 @@ if __name__ == "__main__":
old_device_id_list
=
pd
.
read_csv
(
DIRECTORY_PATH
+
"data_set_device_id.csv"
)[
"device_id"
]
.
values
.
tolist
()
# 求活跃用户和老用户的交集,也就是只预测老用户
predict_list
=
list
(
set
(
device_id_list
)
&
set
(
old_device_id_list
))
predict_list
.
extend
([
"
B2F0665E-4375-4169-8FE3-8A26A1CFE248"
,
"AB20292B-5D15-4C44-9429-1C2FF5ED26F6"
,
"
358035085192742"
])
predict_list
.
extend
([
"358035085192742"
])
# 只预测尾号是6的ID,这块也可以在数据库取数据时过滤一下
# predict_list = list(filter(lambda x:str(x)[-1] == "6", predict_list))
...
...
@@ -269,6 +271,7 @@ if __name__ == "__main__":
if
predict_list
!=
[]:
for
device_id
in
predict_list
:
user_update
(
device_id
)
else
:
print
(
"该列表是新用户,不需要预测"
)
end
=
time
.
time
()
...
...
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