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
4befca07
Commit
4befca07
authored
Aug 29, 2019
by
张彦钊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change tets
parent
43ffadf4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
5 deletions
+30
-5
rerank_esmm.py
rerank_esmm.py
+30
-5
No files found.
rerank_esmm.py
View file @
4befca07
import
pymysql
import
pymysql
import
datetime
import
datetime
import
json
def
get_esmm_users
():
def
get_esmm_users
():
...
@@ -9,15 +10,38 @@ def get_esmm_users():
...
@@ -9,15 +10,38 @@ def get_esmm_users():
stat_date
=
(
datetime
.
date
.
today
()
-
datetime
.
timedelta
(
days
=
1
))
.
strftime
(
"
%
Y-
%
m-
%
d"
)
stat_date
=
(
datetime
.
date
.
today
()
-
datetime
.
timedelta
(
days
=
1
))
.
strftime
(
"
%
Y-
%
m-
%
d"
)
print
(
stat_date
)
print
(
stat_date
)
sql
=
"select distinct device_id,city_id from data_feed_exposure_precise "
\
sql
=
"select distinct device_id,city_id from data_feed_exposure_precise "
\
"where stat_date = '{}'
limit 20
"
.
format
(
stat_date
)
"where stat_date = '{}'"
.
format
(
stat_date
)
cursor
.
execute
(
sql
)
cursor
.
execute
(
sql
)
result
=
list
(
cursor
.
fetchall
())
result
=
list
(
cursor
.
fetchall
())
print
(
result
[:
2
])
return
result
return
result
def
get_user_profile
(
device_id
):
def
get_user_profile
():
pass
r
=
redis
.
Redis
(
host
=
"172.16.40.135"
,
port
=
5379
,
password
=
""
,
db
=
2
)
cl_id
=
"9C5E7C73-380C-4623-8F48-A64C8034E315"
key
=
"user:portrait_tags:cl_id:"
+
str
(
cl_id
)
tmp
=
json
.
loads
(
r
.
get
(
key
)
.
decode
(
'utf-8'
))
# todo 找赵晨把search word映射成tag
tags
=
{}
for
i
in
tmp
:
tags
[
i
[
"content"
]]
=
i
[
"score"
]
tags
=
sorted
(
tags
.
items
(),
key
=
lambda
x
:
x
[
1
],
reverse
=
True
)
tag_score
=
{}
if
len
(
tmp
)
>
5
:
for
i
in
list
(
tags
.
keys
())[:
5
]:
tag_score
[
i
]
=
tags
[
i
]
print
(
tag_score
)
return
tag_score
else
:
print
(
tags
)
return
tags
def
transform_to_tag
(
user_profile
):
def
transform_to_tag
(
user_profile
):
...
@@ -55,7 +79,8 @@ if __name__ == "__main__":
...
@@ -55,7 +79,8 @@ if __name__ == "__main__":
#
#
# total_samples.todf
# total_samples.todf
# to_data_base(df)
# to_data_base(df)
get_esmm_users
()
get_user_profile
()
...
...
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