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
ea80570f
Commit
ea80570f
authored
Aug 15, 2018
by
张彦钊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change preidct and training argument
parent
dbcbc226
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
4 deletions
+6
-4
diaryTraining.py
diaryTraining.py
+2
-2
predictDiary.py
predictDiary.py
+3
-1
processData.py
processData.py
+1
-1
No files found.
diaryTraining.py
View file @
ea80570f
...
@@ -9,8 +9,8 @@ def train():
...
@@ -9,8 +9,8 @@ def train():
ffm_model
=
xl
.
create_ffm
()
ffm_model
=
xl
.
create_ffm
()
ffm_model
.
setTrain
(
DIRECTORY_PATH
+
"train{0}-{1}.csv"
.
format
(
DATA_START_DATE
,
VALIDATION_DATE
))
ffm_model
.
setTrain
(
DIRECTORY_PATH
+
"train{0}-{1}.csv"
.
format
(
DATA_START_DATE
,
VALIDATION_DATE
))
ffm_model
.
setValidate
(
DIRECTORY_PATH
+
"validation{0}.csv"
.
format
(
VALIDATION_DATE
))
ffm_model
.
setValidate
(
DIRECTORY_PATH
+
"validation{0}.csv"
.
format
(
VALIDATION_DATE
))
# log保存路径,如果不加这个参数,日志默认保存在/temp路径下,不符合规范
param
=
{
'task'
:
'binary'
,
'lr'
:
lr
,
'lambda'
:
l2_lambda
,
'metric'
:
'auc'
}
param
=
{
'task'
:
'binary'
,
'lr'
:
lr
,
'lambda'
:
l2_lambda
,
'metric'
:
'auc'
,
"log"
:
"/data2/models/result"
}
ffm_model
.
fit
(
param
,
DIRECTORY_PATH
+
"model_lr{}_lambda{}.out"
.
format
(
lr
,
l2_lambda
))
ffm_model
.
fit
(
param
,
DIRECTORY_PATH
+
"model_lr{}_lambda{}.out"
.
format
(
lr
,
l2_lambda
))
...
...
predictDiary.py
View file @
ea80570f
...
@@ -52,7 +52,9 @@ def predict(user_profile):
...
@@ -52,7 +52,9 @@ def predict(user_profile):
ffm_model
=
xl
.
create_ffm
()
ffm_model
=
xl
.
create_ffm
()
ffm_model
.
setTest
(
instance_file_path
)
ffm_model
.
setTest
(
instance_file_path
)
ffm_model
.
setSigmoid
()
ffm_model
.
setSigmoid
()
ffm_model
.
predict
(
DIRECTORY_PATH
+
"model_lr{}_lambda{}.out"
.
format
(
lr
,
l2_lambda
),
#日志保存路径,如果不加这个参数,日志默认保存在/temp路径下,不符合规范
param
=
{
"log"
:
"/data2/models/result"
}
ffm_model
.
predict
(
param
,
DIRECTORY_PATH
+
"model_lr{}_lambda{}.out"
.
format
(
lr
,
l2_lambda
),
DIRECTORY_PATH
+
"result/{0}_output.txt"
.
format
(
user_profile
[
'device_id'
]))
DIRECTORY_PATH
+
"result/{0}_output.txt"
.
format
(
user_profile
[
'device_id'
]))
print
(
"预测结束"
)
print
(
"预测结束"
)
predict_save_to_local
(
user_profile
,
instance
)
predict_save_to_local
(
user_profile
,
instance
)
...
...
processData.py
View file @
ea80570f
...
@@ -77,7 +77,7 @@ def ffm_transform(data, test_number, validation_number):
...
@@ -77,7 +77,7 @@ def ffm_transform(data, test_number, validation_number):
print
(
"Start ffm transform"
)
print
(
"Start ffm transform"
)
start
=
time
.
time
()
start
=
time
.
time
()
ffm_train
=
multiFFMFormatPandas
()
ffm_train
=
multiFFMFormatPandas
()
data
=
ffm_train
.
fit_transform
(
data
,
y
=
'y'
,
n
=
50000
,
processes
=
6
)
data
=
ffm_train
.
fit_transform
(
data
,
y
=
'y'
,
n
=
50000
,
processes
=
5
)
with
open
(
DIRECTORY_PATH
+
"ffm_{0}_{1}.pkl"
.
format
(
DATA_START_DATE
,
DATA_END_DATE
),
"wb"
)
as
f
:
with
open
(
DIRECTORY_PATH
+
"ffm_{0}_{1}.pkl"
.
format
(
DATA_START_DATE
,
DATA_END_DATE
),
"wb"
)
as
f
:
pickle
.
dump
(
ffm_train
,
f
)
pickle
.
dump
(
ffm_train
,
f
)
...
...
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