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
fcfb12fe
Commit
fcfb12fe
authored
Jun 23, 2021
by
郭羽
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
特征工程优化
parent
57d4f6ea
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
2 deletions
+4
-2
featureEng.py
spark/featureEng.py
+3
-1
train_service.py
train/train_service.py
+1
-1
No files found.
spark/featureEng.py
View file @
fcfb12fe
...
@@ -231,6 +231,7 @@ def getDataVocab(samples,model_columns):
...
@@ -231,6 +231,7 @@ def getDataVocab(samples,model_columns):
# 多值特征
# 多值特征
for
c
in
ITEM_MULTI_COLUMN_EXTRA_MAP
.
keys
():
for
c
in
ITEM_MULTI_COLUMN_EXTRA_MAP
.
keys
():
print
(
c
)
datas
=
samples
.
select
(
c
)
.
distinct
()
.
collect
()
datas
=
samples
.
select
(
c
)
.
distinct
()
.
collect
()
tagSet
=
set
()
tagSet
=
set
()
for
d
in
datas
:
for
d
in
datas
:
...
@@ -244,6 +245,7 @@ def getDataVocab(samples,model_columns):
...
@@ -244,6 +245,7 @@ def getDataVocab(samples,model_columns):
# id类特征 和 类别特征
# id类特征 和 类别特征
for
c
in
[
"userid"
,
"itemid"
]
+
[
ITEM_PREFIX
+
c
for
c
in
ITEM_CATE_COLUMNS
]:
for
c
in
[
"userid"
,
"itemid"
]
+
[
ITEM_PREFIX
+
c
for
c
in
ITEM_CATE_COLUMNS
]:
print
(
c
)
datas
=
samples
.
select
(
c
)
.
distinct
()
.
collect
()
datas
=
samples
.
select
(
c
)
.
distinct
()
.
collect
()
vocabSet
=
set
()
vocabSet
=
set
()
for
d
in
datas
:
for
d
in
datas
:
...
@@ -254,7 +256,6 @@ def getDataVocab(samples,model_columns):
...
@@ -254,7 +256,6 @@ def getDataVocab(samples,model_columns):
pass
pass
for
c
in
model_columns
:
for
c
in
model_columns
:
print
(
"col"
,
c
)
# 判断是否以Bucket结尾
# 判断是否以Bucket结尾
if
c
.
endswith
(
"Bucket"
):
if
c
.
endswith
(
"Bucket"
):
datas
=
samples
.
select
(
c
)
.
distinct
()
.
collect
()
datas
=
samples
.
select
(
c
)
.
distinct
()
.
collect
()
...
@@ -738,6 +739,7 @@ if __name__ == '__main__':
...
@@ -738,6 +739,7 @@ if __name__ == '__main__':
expDF
=
spark
.
sql
(
expSql
)
expDF
=
spark
.
sql
(
expSql
)
# ratingDF = samplesNegAndUnion(clickDF,expDF)
# ratingDF = samplesNegAndUnion(clickDF,expDF)
ratingDF
=
clickDF
.
union
(
expDF
)
ratingDF
=
clickDF
.
union
(
expDF
)
print
(
"pos size:"
+
str
(
clickDF
.
count
()),
"neg size:"
+
str
(
expDF
.
count
()))
ratingDF
=
ratingDF
.
withColumnRenamed
(
"time_stamp"
,
"timestamp"
)
\
ratingDF
=
ratingDF
.
withColumnRenamed
(
"time_stamp"
,
"timestamp"
)
\
.
withColumnRenamed
(
"device_id"
,
"userid"
)
\
.
withColumnRenamed
(
"device_id"
,
"userid"
)
\
...
...
train/train_service.py
View file @
fcfb12fe
...
@@ -20,7 +20,7 @@ one_hot_columns = ["item_"+c for c in ["service_type","doctor_type","doctor_famo
...
@@ -20,7 +20,7 @@ one_hot_columns = ["item_"+c for c in ["service_type","doctor_type","doctor_famo
# data_path_test = "/Users/zhigangzheng/Desktop/work/guoyu/service_sort/train/part-00000-a61205d1-ad4e-4fa7-895d-ad8db41189e6-c000.csv"
# data_path_test = "/Users/zhigangzheng/Desktop/work/guoyu/service_sort/train/part-00000-a61205d1-ad4e-4fa7-895d-ad8db41189e6-c000.csv"
VERSION
=
configUtils
.
SERVICE_VERSION
VERSION
=
configUtils
.
SERVICE_VERSION
trainDay
=
time
.
strftime
(
"
%
Y
%
m
%
d"
,
time
.
localtime
())
trainDay
=
time
.
strftime
(
"
%
Y
%
m
%
d
%
H
"
,
time
.
localtime
())
data_path_train
=
"/data/files/service_feature_{}_train.csv"
.
format
(
VERSION
)
data_path_train
=
"/data/files/service_feature_{}_train.csv"
.
format
(
VERSION
)
data_path_test
=
"/data/files/service_feature_{}_test.csv"
.
format
(
VERSION
)
data_path_test
=
"/data/files/service_feature_{}_test.csv"
.
format
(
VERSION
)
model_file
=
configUtils
.
SERVICE_MODEL_PATH
+
"/"
+
trainDay
model_file
=
configUtils
.
SERVICE_MODEL_PATH
+
"/"
+
trainDay
...
...
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