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
def BayesianMMM(splits="W"): | |
if splits == "Q": | |
time_series = pd.PeriodIndex(dates, freq='Q').astype(str).str[-1].astype(int).values | |
elif splits == "H": | |
time_series = pd.PeriodIndex(dates, freq='Q').astype(str).str[-1].map({'1':1, '2':1, '3':2, '4':2}).values | |
elif splits == "YoY": | |
time_series = np.array([1]*52 + [2]*52) | |
else: | |
time_series = np.arange(104) |
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 rfpimp import permutation_importances | |
from sklearn.base import clone | |
from sklearn.ensemble import RandomForestRegressor | |
from sklearn.metrics import r2_score | |
from sklearn.model_selection import train_test_split | |
import pandas as pd | |
def imp_df(column_names, importances): | |
data = { |
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 scipy.stats import beta | |
import numpy as np | |
from calc_prob import calc_prob_between | |
#This is the known data: imporessions and conversions for the Control and Test set | |
imps_ctrl,convs_ctrl=16500, 30 | |
imps_test, convs_test=17000, 50 | |
#here we create the Beta functions for the two sets | |
a_C, b_C = convs_ctrl+1, imps_ctrl-convs_ctrl+1 |
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
import numpy as np | |
import matplotlib.pyplot as plt | |
import scipy.stats as scs | |
def z_val(sig_level=0.05, two_tailed=True): | |
"""Returns the z value for a given significance level""" | |
z_dist = scs.norm() | |
if two_tailed: | |
sig_level = sig_level/2 | |
area = 1 - sig_level |