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
4300c804
Commit
4300c804
authored
Sep 01, 2018
by
张彦钊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
delete redis
parent
32b39b12
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
29 deletions
+0
-29
utils.py
local/utils.py
+0
-10
predictDiary.py
predictDiary.py
+0
-9
utils.py
utils.py
+0
-10
No files found.
local/utils.py
View file @
4300c804
...
...
@@ -3,7 +3,6 @@ from datetime import datetime
from
datetime
import
timedelta
import
pymysql
import
numpy
as
np
import
redis
import
pandas
as
pd
from
sklearn
import
metrics
from
sklearn.metrics
import
auc
...
...
@@ -46,15 +45,6 @@ def con_sql(sql):
return
df
# 把数据写到redis里
# TODO 生产环境的redis地址没有提供,下面的地址是测试环境的,需要改成生产环境地址
def
add_data_to_redis
(
key
,
val
):
r
=
redis
.
StrictRedis
(
host
=
'10.30.50.58'
,
port
=
6379
,
db
=
12
)
r
.
set
(
key
,
val
)
# 设置key的过期时间,36小时后过期
r
.
expire
(
key
,
36
*
60
*
60
)
# 多线程ffm转化类:
class
multiFFMFormatPandas
:
def
__init__
(
self
):
...
...
predictDiary.py
View file @
4300c804
...
...
@@ -52,9 +52,6 @@ def predict(user_profile):
print
(
"该用户预测结束"
)
predict_save_to_local
(
user_profile
,
instance
)
#TODO 没有提供生产环境的redis地址,所以这个函数先不运行
# predict_save_to_redis(user_profile, instance)
# 将预测结果与device_id 进行拼接,并按照概率降序排序
def
wrapper_result
(
user_profile
,
instance
):
proba
=
pd
.
read_csv
(
DIRECTORY_PATH
+
...
...
@@ -72,12 +69,6 @@ def predict_save_to_local(user_profile, instance):
proba
.
to_csv
(
DIRECTORY_PATH
+
"result/feed_{}"
.
format
(
user_profile
[
'device_id'
]),
index
=
False
)
print
(
"成功将预测候选集保存到本地"
)
# 预测候选集保存到redis
def
predict_save_to_redis
(
user_profile
,
instance
):
device_id
=
user_profile
[
'device_id'
]
cid_list
=
wrapper_result
(
user_profile
,
instance
)[
"cid"
]
.
values
.
tolist
()
add_data_to_redis
(
device_id
,
cid_list
)
print
(
"成功将预测候选集保存到redis"
)
def
router
(
device_id
):
user_profile
,
not_exist
=
fetch_user_profile
(
device_id
)
...
...
utils.py
View file @
4300c804
...
...
@@ -3,7 +3,6 @@ from datetime import datetime
from
datetime
import
timedelta
import
pymysql
import
numpy
as
np
import
redis
import
pandas
as
pd
from
sklearn
import
metrics
from
sklearn.metrics
import
auc
...
...
@@ -73,15 +72,6 @@ def restart_process():
print
(
"成功重启diaryUpdateOnlineOffline.py"
)
# 把数据写到redis里
# TODO 生产环境的redis地址没有提供,下面的地址是测试环境的,需要改成生产环境地址
def
add_data_to_redis
(
key
,
val
):
r
=
redis
.
StrictRedis
(
host
=
'10.30.50.58'
,
port
=
6379
,
db
=
12
)
r
.
set
(
key
,
val
)
# 设置key的过期时间,36小时后过期
r
.
expire
(
key
,
36
*
60
*
60
)
# 多线程ffm转化类:
class
multiFFMFormatPandas
:
def
__init__
(
self
):
...
...
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