Skip to content

Issues with Ratio metrics analysis #231

Open
@tbikeeva

Description

@tbikeeva

Hi team! I think I spotted a bug: when using Ration metrics for experiment analysis, it looks like it's not taking into account denominator values when computing ATE and p-value for the scorecard. See screen below:

Image

This is how the metrics were defined:

...
metric__cm_total = SimpleMetric(
    alias='CM TOTAL',
    name='cm_total'
)

metric__cm_delivered = SimpleMetric(
    alias='CM DELIVERED',
    name='cm_delivered'
)

 metric__cm = RatioMetric(
     alias='CM PER ORDER',
     numerator_name='cm_delivered',
     denominator_name='delivered_orders'
 )
...

And this is how they were analyzed:

analysis_plan_config = [
    (metric__cm_total, 'ols', customer_level_metrics),
    (metric__cm_delivered, 'ols', customer_level_metrics.query("delivered_orders>0")),
    (metric__cm, 'ols', customer_level_metrics.query("delivered_orders>0")),
]

widget_scorecards = AnalysisPlanResults()

for metric, analysis_type, df in analysis_plan_config:
    analysis_config = {"cluster_cols": ["customer_id"]} if analysis_type == 'clustered_ols' else None

    analysis_plan = AnalysisPlan.from_metrics(
        metrics=[metric],
        variants=variants,
        variant_col='experiment_variant',
        alpha=0.05,
        analysis_type=analysis_type,
        analysis_config=analysis_config,
    )

    results = analysis_plan.analyze(exp_data=df, verbose=True)

    widget_scorecards += results

widget_scorecards.to_dataframe()

When calculating this metric on customer level and then running a simple metric test, I get very different results:

Image

Let me know if you need any additional data or queries, thank you!

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions