Skip to main content
Version: 3.19.1

uam

Python

import pandas as pd
from ChannelAttributionPro import uam

token = "yourtoken"

df_aggr = pd.read_csv("https://app.channelattribution.pro/data/data_aggregated.csv", sep=";")

D_variables = {
"conversions": "target",
"A": "channel_a",
"B": "channel_b",
"C": "channel_c",
"D": "channel_d",
"E": "channel_e",
"F": "channel_f"
}

D_measures = {
"A": "clicks",
"B": "impressions",
"C": "impressions",
"D": "clicks",
"E": "clicks",
"F": "clicks"
}

Aggregated-data attribution without customer journey paths:

res = uam(
df_aggr=df_aggr,
D_variables=D_variables,
D_measures=D_measures,
df_paths=None,
max_p=12,
nsim=1000,
seed=1234567,
verbose=1,
password=token
)

print(res)

With already aggregated customer journey paths:

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

res = uam(
df_aggr=df_aggr,
D_variables=D_variables,
D_measures=D_measures,
df_paths=df_paths,
var_path="path",
var_conv="total_conversions",
var_null="total_null",
order=1,
sep=">",
verbose=1,
password=token
)

print(res)

With event-level customer journey paths:

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

res = uam(
df_aggr=df_aggr,
D_variables=D_variables,
D_measures=D_measures,
df_paths=df_paths,
channel_conv="((CONV))",
order=1,
sep=">",
verbose=1,
password=token
)

print(res)

In the last example, df_paths is an event-level customer journey table with columns such as id_path, timestamp, and channel.
The conversion marker is identified by channel_conv="((CONV))". The function internally converts the event-level journeys into aggregated paths before combining the aggregated attribution baseline with the journey-based Markov layer.