This file contains hidden or 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
| """ | |
| # [+] PROJECT INFO | |
| # - Cox Proportional Hazard Regression model (Survival Analysis) | |
| # - Main purpose is to predict post-session conversion likelihood on customer level (cookie_id) | |
| # | |
| # Owner: Marnix Koops / marnixkoops@gmail.com | |
| """ | |
| # ================================================================================================== | |
| # [+] SETUP |
This file contains hidden or 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
| df = pd.concat( | |
| [ | |
| pd.read_csv(f) | |
| for f in glob.glob("./folder/*.csv") | |
| ], | |
| ignore_index=True, | |
| ) |
This file contains hidden or 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
| import logging | |
| logging.basicConfig( # logging to terminal & disk file | |
| level=logging.INFO, | |
| format="%(asctime)s [%(threadName)s] [%(levelname)s] %(message)s", | |
| handlers=[logging.FileHandler("logfile.log"), logging.StreamHandler()], | |
| ) | |
| logger = logging.getLogger() |
This file contains hidden or 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
| import numpy as np | |
| import pandas as pd | |
| import time | |
| import datetime | |
| import warnings | |
| import gc | |
| import tensorflow as tf | |
| from tensorflow import keras | |
| from tensorflow.python.client import device_lib |
This file contains hidden or 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
| def downcast_datatypes(df): | |
| float_cols = df.select_dtypes(include=['float']) | |
| int_cols = df.select_dtypes(include=['int']) | |
| for cols in float_cols.columns: | |
| df[cols] = pd.to_numeric(df[cols], downcast='float') | |
| for cols in int_cols.columns: | |
| df[cols] = pd.to_numeric(df[cols], downcast='integer') | |
| return df |
This file contains hidden or 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
| # %% markdown | |
| # WEER IMPACT | |
| # %% | |
| # SETUP | |
| import pandas as pd | |
| import numpy as np | |
| import pickle | |
| import matplotlib | |
| import matplotlib.pyplot as plt |
This file contains hidden or 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
| import pandas as pd | |
| import numpy as np | |
| from custom_code import timefold | |
| from sklearn import preprocessing | |
| def target_encoder(df, column, target, index=None, method='mean'): | |
| """ | |
| Target-based encoding is numerization of a categorical variables via the target variable. Main purpose is to deal |
This file contains hidden or 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
| # Group by product / timewindow and compute aggregate features | |
| print('[+] Generating weekly lagged product aggregation features ...') | |
| agg_week = demand_df.groupby(['product_id', 'year', 'weekofyear'])[ | |
| 'actual_raw'].agg(num_week_lag_aggregations) | |
| agg_week.columns = ["_week_lagged_".join(agg_feature) | |
| for agg_feature in agg_week.columns.ravel()] | |
| agg_week.reset_index(drop=False, inplace=True) | |
| print('[+] Generating monthly lagged product aggregation features ...') | |
| agg_month = demand_df.groupby(['product_id', 'year', 'month'])[ |
This file contains hidden or 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
| ############################################################################################ | |
| # [+] SETUP | |
| ############################################################################################ | |
| import numpy as np | |
| import pandas as pd | |
| import gc | |
| import glob | |
| import os |
This file contains hidden or 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
| # DARK | |
| jt -t onedork -f sourcemed -fs 10 -altp -tfs 11 -nfs 115 -cellw 80% -T | |
| # LIGHT | |
| jt -t grade3 -f sourcemed -fs 10 -altp -tfs 11 -nfs 115 -cellw 80% -T |
NewerOlder