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
f406c2a4
Commit
f406c2a4
authored
Jan 15, 2019
by
张彦钊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pandas 映射
parent
4e17c892
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
8 deletions
+9
-8
feature_engineering.py
tensnsorflow/feature_engineering.py
+2
-2
test.py
tensnsorflow/test.py
+7
-6
train.py
tensnsorflow/train.py
+0
-0
No files found.
tensnsorflow/feature_engineering.py
View file @
f406c2a4
...
@@ -59,8 +59,8 @@ def get_data():
...
@@ -59,8 +59,8 @@ def get_data():
value_map
=
{
v
:
k
for
k
,
v
in
enumerate
(
unique_values
)}
value_map
=
{
v
:
k
for
k
,
v
in
enumerate
(
unique_values
)}
df
=
df
.
drop
(
"device_id"
,
axis
=
1
)
df
=
df
.
drop
(
"device_id"
,
axis
=
1
)
train
=
df
[
df
[
"stat_date"
]
!=
validate_date
]
train
=
df
[
df
[
"stat_date"
]
!=
validate_date
+
"stat_date"
]
test
=
df
[
df
[
"stat_date"
]
==
validate_date
]
test
=
df
[
df
[
"stat_date"
]
==
validate_date
+
"stat_date"
]
for
i
in
features
:
for
i
in
features
:
train
[
i
]
=
train
[
i
]
.
map
(
value_map
)
train
[
i
]
=
train
[
i
]
.
map
(
value_map
)
test
[
i
]
=
test
[
i
]
.
map
(
value_map
)
test
[
i
]
=
test
[
i
]
.
map
(
value_map
)
...
...
tensnsorflow/test.py
View file @
f406c2a4
...
@@ -26,8 +26,7 @@ def gen_tfrecords(in_file):
...
@@ -26,8 +26,7 @@ def gen_tfrecords(in_file):
out_file
=
os
.
path
.
join
(
FLAGS
.
output_dir
,
basename
)
out_file
=
os
.
path
.
join
(
FLAGS
.
output_dir
,
basename
)
tfrecord_out
=
tf
.
python_io
.
TFRecordWriter
(
out_file
)
tfrecord_out
=
tf
.
python_io
.
TFRecordWriter
(
out_file
)
df
=
pd
.
read_csv
(
in_file
)
df
=
pd
.
read_csv
(
in_file
)
[
""
,
""
,
""
,
"device_type"
,
"manufacturer"
,
,
"level2_ids"
,
"time"
,
"stat_date"
]
for
i
in
range
(
df
.
shape
[
0
]):
for
i
in
range
(
df
.
shape
[
0
]):
features
=
tf
.
train
.
Features
(
feature
=
{
features
=
tf
.
train
.
Features
(
feature
=
{
"y"
:
tf
.
train
.
Feature
(
int64_list
=
tf
.
train
.
Int64List
(
value
=
[
df
[
"y"
][
i
]])),
"y"
:
tf
.
train
.
Feature
(
int64_list
=
tf
.
train
.
Int64List
(
value
=
[
df
[
"y"
][
i
]])),
...
@@ -37,11 +36,13 @@ def gen_tfrecords(in_file):
...
@@ -37,11 +36,13 @@ def gen_tfrecords(in_file):
"ucity_id"
:
tf
.
train
.
Feature
(
int64_list
=
tf
.
train
.
Int64List
(
value
=
[
df
[
"ucity_id"
][
i
]])),
"ucity_id"
:
tf
.
train
.
Feature
(
int64_list
=
tf
.
train
.
Int64List
(
value
=
[
df
[
"ucity_id"
][
i
]])),
"clevel1_id"
:
tf
.
train
.
Feature
(
int64_list
=
tf
.
train
.
Int64List
(
value
=
[
df
[
"clevel1_id"
][
i
]])),
"clevel1_id"
:
tf
.
train
.
Feature
(
int64_list
=
tf
.
train
.
Int64List
(
value
=
[
df
[
"clevel1_id"
][
i
]])),
"ccity_name"
:
tf
.
train
.
Feature
(
int64_list
=
tf
.
train
.
Int64List
(
value
=
[
df
[
"ccity_name"
][
i
]])),
"ccity_name"
:
tf
.
train
.
Feature
(
int64_list
=
tf
.
train
.
Int64List
(
value
=
[
df
[
"ccity_name"
][
i
]])),
"channel"
:
tf
.
train
.
Feature
(
int64_list
=
tf
.
train
.
Int64List
(
value
=
[
df
[
"channel"
][
i
]])),
"device_type"
:
tf
.
train
.
Feature
(
int64_list
=
tf
.
train
.
Int64List
(
value
=
[
df
[
"device_type"
][
i
]])),
"manufacturer"
:
tf
.
train
.
Feature
(
int64_list
=
tf
.
train
.
Int64List
(
value
=
[
df
[
"manufacturer"
][
i
]])),
"level2_ids"
:
tf
.
train
.
Feature
(
int64_list
=
tf
.
train
.
Int64List
(
value
=
[
df
[
"level2_ids"
][
i
]])),
"time"
:
tf
.
train
.
Feature
(
int64_list
=
tf
.
train
.
Int64List
(
value
=
[
df
[
"time"
][
i
]])),
"stat_date"
:
tf
.
train
.
Feature
(
int64_list
=
tf
.
train
.
Int64List
(
value
=
[
df
[
"stat_date"
][
i
]]))
})
})
example
=
tf
.
train
.
Example
(
features
=
tf
.
train
.
Features
(
feature
=
features
))
example
=
tf
.
train
.
Example
(
features
=
tf
.
train
.
Features
(
feature
=
feature
))
serialized
=
example
.
SerializeToString
()
serialized
=
example
.
SerializeToString
()
tfrecord_out
.
write
(
serialized
)
tfrecord_out
.
write
(
serialized
)
tfrecord_out
.
close
()
tfrecord_out
.
close
()
...
...
tensnsorflow/train.py
0 → 100644
View file @
f406c2a4
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