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
2a413f5c
Commit
2a413f5c
authored
Jan 16, 2019
by
张彦钊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
multi hot
parent
96420a74
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
17 deletions
+1
-17
feature_engineering.py
tensnsorflow/feature_engineering.py
+0
-16
multi_hot.py
tensnsorflow/multi_hot.py
+1
-1
No files found.
tensnsorflow/feature_engineering.py
View file @
2a413f5c
...
...
@@ -78,22 +78,6 @@ def get_data():
return
validate_date
,
value_map
def
multi_hot
(
df
,
i
,
n
):
ItemID_set
=
set
()
for
i
in
df
[
i
]
.
unique
():
ItemID_set
.
update
(
set
(
i
.
split
(
","
)))
ItemID2int
=
dict
(
zip
(
list
(
ItemID_set
),
list
(
range
(
n
+
1
,
n
+
1
+
len
(
ItemID_set
),
1
))))
ItemID_map
=
{
val
:
[
ItemID2int
[
row
]
for
row
in
val
.
split
(
','
)]
\
for
ii
,
val
in
enumerate
(
set
(
df
[
1
]))}
ItemID_map_max_len
=
3
for
key
in
ItemID_map
:
for
cnt
in
range
(
ItemID_map_max_len
-
len
(
ItemID_map
[
key
])):
ItemID_map
[
key
]
.
insert
(
len
(
ItemID_map
[
key
])
+
cnt
,
88
)
df
[
i
]
=
df
[
i
]
.
map
(
ItemID_map
)
def
write_csv
(
df
,
name
,
n
):
for
i
in
range
(
0
,
df
.
shape
[
0
],
n
):
if
i
==
0
:
...
...
tensnsorflow/multi_hot.py
View file @
2a413f5c
...
...
@@ -26,7 +26,7 @@ def multi():
df
[
"l2"
]
=
"lost"
df
[
"l3"
]
=
"lost"
for
i
in
list
(
df
[
"level"
]
.
unique
()):
l
=
i
.
split
(
"
,
"
)
l
=
i
.
split
(
"
;
"
)
if
len
(
l
)
==
3
:
df
.
loc
[
df
[
"level"
]
==
i
,
[
"l1"
]]
=
l
[
0
]
df
.
loc
[
df
[
"level"
]
==
i
,
[
"l2"
]]
=
l
[
1
]
...
...
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