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
6ced4f40
Commit
6ced4f40
authored
6 years ago
by
张彦钊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
delete predict function param argument
parent
dcc31112
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
11 deletions
+4
-11
diaryTraining.py
diaryTraining.py
+1
-2
predictDiary.py
predictDiary.py
+1
-3
utils.py
utils.py
+2
-6
No files found.
diaryTraining.py
View file @
6ced4f40
...
...
@@ -15,7 +15,6 @@ def train():
print
(
"predicting"
)
ffm_model
.
setTest
(
DIRECTORY_PATH
+
"test_ffm_data.csv"
)
ffm_model
.
setSigmoid
()
param_predict
=
{
"log"
:
"/data2/models/result"
}
ffm_model
.
predict
(
param_predict
,
DIRECTORY_PATH
+
"model.out"
,
DIRECTORY_PATH
+
"test_set_predict_output.txt"
)
ffm_model
.
predict
(
DIRECTORY_PATH
+
"model.out"
,
DIRECTORY_PATH
+
"test_set_predict_output.txt"
)
This diff is collapsed.
Click to expand it.
predictDiary.py
View file @
6ced4f40
...
...
@@ -48,9 +48,7 @@ def predict(user_profile):
ffm_model
.
setTest
(
instance_file_path
)
ffm_model
.
setSigmoid
()
#日志保存路径,如果不加这个参数,日志默认保存在/temp路径下,不符合规范
param
=
{
"log"
:
"/data2/models/result"
}
ffm_model
.
predict
(
param
,
DIRECTORY_PATH
+
"model.out"
,
ffm_model
.
predict
(
DIRECTORY_PATH
+
"model.out"
,
DIRECTORY_PATH
+
"result/{0}_output.txt"
.
format
(
user_profile
[
'device_id'
]))
print
(
"该用户预测结束"
)
predict_save_to_local
(
user_profile
,
instance
)
...
...
This diff is collapsed.
Click to expand it.
utils.py
View file @
6ced4f40
...
...
@@ -94,7 +94,7 @@ class multiFFMFormatPandas:
self
.
fit
(
df
,
y
)
n
=
n
processes
=
processes
return
self
.
transform
(
df
,
n
=
n
,
processes
=
processes
)
return
self
.
transform
(
df
,
n
,
processes
)
def
transform_row_
(
self
,
row
,
t
):
ffm
=
[]
...
...
@@ -112,17 +112,13 @@ class multiFFMFormatPandas:
ffm
.
append
(
'{}:{}:{}'
.
format
(
self
.
field_index_
[
col
],
self
.
feature_index_
[
col
],
val
))
return
' '
.
join
(
ffm
)
# def transform(self, df):
# t = df.dtypes.to_dict()
# return pd.Series({idx: self.transform_row_(row, t) for idx, row in df.iterrows()})
def
transform
(
self
,
df
,
n
=
10000
,
processes
=
1
):
# n是每个线程运行最大的数据条数,processes是线程数
t
=
df
.
dtypes
.
to_dict
()
data_list
=
self
.
data_split_line
(
df
,
n
)
# 设置进程的数量
pool
=
Pool
(
processes
=
processes
)
pool
=
Pool
(
processes
)
for
i
in
range
(
len
(
data_list
)):
print
(
"处理进度: "
+
str
(
i
+
1
)
+
"/"
+
str
(
len
(
data_list
)))
data_list
[
i
]
=
pool
.
apply_async
(
self
.
pool_function
,
(
data_list
[
i
],
t
,))
...
...
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