tea_tasting.metrics.nonparametric
#
Metrics for nonparametric analysis.
MannWhitneyU(column, *, alternative=None, correction=None, method='auto', nan_policy='propagate')
#
Bases: MetricBaseGranular[MannWhitneyUResult]
Metric for nonparametric analysis with the Mann-Whitney U test.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
column
|
str
|
Metric column name. |
required |
alternative
|
Literal['two-sided', 'greater', 'less'] | None
|
Alternative hypothesis:
|
None
|
correction
|
bool | None
|
Whether a continuity correction (1/2) should be applied.
Only for the asymptotic method.
Defaults to the global config value ( |
None
|
method
|
Literal['auto', 'asymptotic', 'exact']
|
Method used for p-value calculation:
|
'auto'
|
nan_policy
|
Literal['propagate', 'omit', 'raise']
|
Defines how to handle
|
'propagate'
|
Parameter defaults
Defaults for parameters alternative and correction can be changed using
the config_context and set_config functions.
See the Global configuration
reference for details.
Examples:
>>> import tea_tasting as tt
>>> data = tt.make_users_data(seed=42, n_users=1000)
>>> experiment = tt.Experiment(
... revenue_auc=tt.MannWhitneyU("revenue"),
... )
>>> result = experiment.analyze(data)
>>> result
metric control treatment rel_effect_size rel_effect_size_ci pvalue
revenue_auc 0.472 0.528 - [-, -] 0.0698
With specific alternative and method:
>>> experiment = tt.Experiment(
... revenue_auc=tt.MannWhitneyU(
... "revenue",
... alternative="greater",
... method="asymptotic",
... correction=False,
... ),
... )
>>> experiment.analyze(data)
metric control treatment rel_effect_size rel_effect_size_ci pvalue
revenue_auc 0.472 0.528 - [-, -] 0.0349
Source code in src/tea_tasting/metrics/nonparametric.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
cols
property
#
Columns to be fetched for a metric analysis.
analyze(data, control, treatment, variant=None)
#
Analyze a metric in an experiment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
IntoFrame | Table | dict[object, Table]
|
Experimental data. |
required |
control
|
object
|
Control variant. |
required |
treatment
|
object
|
Treatment variant. |
required |
variant
|
str | None
|
Variant column name. |
None
|
Returns:
| Type | Description |
|---|---|
MetricResultT
|
Analysis result. |
Source code in src/tea_tasting/metrics/base.py
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | |
analyze_granular(control, treatment)
#
Analyze a metric in an experiment using granular data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
control
|
Table
|
Control data. |
required |
treatment
|
Table
|
Treatment data. |
required |
Returns:
| Type | Description |
|---|---|
MannWhitneyUResult
|
Analysis result. |
Source code in src/tea_tasting/metrics/nonparametric.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | |
MannWhitneyUResult
#
Bases: NamedTuple
Result of the analysis using the Mann-Whitney U test.
Attributes:
| Name | Type | Description |
|---|---|---|
control |
float
|
ROC AUC for control. Probability that a value from control is greater than a value from treatment, plus half the probability that they are equal. |
treatment |
float
|
ROC AUC for treatment. Probability that a value from treatment is greater than a value from control, plus half the probability that they are equal. |
effect_size |
float
|
Absolute effect size. Difference between treatment and control ROC AUC values. |
pvalue |
float
|
P-value. |
statistic |
float
|
Mann-Whitney U statistic. |