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
179a52c1
Commit
179a52c1
authored
Aug 30, 2019
by
张彦钊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change test file
parent
9d0b5928
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
23 deletions
+37
-23
rerank_esmm.py
rerank_esmm.py
+37
-23
No files found.
rerank_esmm.py
View file @
179a52c1
...
...
@@ -152,7 +152,7 @@ def tag_boost(cid_str, tag_list):
def
to_
data_base
(
df2
):
def
data_base
(
df2
):
device_count
=
df2
.
shape
[
0
]
con
=
pymysql
.
connect
(
host
=
'172.16.40.158'
,
port
=
4000
,
user
=
'root'
,
passwd
=
'3SYz54LS9#^9sBvC'
,
db
=
'jerry_test'
)
cur
=
con
.
cursor
()
...
...
@@ -186,32 +186,46 @@ def to_data_base(df2):
# print(e)
def
to_data_base
():
db
=
pymysql
.
connect
(
host
=
'172.16.40.158'
,
port
=
4000
,
user
=
'root'
,
passwd
=
'3SYz54LS9#^9sBvC'
,
db
=
'jerry_test'
)
cursor
=
db
.
cursor
()
sql
=
"select device_id from esmm_device_diary_queue limit 6"
cursor
.
execute
(
sql
)
result
=
cursor
.
fetchall
()
print
(
result
)
print
(
set
(
result
))
db
.
close
()
if
__name__
==
"__main__"
:
users_list
=
get_esmm_users
()
total_samples
=
list
()
name_tag
=
get_searchworlds_to_tagid
()
# TODO 把下面的截断改掉
for
i
in
users_list
[:
60
]:
tag_list
=
get_user_profile
(
i
[
0
])
queues
=
get_queues
(
i
[
0
],
i
[
1
])
if
len
(
queues
)
>
0
and
len
(
tag_list
)
>
0
:
new_native
=
tag_boost
(
queues
[
0
],
tag_list
)
new_nearby
=
tag_boost
(
queues
[
1
],
tag_list
)
insert_time
=
str
(
datetime
.
datetime
.
now
()
.
strftime
(
'
%
Y
%
m
%
d
%
H
%
M'
))
sample
=
[
i
[
0
],
i
[
1
],
new_native
,
new_nearby
,
queues
[
2
],
queues
[
3
],
insert_time
]
total_samples
.
append
(
sample
)
if
len
(
total_samples
)
>
0
:
df
=
pd
.
DataFrame
(
total_samples
)
df
=
df
.
rename
(
columns
=
{
0
:
"device_id"
,
1
:
"city_id"
,
2
:
"native_queue"
,
3
:
"nearby_queue"
,
4
:
"nation_queue"
,
5
:
"megacity_queue"
,
6
:
"time"
})
print
(
df
.
head
(
2
))
to_data_base
(
df
)
print
(
"good boy"
)
#
users_list = get_esmm_users()
#
total_samples = list()
#
name_tag = get_searchworlds_to_tagid()
#
#
TODO 把下面的截断改掉
#
for i in users_list[:60]:
#
tag_list = get_user_profile(i[0])
#
queues = get_queues(i[0],i[1])
#
if len(queues) > 0 and len(tag_list) > 0:
#
new_native = tag_boost(queues[0], tag_list)
#
new_nearby = tag_boost(queues[1], tag_list)
#
#
insert_time = str(datetime.datetime.now().strftime('%Y%m%d%H%M'))
#
sample = [i[0],i[1],new_native,new_nearby,queues[2],queues[3],insert_time]
#
total_samples.append(sample)
#
#
if len(total_samples) > 0:
#
df = pd.DataFrame(total_samples)
#
df = df.rename(columns={0: "device_id", 1: "city_id",2:"native_queue",
#
3:"nearby_queue",4:"nation_queue",5:"megacity_queue",6:"time"})
#
print(df.head(2))
#
to_data_base(df)
#
print("good boy")
# to_data_base(df)
# to kv
to_data_base
()
# cid_str = "16473983,16296886,16199213,16193883,16419499,16372783,16430184,16617593,16498902,16238415,16214258,15715721,16213338,15349114,14091428,16268804,15485655,16448547,16179842,16685025,16612412,16683132,15646229,16482213,16485831,16436136,16353856,16400696,16193006,16294202,16393228,16716816,16713343,16780702,16107140,16647027,16112786,16503037,16372681,16207971,16179934,16480641,16295094,16204980,16317847,16434907,16117929,15633591,16116818"
...
...
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