Files
PHANTOM/experiments/notebooks/step_breakdown.ipynb
2026-02-27 12:45:46 +01:00

2321 lines
84 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"id": "d6bc6a6d-2454-4222-a1ed-1b06bb7b95d1",
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"from pathlib import Path\n",
"project_root = \"/home/velocitatem/Documents/Projects/PHANTOM/experiments\"\n",
"if str(Path.cwd().parent if 'notebooks' in str(Path.cwd()) else Path.cwd()) not in sys.path:\n",
" sys.path.insert(0, str(project_root))"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "6926d0a1-02f2-47c1-b927-6b5bd28ae8cc",
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "a48f6ab9-46bf-4553-8489-f5ecb58f8d7c",
"metadata": {},
"outputs": [],
"source": [
"from procesing.steps import (\n",
" FetchInteractionsStep,\n",
" FetchPriceLogsStep,\n",
" FetchExperimentsStep,\n",
" JoinExperimentsStep,\n",
" CreatePriceBucketsStep,\n",
" AugmentEventNamesStep,\n",
" ChunkByTimeWindowStep,\n",
" ComputeDemandForChunksStep,\n",
" AggregatePriceLogsStep,\n",
" ComputeElasticityStep,\n",
" FitPricingFunctionStep,\n",
" PredictPricesStep,\n",
")\n",
"from procesing.context import PipelineContext\n",
"from procesing.providers import SupabaseProvider, BackendAPIProvider"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "bb7ebdfb-432e-4cf6-b0ee-dc030107ebc5",
"metadata": {},
"outputs": [],
"source": [
"class Provider(SupabaseProvider, BackendAPIProvider):\n",
" def __init__(self, backend_url: str):\n",
" SupabaseProvider.__init__(self)\n",
" BackendAPIProvider.__init__(self, backend_url=backend_url)\n",
"# example run\n",
"context = PipelineContext(\n",
" provider=Provider(backend_url=\"http://localhost:5000\"),\n",
" store_mode='hotel',\n",
" window_size='15min',\n",
"\n",
")\n"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "587b1fdc-30f4-4ee0-b603-7a54b8bed5eb",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>sessionId</th>\n",
" <th>experimentId</th>\n",
" <th>eventName</th>\n",
" <th>page</th>\n",
" <th>productId</th>\n",
" <th>storeMode</th>\n",
" <th>userAgent</th>\n",
" <th>ts</th>\n",
" <th>metadata_referrer</th>\n",
" <th>metadata_elementText</th>\n",
" <th>metadata_dateIndex</th>\n",
" <th>metadata_dwellTime</th>\n",
" <th>metadata_type</th>\n",
" <th>metadata_roomType</th>\n",
" <th>metadata_price</th>\n",
" <th>metadata_nights</th>\n",
" <th>metadata_total</th>\n",
" <th>metadata_itemCount</th>\n",
" <th>dateIndex</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>d423ce8a-77aa-4c9a-94d4-d1adddcc3472</td>\n",
" <td>None</td>\n",
" <td>page_view</td>\n",
" <td>/</td>\n",
" <td>None</td>\n",
" <td>hotel</td>\n",
" <td>Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...</td>\n",
" <td>2025-11-25T20:20:13.061Z</td>\n",
" <td></td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>&lt;NA&gt;</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>d423ce8a-77aa-4c9a-94d4-d1adddcc3472</td>\n",
" <td>None</td>\n",
" <td>hover_over_title</td>\n",
" <td>/hotel/products</td>\n",
" <td>d018efc1-25e9-4284-b276-80386e048b25</td>\n",
" <td>hotel</td>\n",
" <td>Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...</td>\n",
" <td>2025-11-25T20:21:17.425Z</td>\n",
" <td>NaN</td>\n",
" <td>Junior Suite</td>\n",
" <td>1.0</td>\n",
" <td>1200.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>d423ce8a-77aa-4c9a-94d4-d1adddcc3472</td>\n",
" <td>None</td>\n",
" <td>hover_over_paragraph</td>\n",
" <td>/hotel/products</td>\n",
" <td>d018efc1-25e9-4284-b276-80386e048b25</td>\n",
" <td>hotel</td>\n",
" <td>Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...</td>\n",
" <td>2025-11-25T20:21:19.496Z</td>\n",
" <td>NaN</td>\n",
" <td>price</td>\n",
" <td>1.0</td>\n",
" <td>1202.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>d423ce8a-77aa-4c9a-94d4-d1adddcc3472</td>\n",
" <td>None</td>\n",
" <td>page_view</td>\n",
" <td>/hotel/products/d018efc1-25e9-4284-b276-80386e...</td>\n",
" <td>None</td>\n",
" <td>hotel</td>\n",
" <td>Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...</td>\n",
" <td>2025-11-25T20:21:21.922Z</td>\n",
" <td>http://localhost:3000/hotel/products?dateIndex...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>&lt;NA&gt;</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>d423ce8a-77aa-4c9a-94d4-d1adddcc3472</td>\n",
" <td>None</td>\n",
" <td>learn_more_about_item</td>\n",
" <td>/hotel/products/d018efc1-25e9-4284-b276-80386e...</td>\n",
" <td>d018efc1-25e9-4284-b276-80386e048b25</td>\n",
" <td>hotel</td>\n",
" <td>Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...</td>\n",
" <td>2025-11-25T20:21:22.674Z</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>1.0</td>\n",
" <td>NaN</td>\n",
" <td>hotel</td>\n",
" <td>Junior Suite</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" sessionId experimentId eventName \\\n",
"0 d423ce8a-77aa-4c9a-94d4-d1adddcc3472 None page_view \n",
"1 d423ce8a-77aa-4c9a-94d4-d1adddcc3472 None hover_over_title \n",
"2 d423ce8a-77aa-4c9a-94d4-d1adddcc3472 None hover_over_paragraph \n",
"3 d423ce8a-77aa-4c9a-94d4-d1adddcc3472 None page_view \n",
"4 d423ce8a-77aa-4c9a-94d4-d1adddcc3472 None learn_more_about_item \n",
"\n",
" page \\\n",
"0 / \n",
"1 /hotel/products \n",
"2 /hotel/products \n",
"3 /hotel/products/d018efc1-25e9-4284-b276-80386e... \n",
"4 /hotel/products/d018efc1-25e9-4284-b276-80386e... \n",
"\n",
" productId storeMode \\\n",
"0 None hotel \n",
"1 d018efc1-25e9-4284-b276-80386e048b25 hotel \n",
"2 d018efc1-25e9-4284-b276-80386e048b25 hotel \n",
"3 None hotel \n",
"4 d018efc1-25e9-4284-b276-80386e048b25 hotel \n",
"\n",
" userAgent \\\n",
"0 Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck... \n",
"1 Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck... \n",
"2 Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck... \n",
"3 Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck... \n",
"4 Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck... \n",
"\n",
" ts \\\n",
"0 2025-11-25T20:20:13.061Z \n",
"1 2025-11-25T20:21:17.425Z \n",
"2 2025-11-25T20:21:19.496Z \n",
"3 2025-11-25T20:21:21.922Z \n",
"4 2025-11-25T20:21:22.674Z \n",
"\n",
" metadata_referrer metadata_elementText \\\n",
"0 NaN \n",
"1 NaN Junior Suite \n",
"2 NaN price \n",
"3 http://localhost:3000/hotel/products?dateIndex... NaN \n",
"4 NaN NaN \n",
"\n",
" metadata_dateIndex metadata_dwellTime metadata_type metadata_roomType \\\n",
"0 NaN NaN NaN NaN \n",
"1 1.0 1200.0 NaN NaN \n",
"2 1.0 1202.0 NaN NaN \n",
"3 NaN NaN NaN NaN \n",
"4 1.0 NaN hotel Junior Suite \n",
"\n",
" metadata_price metadata_nights metadata_total metadata_itemCount \\\n",
"0 NaN NaN NaN NaN \n",
"1 NaN NaN NaN NaN \n",
"2 NaN NaN NaN NaN \n",
"3 NaN NaN NaN NaN \n",
"4 NaN NaN NaN NaN \n",
"\n",
" dateIndex \n",
"0 <NA> \n",
"1 1 \n",
"2 1 \n",
"3 <NA> \n",
"4 1 "
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df=FetchInteractionsStep(context).transform(None)\n",
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "45022876-30d9-4607-a10f-932df9b4dbda",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>sessionId</th>\n",
" <th>experimentId</th>\n",
" <th>eventName</th>\n",
" <th>page</th>\n",
" <th>productId</th>\n",
" <th>storeMode</th>\n",
" <th>userAgent</th>\n",
" <th>ts</th>\n",
" <th>metadata_referrer</th>\n",
" <th>metadata_elementText</th>\n",
" <th>metadata_dateIndex</th>\n",
" <th>metadata_dwellTime</th>\n",
" <th>metadata_type</th>\n",
" <th>metadata_roomType</th>\n",
" <th>metadata_price</th>\n",
" <th>metadata_nights</th>\n",
" <th>metadata_total</th>\n",
" <th>metadata_itemCount</th>\n",
" <th>dateIndex</th>\n",
" <th>price_bucket</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>d423ce8a-77aa-4c9a-94d4-d1adddcc3472</td>\n",
" <td>None</td>\n",
" <td>page_view</td>\n",
" <td>/</td>\n",
" <td>None</td>\n",
" <td>hotel</td>\n",
" <td>Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...</td>\n",
" <td>2025-11-25T20:20:13.061Z</td>\n",
" <td></td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>&lt;NA&gt;</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>d423ce8a-77aa-4c9a-94d4-d1adddcc3472</td>\n",
" <td>None</td>\n",
" <td>hover_over_title</td>\n",
" <td>/hotel/products</td>\n",
" <td>d018efc1-25e9-4284-b276-80386e048b25</td>\n",
" <td>hotel</td>\n",
" <td>Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...</td>\n",
" <td>2025-11-25T20:21:17.425Z</td>\n",
" <td>NaN</td>\n",
" <td>Junior Suite</td>\n",
" <td>1.0</td>\n",
" <td>1200.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>1</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>d423ce8a-77aa-4c9a-94d4-d1adddcc3472</td>\n",
" <td>None</td>\n",
" <td>hover_over_paragraph</td>\n",
" <td>/hotel/products</td>\n",
" <td>d018efc1-25e9-4284-b276-80386e048b25</td>\n",
" <td>hotel</td>\n",
" <td>Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...</td>\n",
" <td>2025-11-25T20:21:19.496Z</td>\n",
" <td>NaN</td>\n",
" <td>price</td>\n",
" <td>1.0</td>\n",
" <td>1202.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>1</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>d423ce8a-77aa-4c9a-94d4-d1adddcc3472</td>\n",
" <td>None</td>\n",
" <td>page_view</td>\n",
" <td>/hotel/products/d018efc1-25e9-4284-b276-80386e...</td>\n",
" <td>None</td>\n",
" <td>hotel</td>\n",
" <td>Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...</td>\n",
" <td>2025-11-25T20:21:21.922Z</td>\n",
" <td>http://localhost:3000/hotel/products?dateIndex...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>&lt;NA&gt;</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>d423ce8a-77aa-4c9a-94d4-d1adddcc3472</td>\n",
" <td>None</td>\n",
" <td>learn_more_about_item</td>\n",
" <td>/hotel/products/d018efc1-25e9-4284-b276-80386e...</td>\n",
" <td>d018efc1-25e9-4284-b276-80386e048b25</td>\n",
" <td>hotel</td>\n",
" <td>Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...</td>\n",
" <td>2025-11-25T20:21:22.674Z</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>1.0</td>\n",
" <td>NaN</td>\n",
" <td>hotel</td>\n",
" <td>Junior Suite</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>1</td>\n",
" <td></td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" sessionId experimentId eventName \\\n",
"0 d423ce8a-77aa-4c9a-94d4-d1adddcc3472 None page_view \n",
"1 d423ce8a-77aa-4c9a-94d4-d1adddcc3472 None hover_over_title \n",
"2 d423ce8a-77aa-4c9a-94d4-d1adddcc3472 None hover_over_paragraph \n",
"3 d423ce8a-77aa-4c9a-94d4-d1adddcc3472 None page_view \n",
"4 d423ce8a-77aa-4c9a-94d4-d1adddcc3472 None learn_more_about_item \n",
"\n",
" page \\\n",
"0 / \n",
"1 /hotel/products \n",
"2 /hotel/products \n",
"3 /hotel/products/d018efc1-25e9-4284-b276-80386e... \n",
"4 /hotel/products/d018efc1-25e9-4284-b276-80386e... \n",
"\n",
" productId storeMode \\\n",
"0 None hotel \n",
"1 d018efc1-25e9-4284-b276-80386e048b25 hotel \n",
"2 d018efc1-25e9-4284-b276-80386e048b25 hotel \n",
"3 None hotel \n",
"4 d018efc1-25e9-4284-b276-80386e048b25 hotel \n",
"\n",
" userAgent \\\n",
"0 Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck... \n",
"1 Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck... \n",
"2 Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck... \n",
"3 Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck... \n",
"4 Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck... \n",
"\n",
" ts \\\n",
"0 2025-11-25T20:20:13.061Z \n",
"1 2025-11-25T20:21:17.425Z \n",
"2 2025-11-25T20:21:19.496Z \n",
"3 2025-11-25T20:21:21.922Z \n",
"4 2025-11-25T20:21:22.674Z \n",
"\n",
" metadata_referrer metadata_elementText \\\n",
"0 NaN \n",
"1 NaN Junior Suite \n",
"2 NaN price \n",
"3 http://localhost:3000/hotel/products?dateIndex... NaN \n",
"4 NaN NaN \n",
"\n",
" metadata_dateIndex metadata_dwellTime metadata_type metadata_roomType \\\n",
"0 NaN NaN NaN NaN \n",
"1 1.0 1200.0 NaN NaN \n",
"2 1.0 1202.0 NaN NaN \n",
"3 NaN NaN NaN NaN \n",
"4 1.0 NaN hotel Junior Suite \n",
"\n",
" metadata_price metadata_nights metadata_total metadata_itemCount \\\n",
"0 NaN NaN NaN NaN \n",
"1 NaN NaN NaN NaN \n",
"2 NaN NaN NaN NaN \n",
"3 NaN NaN NaN NaN \n",
"4 NaN NaN NaN NaN \n",
"\n",
" dateIndex price_bucket \n",
"0 <NA> \n",
"1 1 \n",
"2 1 \n",
"3 <NA> \n",
"4 1 "
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df = CreatePriceBucketsStep(context).transform(df)\n",
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "720b9631-4350-425a-ad29-ded745ce28f9",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>sessionId</th>\n",
" <th>experimentId</th>\n",
" <th>eventName</th>\n",
" <th>page</th>\n",
" <th>productId</th>\n",
" <th>storeMode</th>\n",
" <th>userAgent</th>\n",
" <th>ts</th>\n",
" <th>metadata_referrer</th>\n",
" <th>metadata_elementText</th>\n",
" <th>...</th>\n",
" <th>metadata_dwellTime</th>\n",
" <th>metadata_type</th>\n",
" <th>metadata_roomType</th>\n",
" <th>metadata_price</th>\n",
" <th>metadata_nights</th>\n",
" <th>metadata_total</th>\n",
" <th>metadata_itemCount</th>\n",
" <th>dateIndex</th>\n",
" <th>price_bucket</th>\n",
" <th>metadata_schema</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>78</th>\n",
" <td>c404dbe5-116f-42c0-b199-503516dbbe91</td>\n",
" <td>fd01774c-f629-4bcb-88b8-c818856af72a</td>\n",
" <td>page_view</td>\n",
" <td>/hotel/products</td>\n",
" <td>None</td>\n",
" <td>hotel</td>\n",
" <td>Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/53...</td>\n",
" <td>2025-11-29T17:32:45.064Z</td>\n",
" <td></td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>&lt;NA&gt;</td>\n",
" <td></td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>79</th>\n",
" <td>c404dbe5-116f-42c0-b199-503516dbbe91</td>\n",
" <td>fd01774c-f629-4bcb-88b8-c818856af72a</td>\n",
" <td>page_view</td>\n",
" <td>/hotel/products</td>\n",
" <td>None</td>\n",
" <td>hotel</td>\n",
" <td>Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/53...</td>\n",
" <td>2025-11-29T18:13:53.858Z</td>\n",
" <td></td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>&lt;NA&gt;</td>\n",
" <td></td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>80</th>\n",
" <td>d423ce8a-77aa-4c9a-94d4-d1adddcc3472</td>\n",
" <td>53aefd07-f66a-4d7f-ba8b-7ea1fc562d35</td>\n",
" <td>page_view</td>\n",
" <td>/hotel/products</td>\n",
" <td>None</td>\n",
" <td>hotel</td>\n",
" <td>Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...</td>\n",
" <td>2025-12-04T11:13:15.884Z</td>\n",
" <td></td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>&lt;NA&gt;</td>\n",
" <td></td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>81</th>\n",
" <td>d423ce8a-77aa-4c9a-94d4-d1adddcc3472</td>\n",
" <td>53aefd07-f66a-4d7f-ba8b-7ea1fc562d35</td>\n",
" <td>page_view</td>\n",
" <td>/hotel/products</td>\n",
" <td>None</td>\n",
" <td>hotel</td>\n",
" <td>Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...</td>\n",
" <td>2025-12-04T11:18:53.473Z</td>\n",
" <td></td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>&lt;NA&gt;</td>\n",
" <td></td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>82</th>\n",
" <td>d423ce8a-77aa-4c9a-94d4-d1adddcc3472</td>\n",
" <td>53aefd07-f66a-4d7f-ba8b-7ea1fc562d35</td>\n",
" <td>page_view</td>\n",
" <td>/hotel/products</td>\n",
" <td>None</td>\n",
" <td>hotel</td>\n",
" <td>Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...</td>\n",
" <td>2025-12-04T11:19:05.094Z</td>\n",
" <td></td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>&lt;NA&gt;</td>\n",
" <td></td>\n",
" <td></td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>5 rows × 21 columns</p>\n",
"</div>"
],
"text/plain": [
" sessionId \\\n",
"78 c404dbe5-116f-42c0-b199-503516dbbe91 \n",
"79 c404dbe5-116f-42c0-b199-503516dbbe91 \n",
"80 d423ce8a-77aa-4c9a-94d4-d1adddcc3472 \n",
"81 d423ce8a-77aa-4c9a-94d4-d1adddcc3472 \n",
"82 d423ce8a-77aa-4c9a-94d4-d1adddcc3472 \n",
"\n",
" experimentId eventName page \\\n",
"78 fd01774c-f629-4bcb-88b8-c818856af72a page_view /hotel/products \n",
"79 fd01774c-f629-4bcb-88b8-c818856af72a page_view /hotel/products \n",
"80 53aefd07-f66a-4d7f-ba8b-7ea1fc562d35 page_view /hotel/products \n",
"81 53aefd07-f66a-4d7f-ba8b-7ea1fc562d35 page_view /hotel/products \n",
"82 53aefd07-f66a-4d7f-ba8b-7ea1fc562d35 page_view /hotel/products \n",
"\n",
" productId storeMode userAgent \\\n",
"78 None hotel Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/53... \n",
"79 None hotel Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/53... \n",
"80 None hotel Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck... \n",
"81 None hotel Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck... \n",
"82 None hotel Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck... \n",
"\n",
" ts metadata_referrer metadata_elementText ... \\\n",
"78 2025-11-29T17:32:45.064Z NaN ... \n",
"79 2025-11-29T18:13:53.858Z NaN ... \n",
"80 2025-12-04T11:13:15.884Z NaN ... \n",
"81 2025-12-04T11:18:53.473Z NaN ... \n",
"82 2025-12-04T11:19:05.094Z NaN ... \n",
"\n",
" metadata_dwellTime metadata_type metadata_roomType metadata_price \\\n",
"78 NaN NaN NaN NaN \n",
"79 NaN NaN NaN NaN \n",
"80 NaN NaN NaN NaN \n",
"81 NaN NaN NaN NaN \n",
"82 NaN NaN NaN NaN \n",
"\n",
" metadata_nights metadata_total metadata_itemCount dateIndex \\\n",
"78 NaN NaN NaN <NA> \n",
"79 NaN NaN NaN <NA> \n",
"80 NaN NaN NaN <NA> \n",
"81 NaN NaN NaN <NA> \n",
"82 NaN NaN NaN <NA> \n",
"\n",
" price_bucket metadata_schema \n",
"78 \n",
"79 \n",
"80 \n",
"81 \n",
"82 \n",
"\n",
"[5 rows x 21 columns]"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df = AugmentEventNamesStep(context).transform(df)\n",
"df.tail()"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "9c6add1a-147a-4086-a437-3f47f17d69bb",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>productId</th>\n",
" <th>price</th>\n",
" <th>sessionId</th>\n",
" <th>experimentId</th>\n",
" <th>storeMode</th>\n",
" <th>ts</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>213</th>\n",
" <td>2cd7f756-fc65-4ba0-ab01-74521c1fff43</td>\n",
" <td>100.0</td>\n",
" <td>d423ce8a-77aa-4c9a-94d4-d1adddcc3472</td>\n",
" <td>None</td>\n",
" <td>hotel</td>\n",
" <td>2025-12-04T11:18:56.320Z</td>\n",
" </tr>\n",
" <tr>\n",
" <th>214</th>\n",
" <td>2ddabbfc-4127-48fc-86dc-ebc4c677efa2</td>\n",
" <td>100.0</td>\n",
" <td>d423ce8a-77aa-4c9a-94d4-d1adddcc3472</td>\n",
" <td>None</td>\n",
" <td>hotel</td>\n",
" <td>2025-12-04T11:19:05.434Z</td>\n",
" </tr>\n",
" <tr>\n",
" <th>215</th>\n",
" <td>2cd7f756-fc65-4ba0-ab01-74521c1fff43</td>\n",
" <td>100.0</td>\n",
" <td>d423ce8a-77aa-4c9a-94d4-d1adddcc3472</td>\n",
" <td>None</td>\n",
" <td>hotel</td>\n",
" <td>2025-12-04T11:19:05.338Z</td>\n",
" </tr>\n",
" <tr>\n",
" <th>216</th>\n",
" <td>2cd7f756-fc65-4ba0-ab01-74521c1fff43</td>\n",
" <td>100.0</td>\n",
" <td>d423ce8a-77aa-4c9a-94d4-d1adddcc3472</td>\n",
" <td>None</td>\n",
" <td>hotel</td>\n",
" <td>2025-12-04T11:19:05.597Z</td>\n",
" </tr>\n",
" <tr>\n",
" <th>217</th>\n",
" <td>2ddabbfc-4127-48fc-86dc-ebc4c677efa2</td>\n",
" <td>100.0</td>\n",
" <td>d423ce8a-77aa-4c9a-94d4-d1adddcc3472</td>\n",
" <td>None</td>\n",
" <td>hotel</td>\n",
" <td>2025-12-04T11:19:05.594Z</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" productId price \\\n",
"213 2cd7f756-fc65-4ba0-ab01-74521c1fff43 100.0 \n",
"214 2ddabbfc-4127-48fc-86dc-ebc4c677efa2 100.0 \n",
"215 2cd7f756-fc65-4ba0-ab01-74521c1fff43 100.0 \n",
"216 2cd7f756-fc65-4ba0-ab01-74521c1fff43 100.0 \n",
"217 2ddabbfc-4127-48fc-86dc-ebc4c677efa2 100.0 \n",
"\n",
" sessionId experimentId storeMode \\\n",
"213 d423ce8a-77aa-4c9a-94d4-d1adddcc3472 None hotel \n",
"214 d423ce8a-77aa-4c9a-94d4-d1adddcc3472 None hotel \n",
"215 d423ce8a-77aa-4c9a-94d4-d1adddcc3472 None hotel \n",
"216 d423ce8a-77aa-4c9a-94d4-d1adddcc3472 None hotel \n",
"217 d423ce8a-77aa-4c9a-94d4-d1adddcc3472 None hotel \n",
"\n",
" ts \n",
"213 2025-12-04T11:18:56.320Z \n",
"214 2025-12-04T11:19:05.434Z \n",
"215 2025-12-04T11:19:05.338Z \n",
"216 2025-12-04T11:19:05.597Z \n",
"217 2025-12-04T11:19:05.594Z "
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"price_df=FetchPriceLogsStep(context).fit_transform(None)\n",
"price_df.tail()"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "28c3d101-8e82-46c3-aa06-765bd2799177",
"metadata": {},
"outputs": [],
"source": [
"df_chunks = ChunkByTimeWindowStep(context).transform(df)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "9f1e4005-a1ed-423e-ad55-cc00a18ac10b",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"11"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(df_chunks)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "f427318c-c4d3-448a-9b02-f5f71ef15f5c",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Timestamp('2025-12-04 11:15:00+0000', tz='UTC')"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_chunks[-1]['window_start']"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "fc87a9cc-30f0-460d-a13d-b61f7bf83fab",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Timestamp('2025-12-04 11:30:00+0000', tz='UTC')"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_chunks[-1]['window_end']"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "2d850541-47f5-4cd5-8777-ca526645a39b",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>sessionId</th>\n",
" <th>experimentId</th>\n",
" <th>eventName</th>\n",
" <th>page</th>\n",
" <th>productId</th>\n",
" <th>storeMode</th>\n",
" <th>userAgent</th>\n",
" <th>ts</th>\n",
" <th>metadata_referrer</th>\n",
" <th>metadata_elementText</th>\n",
" <th>...</th>\n",
" <th>metadata_dwellTime</th>\n",
" <th>metadata_type</th>\n",
" <th>metadata_roomType</th>\n",
" <th>metadata_price</th>\n",
" <th>metadata_nights</th>\n",
" <th>metadata_total</th>\n",
" <th>metadata_itemCount</th>\n",
" <th>dateIndex</th>\n",
" <th>price_bucket</th>\n",
" <th>metadata_schema</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>81</th>\n",
" <td>d423ce8a-77aa-4c9a-94d4-d1adddcc3472</td>\n",
" <td>53aefd07-f66a-4d7f-ba8b-7ea1fc562d35</td>\n",
" <td>page_view</td>\n",
" <td>/hotel/products</td>\n",
" <td>None</td>\n",
" <td>hotel</td>\n",
" <td>Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...</td>\n",
" <td>2025-12-04 11:18:53.473000+00:00</td>\n",
" <td></td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>&lt;NA&gt;</td>\n",
" <td></td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>82</th>\n",
" <td>d423ce8a-77aa-4c9a-94d4-d1adddcc3472</td>\n",
" <td>53aefd07-f66a-4d7f-ba8b-7ea1fc562d35</td>\n",
" <td>page_view</td>\n",
" <td>/hotel/products</td>\n",
" <td>None</td>\n",
" <td>hotel</td>\n",
" <td>Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...</td>\n",
" <td>2025-12-04 11:19:05.094000+00:00</td>\n",
" <td></td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>&lt;NA&gt;</td>\n",
" <td></td>\n",
" <td></td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>2 rows × 21 columns</p>\n",
"</div>"
],
"text/plain": [
" sessionId \\\n",
"81 d423ce8a-77aa-4c9a-94d4-d1adddcc3472 \n",
"82 d423ce8a-77aa-4c9a-94d4-d1adddcc3472 \n",
"\n",
" experimentId eventName page \\\n",
"81 53aefd07-f66a-4d7f-ba8b-7ea1fc562d35 page_view /hotel/products \n",
"82 53aefd07-f66a-4d7f-ba8b-7ea1fc562d35 page_view /hotel/products \n",
"\n",
" productId storeMode userAgent \\\n",
"81 None hotel Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck... \n",
"82 None hotel Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck... \n",
"\n",
" ts metadata_referrer metadata_elementText \\\n",
"81 2025-12-04 11:18:53.473000+00:00 NaN \n",
"82 2025-12-04 11:19:05.094000+00:00 NaN \n",
"\n",
" ... metadata_dwellTime metadata_type metadata_roomType metadata_price \\\n",
"81 ... NaN NaN NaN NaN \n",
"82 ... NaN NaN NaN NaN \n",
"\n",
" metadata_nights metadata_total metadata_itemCount dateIndex \\\n",
"81 NaN NaN NaN <NA> \n",
"82 NaN NaN NaN <NA> \n",
"\n",
" price_bucket metadata_schema \n",
"81 \n",
"82 \n",
"\n",
"[2 rows x 21 columns]"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_chunks[-1]['data'].head()"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "eda09da8-324b-4af9-971c-d366d8b870d8",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"11"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"demand = ComputeDemandForChunksStep(context).transform(df_chunks)\n",
"len(demand)"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "bd2d40ce-6f51-42a8-8849-cc1a4479f4d9",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>productId</th>\n",
" <th>demand_score</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>bec37f41-7756-47ae-9219-f5854290f4e7</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>5e666c06-023a-415b-9976-be0956bbc405</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>d018efc1-25e9-4284-b276-80386e048b25</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>2cd7f756-fc65-4ba0-ab01-74521c1fff43</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>51266ddb-5b07-47b7-89ee-5b5cae94bb11</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>79</th>\n",
" <td>0d1c9a3a-bc37-4417-a59f-de4b994944cb</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>80</th>\n",
" <td>fc64bd74-4dfa-4f78-802a-39d6aa4c39fe</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>81</th>\n",
" <td>d85d4c52-baa0-435f-81ac-b0c27a5251b3</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>82</th>\n",
" <td>93bc00e5-8cfe-42af-8322-49bc27407688</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>83</th>\n",
" <td>18cc01db-55cc-42a5-aab5-e3ec448548d8</td>\n",
" <td>0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>84 rows × 2 columns</p>\n",
"</div>"
],
"text/plain": [
" productId demand_score\n",
"0 bec37f41-7756-47ae-9219-f5854290f4e7 0\n",
"1 5e666c06-023a-415b-9976-be0956bbc405 0\n",
"2 d018efc1-25e9-4284-b276-80386e048b25 0\n",
"3 2cd7f756-fc65-4ba0-ab01-74521c1fff43 0\n",
"4 51266ddb-5b07-47b7-89ee-5b5cae94bb11 0\n",
".. ... ...\n",
"79 0d1c9a3a-bc37-4417-a59f-de4b994944cb 0\n",
"80 fc64bd74-4dfa-4f78-802a-39d6aa4c39fe 0\n",
"81 d85d4c52-baa0-435f-81ac-b0c27a5251b3 0\n",
"82 93bc00e5-8cfe-42af-8322-49bc27407688 0\n",
"83 18cc01db-55cc-42a5-aab5-e3ec448548d8 0\n",
"\n",
"[84 rows x 2 columns]"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"demand[-1]['demand_vector']"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "20293a35-c0a8-416e-bfb9-178883f4ca5f",
"metadata": {},
"outputs": [],
"source": [
"price_df_agg = AggregatePriceLogsStep(context).transform(price_df)"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "bf378587-f5ef-431b-a1c2-663124b5e42b",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>productId</th>\n",
" <th>price</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>2cd7f756-fc65-4ba0-ab01-74521c1fff43</td>\n",
" <td>100.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2ddabbfc-4127-48fc-86dc-ebc4c677efa2</td>\n",
" <td>100.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>51266ddb-5b07-47b7-89ee-5b5cae94bb11</td>\n",
" <td>100.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>d018efc1-25e9-4284-b276-80386e048b25</td>\n",
" <td>100.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>aaae8177-0803-4421-8702-f3ffeeeadcd9</td>\n",
" <td>389.04</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>7f71fbe2-343c-4a46-94ea-07cbd903a86c</td>\n",
" <td>327.94</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>d6affcb8-6616-47f8-af14-2ec8583f0781</td>\n",
" <td>391.43</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>0fbcf915-ecf1-4ec3-9b00-8bbc314e2a81</td>\n",
" <td>900.97</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>eceedfb3-ec52-4453-9aab-88dd9a6b6ca3</td>\n",
" <td>640.54</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" productId price\n",
"0 2cd7f756-fc65-4ba0-ab01-74521c1fff43 100.00\n",
"1 2ddabbfc-4127-48fc-86dc-ebc4c677efa2 100.00\n",
"2 51266ddb-5b07-47b7-89ee-5b5cae94bb11 100.00\n",
"3 d018efc1-25e9-4284-b276-80386e048b25 100.00\n",
"4 aaae8177-0803-4421-8702-f3ffeeeadcd9 389.04\n",
"5 7f71fbe2-343c-4a46-94ea-07cbd903a86c 327.94\n",
"6 d6affcb8-6616-47f8-af14-2ec8583f0781 391.43\n",
"7 0fbcf915-ecf1-4ec3-9b00-8bbc314e2a81 900.97\n",
"8 eceedfb3-ec52-4453-9aab-88dd9a6b6ca3 640.54"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"price_df_agg[-1]['price_vector']"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "d05f003a-9537-49f6-a814-118e80cd8748",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>productId</th>\n",
" <th>elasticity</th>\n",
" <th>std_error</th>\n",
" <th>n_obs</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>d018efc1-25e9-4284-b276-80386e048b25</td>\n",
" <td>-0.222054</td>\n",
" <td>0.447102</td>\n",
" <td>11</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2cd7f756-fc65-4ba0-ab01-74521c1fff43</td>\n",
" <td>-0.072857</td>\n",
" <td>0.510130</td>\n",
" <td>11</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>51266ddb-5b07-47b7-89ee-5b5cae94bb11</td>\n",
" <td>-0.291083</td>\n",
" <td>0.346879</td>\n",
" <td>11</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>2ddabbfc-4127-48fc-86dc-ebc4c677efa2</td>\n",
" <td>-10.223968</td>\n",
" <td>0.000000</td>\n",
" <td>11</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>7f71fbe2-343c-4a46-94ea-07cbd903a86c</td>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" <td>9</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>79</th>\n",
" <td>0d1c9a3a-bc37-4417-a59f-de4b994944cb</td>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>80</th>\n",
" <td>fc64bd74-4dfa-4f78-802a-39d6aa4c39fe</td>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>81</th>\n",
" <td>d85d4c52-baa0-435f-81ac-b0c27a5251b3</td>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>82</th>\n",
" <td>93bc00e5-8cfe-42af-8322-49bc27407688</td>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>83</th>\n",
" <td>18cc01db-55cc-42a5-aab5-e3ec448548d8</td>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" <td>0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>84 rows × 4 columns</p>\n",
"</div>"
],
"text/plain": [
" productId elasticity std_error n_obs\n",
"0 d018efc1-25e9-4284-b276-80386e048b25 -0.222054 0.447102 11\n",
"1 2cd7f756-fc65-4ba0-ab01-74521c1fff43 -0.072857 0.510130 11\n",
"2 51266ddb-5b07-47b7-89ee-5b5cae94bb11 -0.291083 0.346879 11\n",
"3 2ddabbfc-4127-48fc-86dc-ebc4c677efa2 -10.223968 0.000000 11\n",
"4 7f71fbe2-343c-4a46-94ea-07cbd903a86c 0.000000 0.000000 9\n",
".. ... ... ... ...\n",
"79 0d1c9a3a-bc37-4417-a59f-de4b994944cb 0.000000 0.000000 0\n",
"80 fc64bd74-4dfa-4f78-802a-39d6aa4c39fe 0.000000 0.000000 0\n",
"81 d85d4c52-baa0-435f-81ac-b0c27a5251b3 0.000000 0.000000 0\n",
"82 93bc00e5-8cfe-42af-8322-49bc27407688 0.000000 0.000000 0\n",
"83 18cc01db-55cc-42a5-aab5-e3ec448548d8 0.000000 0.000000 0\n",
"\n",
"[84 rows x 4 columns]"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"elasticity = ComputeElasticityStep(context).transform((demand, price_df_agg))\n",
"elasticity"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "926cd9ea-8f6b-43b5-95a5-8fdf5309e1bd",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>elasticity</th>\n",
" <th>std_error</th>\n",
" <th>n_obs</th>\n",
" </tr>\n",
" <tr>\n",
" <th>productId</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>d018efc1-25e9-4284-b276-80386e048b25</th>\n",
" <td>-0.222054</td>\n",
" <td>0.447102</td>\n",
" <td>11</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2cd7f756-fc65-4ba0-ab01-74521c1fff43</th>\n",
" <td>-0.072857</td>\n",
" <td>0.510130</td>\n",
" <td>11</td>\n",
" </tr>\n",
" <tr>\n",
" <th>51266ddb-5b07-47b7-89ee-5b5cae94bb11</th>\n",
" <td>-0.291083</td>\n",
" <td>0.346879</td>\n",
" <td>11</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2ddabbfc-4127-48fc-86dc-ebc4c677efa2</th>\n",
" <td>-10.223968</td>\n",
" <td>0.000000</td>\n",
" <td>11</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7f71fbe2-343c-4a46-94ea-07cbd903a86c</th>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" <td>9</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0d1c9a3a-bc37-4417-a59f-de4b994944cb</th>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>fc64bd74-4dfa-4f78-802a-39d6aa4c39fe</th>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>d85d4c52-baa0-435f-81ac-b0c27a5251b3</th>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>93bc00e5-8cfe-42af-8322-49bc27407688</th>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18cc01db-55cc-42a5-aab5-e3ec448548d8</th>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" <td>0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>84 rows × 3 columns</p>\n",
"</div>"
],
"text/plain": [
" elasticity std_error n_obs\n",
"productId \n",
"d018efc1-25e9-4284-b276-80386e048b25 -0.222054 0.447102 11\n",
"2cd7f756-fc65-4ba0-ab01-74521c1fff43 -0.072857 0.510130 11\n",
"51266ddb-5b07-47b7-89ee-5b5cae94bb11 -0.291083 0.346879 11\n",
"2ddabbfc-4127-48fc-86dc-ebc4c677efa2 -10.223968 0.000000 11\n",
"7f71fbe2-343c-4a46-94ea-07cbd903a86c 0.000000 0.000000 9\n",
"... ... ... ...\n",
"0d1c9a3a-bc37-4417-a59f-de4b994944cb 0.000000 0.000000 0\n",
"fc64bd74-4dfa-4f78-802a-39d6aa4c39fe 0.000000 0.000000 0\n",
"d85d4c52-baa0-435f-81ac-b0c27a5251b3 0.000000 0.000000 0\n",
"93bc00e5-8cfe-42af-8322-49bc27407688 0.000000 0.000000 0\n",
"18cc01db-55cc-42a5-aab5-e3ec448548d8 0.000000 0.000000 0\n",
"\n",
"[84 rows x 3 columns]"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"elasticity.set_index('productId')"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "bfa8a023-24da-4b3a-bafb-b174e54bf3b0",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"RangeIndex: 84 entries, 0 to 83\n",
"Data columns (total 4 columns):\n",
" # Column Non-Null Count Dtype \n",
"--- ------ -------------- ----- \n",
" 0 productId 84 non-null object \n",
" 1 elasticity 84 non-null float64\n",
" 2 std_error 84 non-null float64\n",
" 3 n_obs 84 non-null int64 \n",
"dtypes: float64(2), int64(1), object(1)\n",
"memory usage: 2.8+ KB\n"
]
}
],
"source": [
"elasticity.info()"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "5a8823da-da7a-41e4-8166-399538c80a73",
"metadata": {},
"outputs": [],
"source": [
"df['productId'] = df['productId'].astype(str)\n",
"elasticity['productId'] = elasticity['productId'].astype(str)\n",
"dff=df.join(elasticity.set_index('productId'), how=\"left\", on=\"productId\")"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "e5d1639b-768b-4217-8821-ee09bb3e60c2",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>sessionId</th>\n",
" <th>experimentId</th>\n",
" <th>eventName</th>\n",
" <th>page</th>\n",
" <th>productId</th>\n",
" <th>storeMode</th>\n",
" <th>userAgent</th>\n",
" <th>ts</th>\n",
" <th>metadata_referrer</th>\n",
" <th>metadata_elementText</th>\n",
" <th>...</th>\n",
" <th>metadata_price</th>\n",
" <th>metadata_nights</th>\n",
" <th>metadata_total</th>\n",
" <th>metadata_itemCount</th>\n",
" <th>dateIndex</th>\n",
" <th>price_bucket</th>\n",
" <th>metadata_schema</th>\n",
" <th>elasticity</th>\n",
" <th>std_error</th>\n",
" <th>n_obs</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>78</th>\n",
" <td>c404dbe5-116f-42c0-b199-503516dbbe91</td>\n",
" <td>fd01774c-f629-4bcb-88b8-c818856af72a</td>\n",
" <td>page_view</td>\n",
" <td>/hotel/products</td>\n",
" <td>None</td>\n",
" <td>hotel</td>\n",
" <td>Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/53...</td>\n",
" <td>2025-11-29T17:32:45.064Z</td>\n",
" <td></td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>&lt;NA&gt;</td>\n",
" <td></td>\n",
" <td></td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>79</th>\n",
" <td>c404dbe5-116f-42c0-b199-503516dbbe91</td>\n",
" <td>fd01774c-f629-4bcb-88b8-c818856af72a</td>\n",
" <td>page_view</td>\n",
" <td>/hotel/products</td>\n",
" <td>None</td>\n",
" <td>hotel</td>\n",
" <td>Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/53...</td>\n",
" <td>2025-11-29T18:13:53.858Z</td>\n",
" <td></td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>&lt;NA&gt;</td>\n",
" <td></td>\n",
" <td></td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>80</th>\n",
" <td>d423ce8a-77aa-4c9a-94d4-d1adddcc3472</td>\n",
" <td>53aefd07-f66a-4d7f-ba8b-7ea1fc562d35</td>\n",
" <td>page_view</td>\n",
" <td>/hotel/products</td>\n",
" <td>None</td>\n",
" <td>hotel</td>\n",
" <td>Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...</td>\n",
" <td>2025-12-04T11:13:15.884Z</td>\n",
" <td></td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>&lt;NA&gt;</td>\n",
" <td></td>\n",
" <td></td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>81</th>\n",
" <td>d423ce8a-77aa-4c9a-94d4-d1adddcc3472</td>\n",
" <td>53aefd07-f66a-4d7f-ba8b-7ea1fc562d35</td>\n",
" <td>page_view</td>\n",
" <td>/hotel/products</td>\n",
" <td>None</td>\n",
" <td>hotel</td>\n",
" <td>Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...</td>\n",
" <td>2025-12-04T11:18:53.473Z</td>\n",
" <td></td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>&lt;NA&gt;</td>\n",
" <td></td>\n",
" <td></td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>82</th>\n",
" <td>d423ce8a-77aa-4c9a-94d4-d1adddcc3472</td>\n",
" <td>53aefd07-f66a-4d7f-ba8b-7ea1fc562d35</td>\n",
" <td>page_view</td>\n",
" <td>/hotel/products</td>\n",
" <td>None</td>\n",
" <td>hotel</td>\n",
" <td>Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...</td>\n",
" <td>2025-12-04T11:19:05.094Z</td>\n",
" <td></td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>&lt;NA&gt;</td>\n",
" <td></td>\n",
" <td></td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>5 rows × 24 columns</p>\n",
"</div>"
],
"text/plain": [
" sessionId \\\n",
"78 c404dbe5-116f-42c0-b199-503516dbbe91 \n",
"79 c404dbe5-116f-42c0-b199-503516dbbe91 \n",
"80 d423ce8a-77aa-4c9a-94d4-d1adddcc3472 \n",
"81 d423ce8a-77aa-4c9a-94d4-d1adddcc3472 \n",
"82 d423ce8a-77aa-4c9a-94d4-d1adddcc3472 \n",
"\n",
" experimentId eventName page \\\n",
"78 fd01774c-f629-4bcb-88b8-c818856af72a page_view /hotel/products \n",
"79 fd01774c-f629-4bcb-88b8-c818856af72a page_view /hotel/products \n",
"80 53aefd07-f66a-4d7f-ba8b-7ea1fc562d35 page_view /hotel/products \n",
"81 53aefd07-f66a-4d7f-ba8b-7ea1fc562d35 page_view /hotel/products \n",
"82 53aefd07-f66a-4d7f-ba8b-7ea1fc562d35 page_view /hotel/products \n",
"\n",
" productId storeMode userAgent \\\n",
"78 None hotel Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/53... \n",
"79 None hotel Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/53... \n",
"80 None hotel Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck... \n",
"81 None hotel Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck... \n",
"82 None hotel Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck... \n",
"\n",
" ts metadata_referrer metadata_elementText ... \\\n",
"78 2025-11-29T17:32:45.064Z NaN ... \n",
"79 2025-11-29T18:13:53.858Z NaN ... \n",
"80 2025-12-04T11:13:15.884Z NaN ... \n",
"81 2025-12-04T11:18:53.473Z NaN ... \n",
"82 2025-12-04T11:19:05.094Z NaN ... \n",
"\n",
" metadata_price metadata_nights metadata_total metadata_itemCount \\\n",
"78 NaN NaN NaN NaN \n",
"79 NaN NaN NaN NaN \n",
"80 NaN NaN NaN NaN \n",
"81 NaN NaN NaN NaN \n",
"82 NaN NaN NaN NaN \n",
"\n",
" dateIndex price_bucket metadata_schema elasticity std_error n_obs \n",
"78 <NA> NaN NaN NaN \n",
"79 <NA> NaN NaN NaN \n",
"80 <NA> NaN NaN NaN \n",
"81 <NA> NaN NaN NaN \n",
"82 <NA> NaN NaN NaN \n",
"\n",
"[5 rows x 24 columns]"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dff.tail()"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "38d4c603-35ed-4de4-847a-48e74044d6d3",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>id</th>\n",
" <th>subject_name</th>\n",
" <th>xp_human_only</th>\n",
" <th>xp_market_mode</th>\n",
" <th>xp_task_id</th>\n",
" <th>task</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>53aefd07-f66a-4d7f-ba8b-7ea1fc562d35</td>\n",
" <td>Daniel</td>\n",
" <td>False</td>\n",
" <td>hotel</td>\n",
" <td>517b8078-cf4c-4a1f-b943-75281c69a5b3</td>\n",
" <td>{'task_name': 'Cheapest Room', 'task_def_of_do...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>d10f5ab3-a7b7-4e97-8d94-ab06f1537c0a</td>\n",
" <td>Full Agent</td>\n",
" <td>False</td>\n",
" <td>hotel</td>\n",
" <td>517b8078-cf4c-4a1f-b943-75281c69a5b3</td>\n",
" <td>{'task_name': 'Cheapest Room', 'task_def_of_do...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>fd01774c-f629-4bcb-88b8-c818856af72a</td>\n",
" <td>Daniel 1</td>\n",
" <td>True</td>\n",
" <td>hotel</td>\n",
" <td>920c3deb-18c6-4586-bbc4-4ce4d1ae6f2d</td>\n",
" <td>{'task_name': 'Cheapest Room w/ View', 'task_d...</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" id subject_name xp_human_only \\\n",
"0 53aefd07-f66a-4d7f-ba8b-7ea1fc562d35 Daniel False \n",
"1 d10f5ab3-a7b7-4e97-8d94-ab06f1537c0a Full Agent False \n",
"2 fd01774c-f629-4bcb-88b8-c818856af72a Daniel 1 True \n",
"\n",
" xp_market_mode xp_task_id \\\n",
"0 hotel 517b8078-cf4c-4a1f-b943-75281c69a5b3 \n",
"1 hotel 517b8078-cf4c-4a1f-b943-75281c69a5b3 \n",
"2 hotel 920c3deb-18c6-4586-bbc4-4ce4d1ae6f2d \n",
"\n",
" task \n",
"0 {'task_name': 'Cheapest Room', 'task_def_of_do... \n",
"1 {'task_name': 'Cheapest Room', 'task_def_of_do... \n",
"2 {'task_name': 'Cheapest Room w/ View', 'task_d... "
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"experiments = FetchExperimentsStep(context).transform(dff)\n",
"experiments.tail()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9fd9f831-8a9e-40c2-89a5-de81fb4f77f3",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 26,
"id": "92f354ee-6550-48c6-87fd-46b0217e57ed",
"metadata": {},
"outputs": [],
"source": [
"dff_exp = JoinExperimentsStep(context).transform((dff,experiments))"
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "d2823849-6ff6-46d2-abc8-9e363b0f66dc",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>sessionId</th>\n",
" <th>experimentId</th>\n",
" <th>eventName</th>\n",
" <th>page</th>\n",
" <th>productId</th>\n",
" <th>storeMode</th>\n",
" <th>userAgent</th>\n",
" <th>ts</th>\n",
" <th>metadata_referrer</th>\n",
" <th>metadata_elementText</th>\n",
" <th>...</th>\n",
" <th>elasticity</th>\n",
" <th>std_error</th>\n",
" <th>n_obs</th>\n",
" <th>exp_subject</th>\n",
" <th>exp_human_only</th>\n",
" <th>exp_market_mode</th>\n",
" <th>exp_task_id</th>\n",
" <th>task_name</th>\n",
" <th>task_def_of_done</th>\n",
" <th>task_description</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>76</th>\n",
" <td>c404dbe5-116f-42c0-b199-503516dbbe91</td>\n",
" <td>fd01774c-f629-4bcb-88b8-c818856af72a</td>\n",
" <td>page_view</td>\n",
" <td>/hotel/products</td>\n",
" <td>None</td>\n",
" <td>hotel</td>\n",
" <td>Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/53...</td>\n",
" <td>2025-11-29T17:32:45.064Z</td>\n",
" <td></td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>Daniel 1</td>\n",
" <td>True</td>\n",
" <td>hotel</td>\n",
" <td>920c3deb-18c6-4586-bbc4-4ce4d1ae6f2d</td>\n",
" <td>Cheapest Room w/ View</td>\n",
" <td>User added to cart a the cheapest room of all ...</td>\n",
" <td>Find the cheapest room with a nice view in the...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>77</th>\n",
" <td>c404dbe5-116f-42c0-b199-503516dbbe91</td>\n",
" <td>fd01774c-f629-4bcb-88b8-c818856af72a</td>\n",
" <td>page_view</td>\n",
" <td>/hotel/products</td>\n",
" <td>None</td>\n",
" <td>hotel</td>\n",
" <td>Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/53...</td>\n",
" <td>2025-11-29T18:13:53.858Z</td>\n",
" <td></td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>Daniel 1</td>\n",
" <td>True</td>\n",
" <td>hotel</td>\n",
" <td>920c3deb-18c6-4586-bbc4-4ce4d1ae6f2d</td>\n",
" <td>Cheapest Room w/ View</td>\n",
" <td>User added to cart a the cheapest room of all ...</td>\n",
" <td>Find the cheapest room with a nice view in the...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>78</th>\n",
" <td>d423ce8a-77aa-4c9a-94d4-d1adddcc3472</td>\n",
" <td>53aefd07-f66a-4d7f-ba8b-7ea1fc562d35</td>\n",
" <td>page_view</td>\n",
" <td>/hotel/products</td>\n",
" <td>None</td>\n",
" <td>hotel</td>\n",
" <td>Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...</td>\n",
" <td>2025-12-04T11:13:15.884Z</td>\n",
" <td></td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>Daniel</td>\n",
" <td>False</td>\n",
" <td>hotel</td>\n",
" <td>517b8078-cf4c-4a1f-b943-75281c69a5b3</td>\n",
" <td>Cheapest Room</td>\n",
" <td>A room was added and purchased.</td>\n",
" <td>Find the cheapest hotel room in multiple steps...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>79</th>\n",
" <td>d423ce8a-77aa-4c9a-94d4-d1adddcc3472</td>\n",
" <td>53aefd07-f66a-4d7f-ba8b-7ea1fc562d35</td>\n",
" <td>page_view</td>\n",
" <td>/hotel/products</td>\n",
" <td>None</td>\n",
" <td>hotel</td>\n",
" <td>Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...</td>\n",
" <td>2025-12-04T11:18:53.473Z</td>\n",
" <td></td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>Daniel</td>\n",
" <td>False</td>\n",
" <td>hotel</td>\n",
" <td>517b8078-cf4c-4a1f-b943-75281c69a5b3</td>\n",
" <td>Cheapest Room</td>\n",
" <td>A room was added and purchased.</td>\n",
" <td>Find the cheapest hotel room in multiple steps...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>80</th>\n",
" <td>d423ce8a-77aa-4c9a-94d4-d1adddcc3472</td>\n",
" <td>53aefd07-f66a-4d7f-ba8b-7ea1fc562d35</td>\n",
" <td>page_view</td>\n",
" <td>/hotel/products</td>\n",
" <td>None</td>\n",
" <td>hotel</td>\n",
" <td>Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...</td>\n",
" <td>2025-12-04T11:19:05.094Z</td>\n",
" <td></td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>Daniel</td>\n",
" <td>False</td>\n",
" <td>hotel</td>\n",
" <td>517b8078-cf4c-4a1f-b943-75281c69a5b3</td>\n",
" <td>Cheapest Room</td>\n",
" <td>A room was added and purchased.</td>\n",
" <td>Find the cheapest hotel room in multiple steps...</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>5 rows × 31 columns</p>\n",
"</div>"
],
"text/plain": [
" sessionId \\\n",
"76 c404dbe5-116f-42c0-b199-503516dbbe91 \n",
"77 c404dbe5-116f-42c0-b199-503516dbbe91 \n",
"78 d423ce8a-77aa-4c9a-94d4-d1adddcc3472 \n",
"79 d423ce8a-77aa-4c9a-94d4-d1adddcc3472 \n",
"80 d423ce8a-77aa-4c9a-94d4-d1adddcc3472 \n",
"\n",
" experimentId eventName page \\\n",
"76 fd01774c-f629-4bcb-88b8-c818856af72a page_view /hotel/products \n",
"77 fd01774c-f629-4bcb-88b8-c818856af72a page_view /hotel/products \n",
"78 53aefd07-f66a-4d7f-ba8b-7ea1fc562d35 page_view /hotel/products \n",
"79 53aefd07-f66a-4d7f-ba8b-7ea1fc562d35 page_view /hotel/products \n",
"80 53aefd07-f66a-4d7f-ba8b-7ea1fc562d35 page_view /hotel/products \n",
"\n",
" productId storeMode userAgent \\\n",
"76 None hotel Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/53... \n",
"77 None hotel Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/53... \n",
"78 None hotel Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck... \n",
"79 None hotel Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck... \n",
"80 None hotel Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck... \n",
"\n",
" ts metadata_referrer metadata_elementText ... \\\n",
"76 2025-11-29T17:32:45.064Z NaN ... \n",
"77 2025-11-29T18:13:53.858Z NaN ... \n",
"78 2025-12-04T11:13:15.884Z NaN ... \n",
"79 2025-12-04T11:18:53.473Z NaN ... \n",
"80 2025-12-04T11:19:05.094Z NaN ... \n",
"\n",
" elasticity std_error n_obs exp_subject exp_human_only exp_market_mode \\\n",
"76 NaN NaN NaN Daniel 1 True hotel \n",
"77 NaN NaN NaN Daniel 1 True hotel \n",
"78 NaN NaN NaN Daniel False hotel \n",
"79 NaN NaN NaN Daniel False hotel \n",
"80 NaN NaN NaN Daniel False hotel \n",
"\n",
" exp_task_id task_name \\\n",
"76 920c3deb-18c6-4586-bbc4-4ce4d1ae6f2d Cheapest Room w/ View \n",
"77 920c3deb-18c6-4586-bbc4-4ce4d1ae6f2d Cheapest Room w/ View \n",
"78 517b8078-cf4c-4a1f-b943-75281c69a5b3 Cheapest Room \n",
"79 517b8078-cf4c-4a1f-b943-75281c69a5b3 Cheapest Room \n",
"80 517b8078-cf4c-4a1f-b943-75281c69a5b3 Cheapest Room \n",
"\n",
" task_def_of_done \\\n",
"76 User added to cart a the cheapest room of all ... \n",
"77 User added to cart a the cheapest room of all ... \n",
"78 A room was added and purchased. \n",
"79 A room was added and purchased. \n",
"80 A room was added and purchased. \n",
"\n",
" task_description \n",
"76 Find the cheapest room with a nice view in the... \n",
"77 Find the cheapest room with a nice view in the... \n",
"78 Find the cheapest hotel room in multiple steps... \n",
"79 Find the cheapest hotel room in multiple steps... \n",
"80 Find the cheapest hotel room in multiple steps... \n",
"\n",
"[5 rows x 31 columns]"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dff_exp.tail()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "eb61bb99-3597-4473-86e2-c90cc51a9c9a",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python (PHANTOM)",
"language": "python",
"name": "phantom"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}