This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
now = datetime.now() | |
start = now.replace(day=1, hour=0, minute=0, second=0, microsecond=0) | |
start = start + timedelta(days=31) | |
stop = start + timedelta(days=30 * 36) | |
synth_certs = pd.DataFrame() | |
for dt in rrule.rrule(rrule.MONTHLY, dtstart=start, until=stop): | |
#THE SEASONALITY CURVE IS MEASURED (in SQL) DIRECTLY FROM OUR DATA | |
cohort_size = ( | |
cert_ramp_seasonality_df[ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
now = datetime.now() | |
start = now.replace(day=1, hour=0, minute=0, second=0, microsecond=0) | |
start = start + timedelta(days=31) | |
stop = start + timedelta(days=30 * 36) | |
synth_certs = pd.DataFrame() | |
for dt in rrule.rrule(rrule.MONTHLY, dtstart=start, until=stop): | |
#THE SEASONALITY CURVE IS MEASURED (in SQL) DIRECTLY FROM OUR DATA | |
cohort_size = ( | |
cert_ramp_seasonality_df[ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
now = datetime.now() | |
start = now.replace(day=1, hour=0, minute=0, second=0, microsecond=0) | |
start = start + timedelta(days=31) | |
stop = start + timedelta(days=30 * 36) | |
synth_certs = pd.DataFrame() | |
for dt in rrule.rrule(rrule.MONTHLY, dtstart=start, until=stop): | |
#THE SEASONALITY CURVE IS MEASURED (in SQL) DIRECTLY FROM OUR DATA | |
cohort_size = ( | |
cert_ramp_seasonality_df[ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
lease_dim_id, | |
reporting_month AS simulated_default_month | |
FROM | |
( | |
-- | |
SELECT | |
*, | |
ROW_NUMBER() OVER(PARTITION BY certificate_dim_id ORDER BY (RANDOM() * COALESCE(perc_losses_expected+in_month,0)) DESC) AS rnk | |
FROM ll_fact_lease_ts ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
now = datetime.now() | |
start = now.replace(day=1, hour=0, minute=0, second=0, microsecond=0) | |
start = start + timedelta(days=31) | |
stop = start + timedelta(days=30 * 36) | |
synth_certs = pd.DataFrame() | |
for dt in rrule.rrule(rrule.MONTHLY, dtstart=start, until=stop): | |
#THE SEASONALITY CURVE IS MEASURED (in SQL) DIRECTLY FROM OUR DATA | |
cohort_size = ( | |
cert_ramp_seasonality_df[ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH month_0 AS | |
( | |
SELECT user_id, | |
metric_a | |
FROM analytics_table | |
WHERE execution_date = < month_0 > | |
), | |
month_1 AS | |
( | |
SELECT user_id, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH transaction AS ( | |
SELECT transaction_id, | |
customer_id, | |
state, | |
amount_spent_usd | |
FROM FACT_TABLE_TRANSACTION | |
), | |
customer_spend AS ( | |
SELECT customer_id, | |
state, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH transaction AS ( | |
SELECT transaction_id, | |
customer_id, | |
state, | |
amount_spent_usd | |
FROM < FACT_TABLE_TRANSACTION > | |
), | |
customer_spend AS ( | |
SELECT customer_id, | |
state, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from airflow.models import Variable | |
from airflow import DAG | |
from airflow.operators.python_operator import PythonOperator | |
def train_model(lookback_days=30: int): | |
""" | |
Trains a model using data from the past <lookback_days> and persists to a model store | |
""" | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from airflow.models import Variable | |
from airflow import DAG | |
from airflow.operators.python_operator import PythonOperator | |
MODEL_ENTRY_POINT = "customer_model.py" | |
# This dynamic configuration mechanism is not ideal but makes for an easy demo | |
model_version = Variable.get("model_version") |
OlderNewer