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
e31a2d70
Commit
e31a2d70
authored
Jan 07, 2019
by
张彦钊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改ffm转化函数,改成features累计相加
parent
71f3d64d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
+9
-4
ffm.py
tensnsorflow/ffm.py
+9
-4
No files found.
tensnsorflow/ffm.py
View file @
e31a2d70
...
...
@@ -187,7 +187,8 @@ def get_data():
ucity_id
=
list
(
set
(
df
[
"ucity_id"
]
.
values
.
tolist
()))
manufacturer
=
list
(
set
(
df
[
"manufacturer"
]
.
values
.
tolist
()))
channel
=
list
(
set
(
df
[
"channel"
]
.
values
.
tolist
()))
return
df
,
validate_date
,
ucity_id
,
ccity_name
,
manufacturer
,
channel
level2_ids
=
list
(
set
(
df
[
"level2_ids"
]
.
values
.
tolist
()))
return
df
,
validate_date
,
ucity_id
,
ccity_name
,
manufacturer
,
channel
,
level2_ids
def
transform
(
a
,
validate_date
):
...
...
@@ -219,7 +220,7 @@ def transform(a,validate_date):
return
model
def
get_predict_set
(
ucity_id
,
model
,
ccity_name
,
manufacturer
,
channel
):
def
get_predict_set
(
ucity_id
,
model
,
ccity_name
,
manufacturer
,
channel
,
level2_ids
):
db
=
pymysql
.
connect
(
host
=
'10.66.157.22'
,
port
=
4000
,
user
=
'root'
,
passwd
=
'3SYz54LS9#^9sBvC'
,
db
=
'jerry_test'
)
sql
=
"select e.y,e.z,e.label,e.ucity_id,e.clevel1_id,e.ccity_name,"
\
"u.device_type,u.manufacturer,u.channel,c.top,df.level2_ids,e.device_id,e.cid_id "
\
...
...
@@ -250,6 +251,10 @@ def get_predict_set(ucity_id,model,ccity_name,manufacturer,channel):
print
(
"after channel filter:"
)
print
(
df
.
shape
)
df
=
df
[
df
[
"level2_ids"
]
.
isin
(
level2_ids
)]
print
(
"after level2_ids filter:"
)
print
(
df
.
shape
)
df
[
"cid_id"
]
=
df
[
"cid_id"
]
.
astype
(
"str"
)
df
[
"clevel1_id"
]
=
df
[
"clevel1_id"
]
.
astype
(
"str"
)
df
[
"top"
]
=
df
[
"top"
]
.
astype
(
"str"
)
...
...
@@ -302,9 +307,9 @@ def get_predict_set(ucity_id,model,ccity_name,manufacturer,channel):
if
__name__
==
"__main__"
:
path
=
"/home/gmuser/esmm_data/"
a
=
time
.
time
()
temp
,
validate_date
,
ucity_id
,
ccity_name
,
manufacturer
,
channel
=
get_data
()
temp
,
validate_date
,
ucity_id
,
ccity_name
,
manufacturer
,
channel
,
level2_ids
=
get_data
()
model
=
transform
(
temp
,
validate_date
)
get_predict_set
(
ucity_id
,
model
,
ccity_name
,
manufacturer
,
channel
)
get_predict_set
(
ucity_id
,
model
,
ccity_name
,
manufacturer
,
channel
,
level2_ids
)
b
=
time
.
time
()
print
(
"cost(分钟)"
)
print
((
b
-
a
)
/
60
)
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