Skip to content

Commit

Permalink
add decile for ltv and purchase propensity (#78)
Browse files Browse the repository at this point in the history
* add decile for ltv and purchase propensity

* fix terraform version conflict
  • Loading branch information
kingman authored Feb 14, 2024
1 parent a8287e5 commit 4476d4b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion infrastructure/terraform/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "~> 4.49.0"
version = ">= 4.49.0"
}
}

Expand Down
10 changes: 7 additions & 3 deletions sql/procedure/aggregate_predictions_procedure.sqlx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ SELECT
a.prediction as ltv,
a.user_pseudo_id,
a.processed_timestamp,
a.feature_date as ltv_Feature_date,
a.feature_date as ltv_feature_date,
NTILE(10) OVER (ORDER BY a.prediction DESC) AS ltv_decile,
coalesce(a.month_of_the_year,b.month_of_the_year) as month_of_the_year,
coalesce(a.week_of_the_year,b.week_of_the_year) as week_of_the_year,
coalesce(a.day_of_week,b.day_of_week) as day_of_week,
Expand Down Expand Up @@ -121,7 +122,8 @@ a.checkouts_past_150_180_day,
b.prediction as likely_to_purchase,
b.prediction_prob as propensity_score,
b.processed_timestamp as propensity_processed_timestamp,
b.feature_date as propensity_feature_date ,
b.feature_date as propensity_feature_date,
NTILE(10) OVER (ORDER BY b.prediction_prob DESC) AS p_p_decile,
b.user_ltv_revenue,
b.engagement_rate,
b.engaged_sessions_per_user,
Expand Down Expand Up @@ -244,8 +246,9 @@ CREATE OR REPLACE TABLE `{{project_id}}.{{dataset_id}}.{{table_id}}` AS
SELECT
c.user_pseudo_id,
c.ltv,
c.ltv_decile,
c.processed_timestamp as ltv_processed_timestamp,
c.ltv_Feature_date,
c.ltv_feature_date,
c.month_of_the_year,
c.week_of_the_year,
coalesce(c.day_of_week,d.day_of_week) as day_of_week,
Expand Down Expand Up @@ -308,6 +311,7 @@ SELECT
c.checkouts_past_150_180_day,
c.likely_to_purchase,
c.propensity_score,
c.p_p_decile,
c.propensity_processed_timestamp,
c.propensity_feature_date,
c.user_ltv_revenue,
Expand Down
10 changes: 9 additions & 1 deletion sql/schema/table/aggregated_predictions_latest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@
"name": "ltv",
"type": "FLOAT"
},
{
"name": "ltv_decile",
"type": "INTEGER"
},
{
"name": "ltv_processed_timestamp",
"type": "TIMESTAMP"
},
{
"name": "ltv_Feature_date",
"name": "ltv_feature_date",
"type": "DATE"
},
{
Expand Down Expand Up @@ -263,6 +267,10 @@
"name": "propensity_score",
"type": "FLOAT"
},
{
"name": "p_p_decile",
"type": "INTEGER"
},
{
"name": "propensity_processed_timestamp",
"type": "TIMESTAMP"
Expand Down

0 comments on commit 4476d4b

Please sign in to comment.