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
71e5100b
Commit
71e5100b
authored
Aug 27, 2018
by
张彦钊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update diaryqueue file
parent
d1ddcfe6
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
22 deletions
+23
-22
diaryQueueUpdate.py
diaryQueueUpdate.py
+10
-12
userProfile.py
userProfile.py
+13
-10
No files found.
diaryQueueUpdate.py
View file @
71e5100b
...
...
@@ -137,8 +137,7 @@ def update_dairy_queue(score_df,predict_score_df,total_video_id):
i
=
1
for
j
in
video_id
:
new_queue
.
insert
(
i
,
j
)
# TODO 下面的3是测试用的,如果上线后,把3改成5
i
+=
3
i
+=
5
print
(
"分数合并成功"
)
return
new_queue
...
...
@@ -253,24 +252,23 @@ def multi_proecess_update(device_id, city_id, data_set_cid,total_video_id):
pool
.
join
()
def
run
():
if
__name__
==
"__main__"
:
warnings
.
filterwarnings
(
"ignore"
)
total_number
=
0
while
True
:
data_set_cid
=
pd
.
read_csv
(
DIRECTORY_PATH
+
"data_set_cid.csv"
)[
"cid"
]
.
values
.
tolist
()
total_video_id
=
get_video_id
()
device_city_list
=
get_active_users
()
total_number
+=
len
(
device_city_list
)
if
device_city_list
!=
[]:
for
device_city
in
device_city_list
:
start
=
time
.
time
()
multi_proecess_update
(
device_city
[
0
],
device_city
[
1
],
data_set_cid
,
total_video_id
)
multi_proecess_update
(
device_city
[
0
],
device_city
[
1
],
data_set_cid
,
total_video_id
)
end
=
time
.
time
()
print
(
"更新该用户队列耗时{}秒"
.
format
((
end
-
start
)))
print
(
"end"
)
print
(
"更新该用户队列耗时{}秒"
.
format
((
end
-
start
)))
print
(
"累计预测用户总数:{}"
.
format
(
total_number
)
)
if
__name__
==
"__main__"
:
warnings
.
filterwarnings
(
"ignore"
)
# todo 正式上线后把下面while True的代码加上
# while True:
run
()
# # TODO 上线后把预测用户改成多进程预测
...
...
userProfile.py
View file @
71e5100b
...
...
@@ -14,15 +14,13 @@ def get_active_users():
sql
=
"select device_id,city_id from user_active_time "
\
"where active_time <= '{}' and active_time >= '{}'"
.
format
(
now_end
,
now_start
)
df
=
con_sql
(
sql
)
return
((
"AB20292B-5D15-4C44-9429-1C2FF5ED26F6"
,
"beijing"
),)
if
df
.
empty
:
print
(
"当下这一分钟没有活跃用户,不需要预测"
)
for
eachFile
in
os
.
listdir
(
"/tmp"
):
if
"xlearn"
in
eachFile
:
os
.
remove
(
"/tmp"
+
"/"
+
eachFile
)
time
.
sleep
(
58
)
return
False
time
.
sleep
(
56
)
return
[]
else
:
df
=
df
.
rename
(
columns
=
{
0
:
"device_id"
,
1
:
"city_id"
})
old_device_id_list
=
pd
.
read_csv
(
DIRECTORY_PATH
+
"data_set_device_id.csv"
)[
"device_id"
]
.
values
.
tolist
()
...
...
@@ -30,18 +28,23 @@ def get_active_users():
df
=
df
.
loc
[
df
[
"device_id"
]
.
isin
(
old_device_id_list
)]
if
df
.
empty
:
print
(
"该列表是新用户,不需要预测"
)
return
[]
else
:
# TODO 正式上线后注释下面的只预测尾号是6的代码
# 只预测尾号是6的ID,这块是测试要求的
# device_temp_list = df["device_id"].values.tolist()
# predict_list = list(filter(lambda x: str(x)[-1] == "6", device_temp_list))
# df = df.loc[df["device_id"].isin(predict_list)]
# TODO 上线后把下面的temp删掉
# 把刘潇的id加进去
df
=
pd
.
DataFrame
({
"device_id"
:[
"358035085192742"
],
"city_id"
:[
"beijing"
]})
device_temp_list
=
df
[
"device_id"
]
.
values
.
tolist
()
predict_list
=
list
(
filter
(
lambda
x
:
str
(
x
)[
-
1
]
==
"6"
,
device_temp_list
))
if
predict_list
==
[]:
print
(
'没有尾号是6的用户'
)
return
[]
else
:
df
=
df
.
loc
[
df
[
"device_id"
]
.
isin
(
predict_list
)]
device_list
=
df
[
"device_id"
]
.
values
.
tolist
()
city_list
=
df
[
"city_id"
]
.
values
.
tolist
()
device_city_list
=
list
(
zip
(
device_list
,
city_list
))
# TODO 上线后把刘潇的id删除
# 把刘潇的id加进去
device_city_list
.
append
((
"358035085192742"
,
"beijing"
))
print
(
"当下这一分钟预测用户数量:{}"
.
format
(
len
(
device_city_list
)))
return
device_city_list
...
...
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