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
33149f28
Commit
33149f28
authored
3 years ago
by
宋柯
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
模型上线
parent
ffa71992
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
6 deletions
+10
-6
featureEngSk.py
spark/featureEngSk.py
+10
-6
No files found.
spark/featureEngSk.py
View file @
33149f28
...
...
@@ -1053,16 +1053,18 @@ def get_and_save_card_feature(itemEsFeatureDF, predictClickStaticFeatures, predi
itemFeatureDF
=
itemFeature
.
toPandas
()
conn
=
getRedisConn
()
BATCH
=
5000
Key
=
'strategy:model:rank:widedeep:service:feature
'
Key
_TMP
=
'strategy:model:rank:widedeep:service:feature:tmp
'
def
concat_service_feature
(
row
):
row
=
row
[
1
]
return
'|'
.
join
(
row
[
columns_used
]
.
astype
(
str
))
columns_used
=
list
(
filter
(
lambda
c
:
c
.
startswith
(
'ITEM_'
),
list
(
itemFeatureDF
.
columns
)))
print
(
'columns_used: '
,
columns_used
)
conn
.
delete
(
Key_TMP
)
for
start
in
range
(
0
,
len
(
itemFeatureDF
),
BATCH
):
conn
.
hmset
(
Key
,
{
row
[
1
][
'card_id'
]:
concat_service_feature
(
row
)
for
row
in
itemFeatureDF
.
iloc
[
start
:
start
+
BATCH
]
.
iterrows
()})
conn
.
hmset
(
Key_TMP
,
{
row
[
1
][
'card_id'
]:
concat_service_feature
(
row
)
for
row
in
itemFeatureDF
.
iloc
[
start
:
start
+
BATCH
]
.
iterrows
()})
Key
=
'strategy:model:rank:widedeep:service:feature'
conn
.
rename
(
Key_TMP
,
Key
)
def
get_and_save_device_feature
(
spark
,
fields_na_value_dict
,
days
=
180
):
...
...
@@ -1121,10 +1123,12 @@ def get_and_save_device_feature(spark, fields_na_value_dict, days = 180):
device_feature_df
=
device_feature_df
.
na
.
fill
(
fields_na_value_dict
)
conn
=
getRedisConn
()
BATCH
=
5000
Key
=
'strategy:model:rank:widedeep:device:feature'
Key_TMP
=
'strategy:model:rank:widedeep:device:feature:tmp'
conn
.
delete
(
Key_TMP
)
for
start
in
range
(
0
,
len
(
device_feature_df
),
BATCH
):
conn
.
hmset
(
Key
,
{
row
[
1
][
'device_id'
]:
row
[
1
][
'os'
]
for
row
in
device_feature_df
.
iloc
[
start
:
start
+
BATCH
]
.
iterrows
()})
conn
.
hmset
(
Key_TMP
,
{
row
[
1
][
'device_id'
]:
row
[
1
][
'os'
]
for
row
in
device_feature_df
.
iloc
[
start
:
start
+
BATCH
]
.
iterrows
()})
Key
=
'strategy:model:rank:widedeep:device:feature'
conn
.
rename
(
Key_TMP
,
Key
)
def
get_click_exp_rating_df
(
trainDays
,
spark
):
...
...
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