tea_tasting.datasets
#
Example datasets.
make_users_data(*, covariates=False, seed=None, n_users=4000, ratio=1, sessions_uplift=0.0, orders_uplift=0.1, revenue_uplift=0.1, avg_sessions=2, avg_orders_per_session=0.25, avg_revenue_per_order=10, to_ibis=False)
#
Generate simulated data for A/B testing scenarios.
Data mimics what you might encounter in an A/B test for an online store, with a user-level randomization. Each row represents an individual user with information about:
user
: User identifier.variant
: Variant of the test. 0 is control, 1 is treatment.sessions
: Number of user's sessions.orders
: Number of user's orders.revenue
: Revenue generated by the user.
Optionally, pre-experimental data can be generated as well:
sessions_covariate
: Number of user's sessions before the experiment.orders_covariate
: Number of user's orders before the experiment.revenue_covariate
: Revenue generated by the user before the experiment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
covariates |
bool
|
If |
False
|
seed |
int | Generator | SeedSequence | None
|
Random seed. |
None
|
n_users |
int
|
Number of users. |
4000
|
ratio |
float | int
|
Ratio of the number of users in treatment relative to control. |
1
|
sessions_uplift |
float | int
|
Sessions uplift in the treatment variant, relative to control. |
0.0
|
orders_uplift |
float
|
Orders uplift in the treatment variant, relative to control. |
0.1
|
revenue_uplift |
float
|
Revenue uplift in the treatment variant, relative to control. |
0.1
|
avg_sessions |
float | int
|
Average number of sessions per user. |
2
|
avg_orders_per_session |
float
|
Average number of orders per session.
Should be less than |
0.25
|
avg_revenue_per_order |
float | int
|
Average revenue per order. |
10
|
to_ibis |
bool
|
If set to |
False
|
Returns:
Type | Description |
---|---|
Table | DataFrame
|
Simulated data for A/B testing scenarios. |
Examples:
import tea_tasting as tt
data = tt.make_users_data(seed=42)
data
#> user variant sessions orders revenue
#> 0 0 1 2 1 9.166147
#> 1 1 0 2 1 6.434079
#> 2 2 1 2 1 7.943873
#> 3 3 1 2 1 15.928675
#> 4 4 0 1 1 7.136917
#> ... ... ... ... ... ...
#> 3995 3995 0 2 0 0.000000
#> 3996 3996 0 2 0 0.000000
#> 3997 3997 0 3 0 0.000000
#> 3998 3998 0 1 0 0.000000
#> 3999 3999 0 5 2 17.162459
#>
#> [4000 rows x 5 columns]
With covariates:
data = tt.make_users_data(seed=42, covariates=True)
data
#> user variant sessions orders revenue sessions_covariate orders_covariate revenue_covariate
#> 0 0 1 2 1 9.166147 3 2 19.191712
#> 1 1 0 2 1 6.434079 4 1 2.770749
#> 2 2 1 2 1 7.943873 4 2 22.568422
#> 3 3 1 2 1 15.928675 1 0 0.000000
#> 4 4 0 1 1 7.136917 1 1 13.683796
#> ... ... ... ... ... ... ... ... ...
#> 3995 3995 0 2 0 0.000000 1 0 0.000000
#> 3996 3996 0 2 0 0.000000 3 1 13.517967
#> 3997 3997 0 3 0 0.000000 2 0 0.000000
#> 3998 3998 0 1 0 0.000000 1 0 0.000000
#> 3999 3999 0 5 2 17.162459 5 0 0.000000
#>
#> [4000 rows x 8 columns]
Source code in src/tea_tasting/datasets.py
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 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
|
make_sessions_data(*, covariates=False, seed=None, n_users=4000, ratio=1, sessions_uplift=0.0, orders_uplift=0.1, revenue_uplift=0.1, avg_sessions=2, avg_orders_per_session=0.25, avg_revenue_per_order=10, to_ibis=False)
#
Generate simulated user data for A/B testing scenarios.
Data mimics what you might encounter in an A/B test for an online store, with a user-level randomization. Each row represents a user's session with information about:
user
: User identifier.variant
: Variant of the test. 0 is control, 1 is treatment.sessions
: Number of user's sessions.orders
: Number of user's orders.revenue
: Revenue generated by the user.
Optionally, pre-experimental data can be generated as well:
sessions_covariate
: Number of user's sessions before the experiment.orders_covariate
: Number of user's orders before the experiment.revenue_covariate
: Revenue generated by the user before the experiment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
covariates |
bool
|
If |
False
|
seed |
int | Generator | SeedSequence | None
|
Random seed. |
None
|
n_users |
int
|
Number of users. |
4000
|
ratio |
float | int
|
Ratio of the number of users in treatment relative to control. |
1
|
sessions_uplift |
float | int
|
Sessions uplift in the treatment variant, relative to control. |
0.0
|
orders_uplift |
float
|
Orders uplift in the treatment variant, relative to control. |
0.1
|
revenue_uplift |
float
|
Revenue uplift in the treatment variant, relative to control. |
0.1
|
avg_sessions |
float | int
|
Average number of sessions per user. |
2
|
avg_orders_per_session |
float
|
Average number of orders per session.
Should be less than |
0.25
|
avg_revenue_per_order |
float | int
|
Average revenue per order. |
10
|
to_ibis |
bool
|
If set to |
False
|
Returns:
Type | Description |
---|---|
Table | DataFrame
|
Simulated data for A/B testing scenarios. |
Examples:
import tea_tasting as tt
data = tt.make_sessions_data(seed=42)
data
#> user variant sessions orders revenue
#> 0 0 1 1 1 5.887178
#> 1 0 1 1 1 6.131080
#> 2 1 0 1 1 2.614675
#> 3 1 0 1 1 12.296075
#> 4 2 1 1 1 11.573409
#> ... ... ... ... ... ...
#> 7953 3999 0 1 1 23.634941
#> 7954 3999 0 1 0 0.000000
#> 7955 3999 0 1 1 2.396078
#> 7956 3999 0 1 1 24.538111
#> 7957 3999 0 1 0 0.000000
#>
#> [7958 rows x 5 columns]
With covariates:
data = tt.make_sessions_data(seed=42, covariates=True)
data
#> user variant sessions orders revenue sessions_covariate orders_covariate revenue_covariate
#> 0 0 1 1 1 5.887178 1.5 0.5 1.236732
#> 1 0 1 1 1 6.131080 1.5 0.5 1.236732
#> 2 1 0 1 1 2.614675 0.0 0.0 0.000000
#> 3 1 0 1 1 12.296075 0.0 0.0 0.000000
#> 4 2 1 1 1 11.573409 1.5 1.5 12.324434
#> ... ... ... ... ... ... ... ... ...
#> 7953 3999 0 1 1 23.634941 0.2 0.0 0.000000
#> 7954 3999 0 1 0 0.000000 0.2 0.0 0.000000
#> 7955 3999 0 1 1 2.396078 0.2 0.0 0.000000
#> 7956 3999 0 1 1 24.538111 0.2 0.0 0.000000
#> 7957 3999 0 1 0 0.000000 0.2 0.0 0.000000
#>
#> [7958 rows x 8 columns]
Source code in src/tea_tasting/datasets.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
|