Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
gm_strategy_cvr
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
rank
gm_strategy_cvr
Commits
77a9aa4a
Commit
77a9aa4a
authored
Sep 08, 2020
by
赵威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removet tractate service feature
parent
cc73abcc
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
44 deletions
+35
-44
tractate_fe.py
src/models/esmm/fe/tractate_fe.py
+22
-22
model.py
src/models/esmm/model.py
+2
-12
tractate_model.py
src/models/esmm/tractate_model.py
+9
-9
train_tractate.py
src/train_tractate.py
+2
-1
No files found.
src/models/esmm/fe/tractate_fe.py
View file @
77a9aa4a
...
@@ -116,15 +116,15 @@ TRACTATE_COLUMNS = [
...
@@ -116,15 +116,15 @@ TRACTATE_COLUMNS = [
"first_positions_num"
,
"first_positions_num"
,
"second_positions_num"
,
"second_positions_num"
,
"projects_num"
,
"projects_num"
,
"is_related_service"
,
#
"is_related_service",
"effect_second_skip_num"
,
#
"effect_second_skip_num",
"business_second_skip_num"
,
#
"business_second_skip_num",
"effect_second_skip_rate"
,
#
"effect_second_skip_rate",
"business_second_skip_rate"
,
#
"business_second_skip_rate",
"service_id"
,
#
"service_id",
"service_price"
,
#
"service_price",
"service_sold_num"
,
#
"service_sold_num",
"service_city"
,
#
"service_city",
# "recommend_service_id",
# "recommend_service_id",
# "recommend_service_city",
# "recommend_service_city",
# "recommend_service_price",
# "recommend_service_price",
...
@@ -197,10 +197,10 @@ INT_COLUMNS = [
...
@@ -197,10 +197,10 @@ INT_COLUMNS = [
"first_positions_num"
,
"first_positions_num"
,
"second_positions_num"
,
"second_positions_num"
,
"projects_num"
,
"projects_num"
,
"effect_second_skip_num"
,
#
"effect_second_skip_num",
"business_second_skip_num"
,
#
"business_second_skip_num",
"service_price"
,
#
"service_price",
"service_sold_num"
,
#
"service_sold_num",
]
]
FLOAT_COLUMNS
=
[
FLOAT_COLUMNS
=
[
"one_ctr"
,
"one_ctr"
,
...
@@ -235,8 +235,8 @@ FLOAT_COLUMNS = [
...
@@ -235,8 +235,8 @@ FLOAT_COLUMNS = [
"sixty_browse_duration_avg"
,
"sixty_browse_duration_avg"
,
"ninety_browse_duration_avg"
,
"ninety_browse_duration_avg"
,
"history_browse_duration_avg"
,
"history_browse_duration_avg"
,
"effect_second_skip_rate"
,
#
"effect_second_skip_rate",
"business_second_skip_rate"
,
#
"business_second_skip_rate",
]
]
CATEGORICAL_COLUMNS
=
[
CATEGORICAL_COLUMNS
=
[
"device_id"
,
"device_id"
,
...
@@ -290,9 +290,9 @@ CATEGORICAL_COLUMNS = [
...
@@ -290,9 +290,9 @@ CATEGORICAL_COLUMNS = [
"click_tractate_id3"
,
"click_tractate_id3"
,
"click_tractate_id4"
,
"click_tractate_id4"
,
"click_tractate_id5"
,
"click_tractate_id5"
,
"is_related_service"
,
#
"is_related_service",
"service_id"
,
#
"service_id",
"service_city"
,
#
"service_city",
# "recommend_service_id",
# "recommend_service_id",
# "recommend_service_city",
# "recommend_service_city",
# "recommend_service_price",
# "recommend_service_price",
...
@@ -408,13 +408,13 @@ def tractate_feature_engineering(tractate_df):
...
@@ -408,13 +408,13 @@ def tractate_feature_engineering(tractate_df):
df
[
"is_have_reply"
]
=
df
[
"is_have_reply"
]
.
astype
(
int
)
df
[
"is_have_reply"
]
=
df
[
"is_have_reply"
]
.
astype
(
int
)
df
[
"show_tag_id"
]
=
df
[
"show_tag_id"
]
.
astype
(
str
)
df
[
"show_tag_id"
]
=
df
[
"show_tag_id"
]
.
astype
(
str
)
df
[
"is_related_service"
]
=
df
[
"is_related_service"
]
.
astype
(
int
)
#
df["is_related_service"] = df["is_related_service"].astype(int)
df
[
"service_id"
]
=
df
[
"service_id"
]
.
astype
(
str
)
#
df["service_id"] = df["service_id"].astype(str)
# df["recommend_service_id"] = df["recommend_service_id"].astype(str)
# df["recommend_service_id"] = df["recommend_service_id"].astype(str)
# df["recommend_service_price"] = df["recommend_service_price"].astype(str)
# df["recommend_service_price"] = df["recommend_service_price"].astype(str)
df
[
"service_id"
]
=
df
[
"service_city
"
]
.
fillna
(
"-1"
)
# df["service_id"] = df["service_id
"].fillna("-1")
df
[
"service_city"
]
=
df
[
"service_city"
]
.
fillna
(
""
)
#
df["service_city"] = df["service_city"].fillna("")
# df["recommend_service_id"] = df["recommend_service_id"].fillna("-1")
# df["recommend_service_id"] = df["recommend_service_id"].fillna("-1")
# df["recommend_service_city"] = df["recommend_service_city"].fillna("")
# df["recommend_service_city"] = df["recommend_service_city"].fillna("")
...
...
src/models/esmm/model.py
View file @
77a9aa4a
...
@@ -28,18 +28,8 @@ def esmm_model_fn(features, labels, mode, params):
...
@@ -28,18 +28,8 @@ def esmm_model_fn(features, labels, mode, params):
cvr_logits
=
tf
.
layers
.
dense
(
last_cvr_layer
,
units
=
head
.
logits_dimension
,
kernel_initializer
=
tf
.
glorot_uniform_initializer
())
cvr_logits
=
tf
.
layers
.
dense
(
last_cvr_layer
,
units
=
head
.
logits_dimension
,
kernel_initializer
=
tf
.
glorot_uniform_initializer
())
ctr_preds
=
tf
.
sigmoid
(
ctr_logits
)
ctr_preds
=
tf
.
sigmoid
(
ctr_logits
)
cvr_preds
=
tf
.
sigmoid
(
cvr_logits
)
cvr_preds
=
tf
.
sigmoid
(
cvr_logits
)
ctcvr_preds
=
tf
.
multiply
(
ctr_preds
,
cvr_preds
)
# ctcvr_preds = tf.multiply(ctr_preds, cvr_preds)
print
(
"@@@@@@@@@@@"
)
ctcvr_preds
=
tf
.
multiply
(
tf
.
multiply
(
0.8
,
ctr_preds
),
tf
.
multiply
(
0.2
,
cvr_preds
))
print
(
ctr_logits
)
print
(
ctr_preds
)
print
(
ctcvr_preds
)
print
(
"@@@@@@@@@@@"
)
a
=
tf
.
multiply
(
0.8
,
ctr_preds
)
b
=
tf
.
multiply
(
0.2
,
cvr_preds
)
c
=
tf
.
multiply
(
a
,
b
)
print
(
a
)
print
(
c
)
print
(
"@@@@@@@@@@@"
)
# optimizer = tf.compat.v1.train.AdamOptimizer()
# optimizer = tf.compat.v1.train.AdamOptimizer()
# click_label = features["click_label"]
# click_label = features["click_label"]
...
...
src/models/esmm/tractate_model.py
View file @
77a9aa4a
...
@@ -78,11 +78,11 @@ _int_columns = [
...
@@ -78,11 +78,11 @@ _int_columns = [
"first_positions_num"
,
"first_positions_num"
,
"second_positions_num"
,
"second_positions_num"
,
"projects_num"
,
"projects_num"
,
"is_related_service"
,
#
"is_related_service",
"effect_second_skip_num"
,
#
"effect_second_skip_num",
"business_second_skip_num"
,
#
"business_second_skip_num",
"service_price"
,
#
"service_price",
"service_sold_num"
,
#
"service_sold_num",
]
]
_float_columns
=
[
_float_columns
=
[
"one_ctr"
,
"one_ctr"
,
...
@@ -117,8 +117,8 @@ _float_columns = [
...
@@ -117,8 +117,8 @@ _float_columns = [
"sixty_browse_duration_avg"
,
"sixty_browse_duration_avg"
,
"ninety_browse_duration_avg"
,
"ninety_browse_duration_avg"
,
"history_browse_duration_avg"
,
"history_browse_duration_avg"
,
"effect_second_skip_rate"
,
#
"effect_second_skip_rate",
"business_second_skip_rate"
,
#
"business_second_skip_rate",
]
]
_categorical_columns
=
[
_categorical_columns
=
[
"device_id"
,
"device_id"
,
...
@@ -166,8 +166,8 @@ _categorical_columns = [
...
@@ -166,8 +166,8 @@ _categorical_columns = [
"click_tractate_id3"
,
"click_tractate_id3"
,
"click_tractate_id4"
,
"click_tractate_id4"
,
"click_tractate_id5"
,
"click_tractate_id5"
,
"service_id"
,
#
"service_id",
"service_city"
,
#
"service_city",
# "recommend_service_id",
# "recommend_service_id",
# "recommend_service_city",
# "recommend_service_city",
# "recommend_service_price",
# "recommend_service_price",
...
...
src/train_tractate.py
View file @
77a9aa4a
...
@@ -62,7 +62,8 @@ def main():
...
@@ -62,7 +62,8 @@ def main():
estimator_config
=
tf
.
estimator
.
RunConfig
(
session_config
=
session_config
)
estimator_config
=
tf
.
estimator
.
RunConfig
(
session_config
=
session_config
)
model
=
tf
.
estimator
.
Estimator
(
model_fn
=
esmm_model_fn
,
params
=
params
,
model_dir
=
model_path
,
config
=
estimator_config
)
model
=
tf
.
estimator
.
Estimator
(
model_fn
=
esmm_model_fn
,
params
=
params
,
model_dir
=
model_path
,
config
=
estimator_config
)
train_spec
=
tf
.
estimator
.
TrainSpec
(
input_fn
=
lambda
:
esmm_input_fn
(
train_df
,
shuffle
=
True
),
max_steps
=
45000
)
# TODO 45000
train_spec
=
tf
.
estimator
.
TrainSpec
(
input_fn
=
lambda
:
esmm_input_fn
(
train_df
,
shuffle
=
True
),
max_steps
=
12000
)
eval_spec
=
tf
.
estimator
.
EvalSpec
(
input_fn
=
lambda
:
esmm_input_fn
(
val_df
,
shuffle
=
False
))
eval_spec
=
tf
.
estimator
.
EvalSpec
(
input_fn
=
lambda
:
esmm_input_fn
(
val_df
,
shuffle
=
False
))
res
=
tf
.
estimator
.
train_and_evaluate
(
model
,
train_spec
,
eval_spec
)
res
=
tf
.
estimator
.
train_and_evaluate
(
model
,
train_spec
,
eval_spec
)
print
(
"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
)
print
(
"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
)
...
...
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