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
b4bfaa68
Commit
b4bfaa68
authored
May 23, 2019
by
张彦钊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change test file
parent
7eb0395f
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
6 deletions
+5
-6
feature_engineering.py
tensnsorflow/feature_engineering.py
+0
-0
multi.py
tensnsorflow/multi.py
+5
-6
No files found.
tensnsorflow/feature_engineering.py
View file @
b4bfaa68
This diff is collapsed.
Click to expand it.
tensnsorflow/multi.py
View file @
b4bfaa68
...
...
@@ -17,7 +17,6 @@ def app_list_func(x,l):
else
:
e
.
append
(
0
)
return
e
# return ",".join([str(j) for j in e])
def
multi_hot
(
df
,
column
,
n
):
...
...
@@ -32,7 +31,7 @@ def multi_hot(df,column,n):
return
number
,
app_list_map
def
feature
_engineer
():
def
feature
():
db
=
pymysql
.
connect
(
host
=
'172.16.40.158'
,
port
=
4000
,
user
=
'root'
,
passwd
=
'3SYz54LS9#^9sBvC'
,
db
=
'jerry_test'
)
sql
=
"select max(stat_date) from esmm_train_data"
validate_date
=
con_sql
(
db
,
sql
)[
0
]
.
values
.
tolist
()[
0
]
...
...
@@ -99,9 +98,9 @@ def get_predict(date,value_map,app_list_map):
native_pre
=
spark
.
createDataFrame
(
rdd
.
filter
(
lambda
x
:
x
[
4
]
==
0
)
.
map
(
lambda
x
:(
x
[
1
],
x
[
2
],
x
[
3
])))
\
.
toDF
(
"city"
,
"uid"
,
"cid_id"
)
print
(
"native"
)
#
native_pre.toPandas().to_csv(local_path+"native.csv", header=True)
native_pre
.
coalesce
(
1
)
.
write
.
format
(
'com.databricks.spark.csv'
)
.
save
(
path
+
"hello.csv
"
,
header
=
'true'
)
native_pre
.
toPandas
()
.
to_csv
(
local_path
+
"native.csv"
,
header
=
True
)
# TODO 写成csv文件改成下面这样
# native_pre.coalesce(1).write.format('com.databricks.spark.csv').save(path+"native/
",header = 'true')
# 预测的tfrecord必须写成一个文件,这样可以摆保证顺序
spark
.
createDataFrame
(
rdd
.
filter
(
lambda
x
:
x
[
4
]
==
0
)
.
map
(
lambda
x
:
(
x
[
0
],
x
[
5
],
x
[
6
],
x
[
7
])))
\
...
...
@@ -145,7 +144,7 @@ if __name__ == '__main__':
path
=
"hdfs:///strategy/esmm/"
local_path
=
"/home/gmuser/esmm/"
validate_date
,
value_map
,
app_list_map
=
feature
_engineer
()
validate_date
,
value_map
,
app_list_map
=
feature
()
get_predict
(
validate_date
,
value_map
,
app_list_map
)
# df = spark.read.format("tfrecords").option("recordType", "Example").load("/strategy/va.tfrecord")
...
...
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