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
ae16b6d6
Commit
ae16b6d6
authored
6 years ago
by
张彦钊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add eda file
parent
bbcd3bfa
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
13 deletions
+76
-13
eda.py
tensnsorflow/eda.py
+45
-0
feature.py
tensnsorflow/es/feature.py
+1
-1
ffm.py
tensnsorflow/ffm.py
+30
-12
No files found.
tensnsorflow/eda.py
0 → 100644
View file @
ae16b6d6
import
pymysql
import
pandas
as
pd
from
multiprocessing
import
Pool
import
numpy
as
np
import
datetime
import
time
def
con_sql
(
db
,
sql
):
cursor
=
db
.
cursor
()
try
:
cursor
.
execute
(
sql
)
result
=
cursor
.
fetchall
()
df
=
pd
.
DataFrame
(
list
(
result
))
except
Exception
:
print
(
"发生异常"
,
Exception
)
df
=
pd
.
DataFrame
()
finally
:
db
.
close
()
return
df
def
test
(
days
):
start
=
(
temp
-
datetime
.
timedelta
(
days
))
.
strftime
(
"
%
Y-
%
m-
%
d"
)
print
(
start
)
sql
=
"select (select count(*) from train_data where stat_date = '{}' and y = 0)/(select count(*) "
\
"from train_data where stat_date = '{}' and z = 1)"
.
format
(
start
)
db
=
pymysql
.
connect
(
host
=
'10.66.157.22'
,
port
=
4000
,
user
=
'root'
,
passwd
=
'3SYz54LS9#^9sBvC'
,
db
=
'jerry_test'
)
exp
=
con_sql
(
db
,
sql
)[
0
]
.
values
.
tolist
()[
0
]
sql
=
"select (select count(*) from train_data where stat_date = '{}' and y = 1 and z = 0)/(select count(*) "
\
"from train_data where stat_date = '{}' and z = 1)"
.
format
(
start
)
db
=
pymysql
.
connect
(
host
=
'10.66.157.22'
,
port
=
4000
,
user
=
'root'
,
passwd
=
'3SYz54LS9#^9sBvC'
,
db
=
'jerry_test'
)
click
=
con_sql
(
db
,
sql
)[
0
]
.
values
.
tolist
()[
0
]
return
start
,
exp
,
click
if
__name__
==
"__main__"
:
temp
=
datetime
.
datetime
.
strptime
(
"2019-03-14"
,
"
%
Y-
%
m-
%
d"
)
DIRECTORY_PATH
=
"/home/gmuser/"
output_path
=
DIRECTORY_PATH
+
"eda.csv"
for
i
in
range
(
1
,
41
):
a
,
b
,
c
=
test
(
i
)
with
open
(
output_path
,
'a+'
)
as
f
:
line
=
str
(
a
)
+
','
+
str
(
b
)
+
','
+
str
(
c
)
+
'
\n
'
f
.
write
(
line
)
This diff is collapsed.
Click to expand it.
tensnsorflow/es/feature.py
View file @
ae16b6d6
...
@@ -79,7 +79,7 @@ def get_data():
...
@@ -79,7 +79,7 @@ def get_data():
value_map
=
dict
(
zip
(
unique_values
,
temp
))
value_map
=
dict
(
zip
(
unique_values
,
temp
))
df
=
df
.
drop
(
"device_id"
,
axis
=
1
)
df
=
df
.
drop
(
"device_id"
,
axis
=
1
)
train
=
df
train
=
df
[
df
[
"stat_date"
]
!=
validate_date
+
"stat_date"
]
test
=
df
[
df
[
"stat_date"
]
==
validate_date
+
"stat_date"
]
test
=
df
[
df
[
"stat_date"
]
==
validate_date
+
"stat_date"
]
for
i
in
[
"ucity_id"
,
"clevel1_id"
,
"ccity_name"
,
"device_type"
,
"manufacturer"
,
for
i
in
[
"ucity_id"
,
"clevel1_id"
,
"ccity_name"
,
"device_type"
,
"manufacturer"
,
"channel"
,
"top"
,
"l1"
,
"time"
,
"stat_date"
,
"l2"
]:
"channel"
,
"top"
,
"l1"
,
"time"
,
"stat_date"
,
"l2"
]:
...
...
This diff is collapsed.
Click to expand it.
tensnsorflow/ffm.py
View file @
ae16b6d6
...
@@ -9,18 +9,7 @@ import time
...
@@ -9,18 +9,7 @@ import time
from
sqlalchemy
import
create_engine
from
sqlalchemy
import
create_engine
def
con_sql
(
db
,
sql
):
cursor
=
db
.
cursor
()
try
:
cursor
.
execute
(
sql
)
result
=
cursor
.
fetchall
()
df
=
pd
.
DataFrame
(
list
(
result
))
except
Exception
:
print
(
"发生异常"
,
Exception
)
df
=
pd
.
DataFrame
()
finally
:
db
.
close
()
return
df
# def test():
# def test():
# sql = "select max(update_time) from ffm_diary_queue"
# sql = "select max(update_time) from ffm_diary_queue"
...
@@ -285,6 +274,35 @@ def get_predict_set(ucity_id,model,ccity_name,manufacturer,channel):
...
@@ -285,6 +274,35 @@ def get_predict_set(ucity_id,model,ccity_name,manufacturer,channel):
# print("nearby_pre shape")
# print("nearby_pre shape")
# print(nearby_pre.shape)
# print(nearby_pre.shape)
def
con_sql
(
db
,
sql
):
cursor
=
db
.
cursor
()
try
:
cursor
.
execute
(
sql
)
result
=
cursor
.
fetchall
()
df
=
pd
.
DataFrame
(
list
(
result
))
except
Exception
:
print
(
"发生异常"
,
Exception
)
df
=
pd
.
DataFrame
()
finally
:
db
.
close
()
return
df
def
test
(
days
):
start
=
(
temp
-
datetime
.
timedelta
(
days
))
.
strftime
(
"
%
Y-
%
m-
%
d"
)
print
(
start
)
sql
=
"select (select count(*) from train_data where stat_date = '{}' and y = 0)/(select count(*) "
\
"from train_data where stat_date = '{}' and z = 1)"
.
format
(
start
)
db
=
pymysql
.
connect
(
host
=
'10.66.157.22'
,
port
=
4000
,
user
=
'root'
,
passwd
=
'3SYz54LS9#^9sBvC'
,
db
=
'jerry_test'
)
exp
=
con_sql
(
db
,
sql
)[
0
]
.
values
.
tolist
()[
0
]
sql
=
"select (select count(*) from train_data where stat_date = '{}' and y = 1 and z = 0)/(select count(*) "
\
"from train_data where stat_date = '{}' and z = 1)"
.
format
(
start
)
db
=
pymysql
.
connect
(
host
=
'10.66.157.22'
,
port
=
4000
,
user
=
'root'
,
passwd
=
'3SYz54LS9#^9sBvC'
,
db
=
'jerry_test'
)
click
=
con_sql
(
db
,
sql
)[
0
]
.
values
.
tolist
()[
0
]
return
start
,
exp
,
click
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
...
...
This diff is collapsed.
Click to expand it.
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