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
9d25ea4b
Commit
9d25ea4b
authored
Dec 03, 2018
by
张彦钊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改str cat函数
parent
fb81a269
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
11 deletions
+12
-11
ffm.py
tensnsorflow/ffm.py
+12
-11
No files found.
tensnsorflow/ffm.py
View file @
9d25ea4b
...
...
@@ -44,32 +44,33 @@ def get_data():
df
[
"cid_id"
]
=
df
[
"cid_id"
]
.
astype
(
"str"
)
df
[
"y"
]
=
df
[
"y"
]
.
astype
(
"str"
)
df
[
"z"
]
=
df
[
"z"
]
.
astype
(
"str"
)
df
[
"y"
]
=
df
[
"device_id"
]
.
str
.
cat
([
df
[
"ucity_id"
]
.
values
.
tolist
(),
df
[
"cid_id"
]
.
values
.
tolist
(),
df
[
"y"
]
=
df
[
"device_id"
]
.
str
.
cat
([
df
[
"
stat_date"
]
.
values
.
tolist
(),
df
[
"
ucity_id"
]
.
values
.
tolist
(),
df
[
"cid_id"
]
.
values
.
tolist
(),
df
[
"y"
]
.
values
.
tolist
(),
df
[
"z"
]
.
values
.
tolist
()],
sep
=
","
)
df
=
df
.
drop
(
"z"
,
axis
=
1
)
print
(
df
.
head
())
train
=
df
[
df
[
"stat_date"
]
!=
"2018-11-25"
]
transform
(
train
,
"crvtrain.csv"
)
test
=
df
[
df
[
"stat_date"
]
==
"2018-11-25"
]
transform
(
test
,
"crvtest.csv"
)
transform
(
df
)
def
transform
(
df
,
table
):
def
transform
(
df
):
model
=
multiFFMFormatPandas
()
df
=
model
.
fit_transform
(
df
,
y
=
"y"
,
n
=
80000
,
processes
=
20
)
df
=
pd
.
DataFrame
(
df
)
df
[
"device_id"
]
=
df
[
0
]
.
apply
(
lambda
x
:
x
.
split
(
","
)[
0
])
df
[
"city_id"
]
=
df
[
0
]
.
apply
(
lambda
x
:
x
.
split
(
","
)[
1
])
df
[
"diary_id"
]
=
df
[
0
]
.
apply
(
lambda
x
:
x
.
split
(
","
)[
2
])
df
[
"stat_date"
]
=
df
[
0
]
.
apply
(
lambda
x
:
x
.
split
(
","
)[
0
])
df
[
"device_id"
]
=
df
[
0
]
.
apply
(
lambda
x
:
x
.
split
(
","
)[
1
])
df
[
"city_id"
]
=
df
[
0
]
.
apply
(
lambda
x
:
x
.
split
(
","
)[
2
])
df
[
"diary_id"
]
=
df
[
0
]
.
apply
(
lambda
x
:
x
.
split
(
","
)[
3
])
df
[
"seq"
]
=
list
(
range
(
df
.
shape
[
0
]))
df
[
"seq"
]
=
df
[
"seq"
]
.
astype
(
"str"
)
df
[
"ffm"
]
=
df
[
0
]
.
apply
(
lambda
x
:
","
.
join
(
x
.
split
(
","
)[
3
:]))
df
[
"ffm"
]
=
df
[
0
]
.
apply
(
lambda
x
:
","
.
join
(
x
.
split
(
","
)[
4
:]))
df
[
"ffm"
]
=
df
[
"seq"
]
.
str
.
cat
(
df
[
"ffm"
],
sep
=
","
)
df
[
"random"
]
=
np
.
random
.
randint
(
1
,
2147483647
,
df
.
shape
[
0
])
df
=
df
.
drop
(
0
,
axis
=
1
)
.
drop
(
"seq"
,
axis
=
1
)
print
(
"size"
)
print
(
df
.
shape
)
df
.
to_csv
(
path
+
table
,
index
=
None
)
train
=
df
[
df
[
"stat_date"
]
!=
"2018-11-25"
]
.
drop
(
"stat_date"
,
axis
=
1
)
test
=
df
[
df
[
"stat_date"
]
==
"2018-11-25"
]
.
drop
(
"stat_date"
,
axis
=
1
)
train
.
to_csv
(
path
+
"train.csv"
,
index
=
None
)
test
.
to_csv
(
path
+
"test.csv"
,
index
=
None
)
# yconnect = create_engine('mysql+pymysql://root:3SYz54LS9#^9sBvC@10.66.157.22:4000/jerry_test?charset=utf8')
# n = 100000
# for i in range(0,df.shape[0],n):
...
...
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