Custom metrics
This guide will show you how to automatically add custom metrics to your model from code using the Python SDK.
To add new custom metrics:
conversion_rate = aporia.CustomMetric(
"Conversion Rate",
code="""
count(filter="purchased=TRUE") / count()
""",
)
model_revenue = aporia.CustomMetric(
"Model Revenue",
code="""
sum(
column="candidate_item_price",
filter="purchased=TRUE AND ranking_index<=4"
) / count()*2
""",
)
In this example, we're adding two new custom metrics - conversion rate and model revenue. To add the custom metrics to your model, pass them to the model object:
model = aporia.Model(
"My Model",
type=aporia.ModelType.RANKING,
versions=[model_version],
segments=[platform_segment, country_segments],
custom_metrics=[conversion_rate, model_revenue]
)