Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
serviceRec
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
郭羽
serviceRec
Commits
044f71fc
Commit
044f71fc
authored
Jun 24, 2021
by
郭羽
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
特征工程优化
parent
c0093701
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
2 deletions
+6
-2
featureEng.py
spark/featureEng.py
+1
-1
train_service.py
train/train_service.py
+5
-1
No files found.
spark/featureEng.py
View file @
044f71fc
...
@@ -834,7 +834,7 @@ if __name__ == '__main__':
...
@@ -834,7 +834,7 @@ if __name__ == '__main__':
train_columns
=
model_columns
+
[
"label"
,
"timestamp"
]
train_columns
=
model_columns
+
[
"label"
,
"timestamp"
]
trainSamples
=
samplesWithUserFeatures
.
select
(
*
train_columns
)
trainSamples
=
samplesWithUserFeatures
.
select
(
*
train_columns
)
print
(
"write to hdfs start..."
)
print
(
"write to hdfs start..."
)
splitTimestamp
=
int
(
time
.
mktime
(
time
.
strptime
(
addDays
(
-
1
),
"
%
Y
%
m
%
d"
)))
splitTimestamp
=
int
(
time
.
mktime
(
time
.
strptime
(
addDays
(
0
),
"
%
Y
%
m
%
d"
)))
splitAndSaveTrainingTestSamplesByTimeStamp
(
trainSamples
,
splitTimestamp
,
TRAIN_FILE_PATH
)
splitAndSaveTrainingTestSamplesByTimeStamp
(
trainSamples
,
splitTimestamp
,
TRAIN_FILE_PATH
)
print
(
"write to hdfs success..."
)
print
(
"write to hdfs success..."
)
timestmp7
=
int
(
round
(
time
.
time
()))
timestmp7
=
int
(
round
(
time
.
time
()))
...
...
train/train_service.py
View file @
044f71fc
...
@@ -4,6 +4,8 @@ import pandas as pd
...
@@ -4,6 +4,8 @@ import pandas as pd
import
time
import
time
import
sys
import
sys
import
os
import
os
from
datetime
import
date
,
timedelta
sys
.
path
.
append
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
))))
sys
.
path
.
append
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
))))
import
utils.connUtils
as
connUtils
import
utils.connUtils
as
connUtils
...
@@ -170,12 +172,14 @@ def predict(model_path,df):
...
@@ -170,12 +172,14 @@ def predict(model_path,df):
model_new
.
predict
(
dd
,
batch_size
=
10000
)
model_new
.
predict
(
dd
,
batch_size
=
10000
)
print
(
"测试样本数:{},测试耗时ms:{}"
.
format
(
n
,
int
(
round
(
time
.
time
()
*
1000
))
-
timestmp1
))
print
(
"测试样本数:{},测试耗时ms:{}"
.
format
(
n
,
int
(
round
(
time
.
time
()
*
1000
))
-
timestmp1
))
def
addDays
(
n
,
format
=
"
%
Y
%
m
%
d"
):
return
(
date
.
today
()
+
timedelta
(
days
=
n
))
.
strftime
(
format
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
curTime
=
time
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
,
time
.
localtime
())
curTime
=
time
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
,
time
.
localtime
())
print
(
"train_service执行时间:{}"
.
format
(
curTime
))
print
(
"train_service执行时间:{}"
.
format
(
curTime
))
splitTimestamp
=
int
(
time
.
mktime
(
time
.
strptime
(
addDays
(
-
1
),
"
%
Y
%
m
%
d"
)))
# redis中加载数据字典
# redis中加载数据字典
print
(
"redis 中加载模型字典..."
)
print
(
"redis 中加载模型字典..."
)
...
...
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