Skip to main content

Markov Model Feat Python Code

Python

#Load library and data

import pandas as pd

from ChannelAttributionPro import *

import urllib.request

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

#Set your password

password="yourpassword"

#Define the type of each feature: 'categorial' or 'numeric'

D_feat_types={'region':'categorial','segment':'categorial','seconds_to_last_touch':'numeric','position':'categorial'}

#Train Markov model with external features

res=markov_model_feat(Data,D_feat_types,server="http://app.channelattribution.io",password=password)

#Return transaction-level attribution

print(res["attribution"])

#Return estimated weigths for each feature at path level

print(res["weights_attr"])

#Return predictive performance of each feature

print(res["weights_feat"])