Skip to main content

compare_models Python Code

Python

#Load library and data

import pandas as pd

from ChannelAttributionPro import *

import matplotlib.pyplot as plt

df_paths = pd.read_csv("https://app.channelattribution.io/data/Data.csv",sep=";")

password="yourpassword"

#Compare MTA models

res=compare_models(df_paths,var_path="path",var_conv="total_conversions",
var_null="total_null",cha_sep=">",perc_reall=0.1,perc_sample=0.10,
max_nsim=10000,min_perc_traffic=0.005,niter=30,flg_extra_path=1,
max_markov_order=4,seed=1234567,verbose=1,
server="app.channelattribution.io",password=password)

res["performance"].columns=res["performance"].columns.str.replace('markov_model_order','markov_m_order')
fig=res["performance"].boxplot()
plt.rcParams["figure.figsize"] = (10,12)
plt.title('Simulated Conversion Rate')
plt.show()

#Compare MTA models and Reward model (UAM)

df_paths = pd.read_csv("https://app.channelattribution.io/data/data_paths_2.csv",sep=";")

df_ctr = pd.read_csv("https://app.channelattribution.io/data/data_ctr_2.csv",sep=";")

res=compare_models(df_paths=df_paths,df_ctr=df_ctr,channel_conv_name="((CONV))",perc_reall=0.1,perc_sample=0.10,
max_nsim=10000,min_perc_traffic=0.005,niter=30,flg_extra_path=1,max_markov_order=4,seed=1234567,verbose=1, server="app.channelattribution.io",password=password)

res["performance"].columns=res["performance"].columns.str.replace('markov_model_order','markov_m_order')
fig=res["performance"].boxplot()
plt.rcParams["figure.figsize"] = (10,12)
plt.title('Simulated Conversion Rate')
plt.show()