{ "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": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
sessionIdexperimentIdeventNamepageproductIdstoreModeuserAgenttsmetadata_referrermetadata_elementTextmetadata_dateIndexmetadata_dwellTimemetadata_typemetadata_roomTypemetadata_pricemetadata_nightsmetadata_totalmetadata_itemCountdateIndex
0d423ce8a-77aa-4c9a-94d4-d1adddcc3472Nonepage_view/NonehotelMozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...2025-11-25T20:20:13.061ZNaNNaNNaNNaNNaNNaNNaNNaNNaN<NA>
1d423ce8a-77aa-4c9a-94d4-d1adddcc3472Nonehover_over_title/hotel/productsd018efc1-25e9-4284-b276-80386e048b25hotelMozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...2025-11-25T20:21:17.425ZNaNJunior Suite1.01200.0NaNNaNNaNNaNNaNNaN1
2d423ce8a-77aa-4c9a-94d4-d1adddcc3472Nonehover_over_paragraph/hotel/productsd018efc1-25e9-4284-b276-80386e048b25hotelMozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...2025-11-25T20:21:19.496ZNaNprice1.01202.0NaNNaNNaNNaNNaNNaN1
3d423ce8a-77aa-4c9a-94d4-d1adddcc3472Nonepage_view/hotel/products/d018efc1-25e9-4284-b276-80386e...NonehotelMozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...2025-11-25T20:21:21.922Zhttp://localhost:3000/hotel/products?dateIndex...NaNNaNNaNNaNNaNNaNNaNNaNNaN<NA>
4d423ce8a-77aa-4c9a-94d4-d1adddcc3472Nonelearn_more_about_item/hotel/products/d018efc1-25e9-4284-b276-80386e...d018efc1-25e9-4284-b276-80386e048b25hotelMozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...2025-11-25T20:21:22.674ZNaNNaN1.0NaNhotelJunior SuiteNaNNaNNaNNaN1
\n", "
" ], "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 \n", "1 1 \n", "2 1 \n", "3 \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": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
sessionIdexperimentIdeventNamepageproductIdstoreModeuserAgenttsmetadata_referrermetadata_elementTextmetadata_dateIndexmetadata_dwellTimemetadata_typemetadata_roomTypemetadata_pricemetadata_nightsmetadata_totalmetadata_itemCountdateIndexprice_bucket
0d423ce8a-77aa-4c9a-94d4-d1adddcc3472Nonepage_view/NonehotelMozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...2025-11-25T20:20:13.061ZNaNNaNNaNNaNNaNNaNNaNNaNNaN<NA>
1d423ce8a-77aa-4c9a-94d4-d1adddcc3472Nonehover_over_title/hotel/productsd018efc1-25e9-4284-b276-80386e048b25hotelMozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...2025-11-25T20:21:17.425ZNaNJunior Suite1.01200.0NaNNaNNaNNaNNaNNaN1
2d423ce8a-77aa-4c9a-94d4-d1adddcc3472Nonehover_over_paragraph/hotel/productsd018efc1-25e9-4284-b276-80386e048b25hotelMozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...2025-11-25T20:21:19.496ZNaNprice1.01202.0NaNNaNNaNNaNNaNNaN1
3d423ce8a-77aa-4c9a-94d4-d1adddcc3472Nonepage_view/hotel/products/d018efc1-25e9-4284-b276-80386e...NonehotelMozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...2025-11-25T20:21:21.922Zhttp://localhost:3000/hotel/products?dateIndex...NaNNaNNaNNaNNaNNaNNaNNaNNaN<NA>
4d423ce8a-77aa-4c9a-94d4-d1adddcc3472Nonelearn_more_about_item/hotel/products/d018efc1-25e9-4284-b276-80386e...d018efc1-25e9-4284-b276-80386e048b25hotelMozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...2025-11-25T20:21:22.674ZNaNNaN1.0NaNhotelJunior SuiteNaNNaNNaNNaN1
\n", "
" ], "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 \n", "1 1 \n", "2 1 \n", "3 \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": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
sessionIdexperimentIdeventNamepageproductIdstoreModeuserAgenttsmetadata_referrermetadata_elementText...metadata_dwellTimemetadata_typemetadata_roomTypemetadata_pricemetadata_nightsmetadata_totalmetadata_itemCountdateIndexprice_bucketmetadata_schema
78c404dbe5-116f-42c0-b199-503516dbbe91fd01774c-f629-4bcb-88b8-c818856af72apage_view/hotel/productsNonehotelMozilla/5.0 (X11; Linux x86_64) AppleWebKit/53...2025-11-29T17:32:45.064ZNaN...NaNNaNNaNNaNNaNNaNNaN<NA>
79c404dbe5-116f-42c0-b199-503516dbbe91fd01774c-f629-4bcb-88b8-c818856af72apage_view/hotel/productsNonehotelMozilla/5.0 (X11; Linux x86_64) AppleWebKit/53...2025-11-29T18:13:53.858ZNaN...NaNNaNNaNNaNNaNNaNNaN<NA>
80d423ce8a-77aa-4c9a-94d4-d1adddcc347253aefd07-f66a-4d7f-ba8b-7ea1fc562d35page_view/hotel/productsNonehotelMozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...2025-12-04T11:13:15.884ZNaN...NaNNaNNaNNaNNaNNaNNaN<NA>
81d423ce8a-77aa-4c9a-94d4-d1adddcc347253aefd07-f66a-4d7f-ba8b-7ea1fc562d35page_view/hotel/productsNonehotelMozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...2025-12-04T11:18:53.473ZNaN...NaNNaNNaNNaNNaNNaNNaN<NA>
82d423ce8a-77aa-4c9a-94d4-d1adddcc347253aefd07-f66a-4d7f-ba8b-7ea1fc562d35page_view/hotel/productsNonehotelMozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...2025-12-04T11:19:05.094ZNaN...NaNNaNNaNNaNNaNNaNNaN<NA>
\n", "

5 rows × 21 columns

\n", "
" ], "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 \n", "79 NaN NaN NaN \n", "80 NaN NaN NaN \n", "81 NaN NaN NaN \n", "82 NaN NaN NaN \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": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
productIdpricesessionIdexperimentIdstoreModets
2132cd7f756-fc65-4ba0-ab01-74521c1fff43100.0d423ce8a-77aa-4c9a-94d4-d1adddcc3472Nonehotel2025-12-04T11:18:56.320Z
2142ddabbfc-4127-48fc-86dc-ebc4c677efa2100.0d423ce8a-77aa-4c9a-94d4-d1adddcc3472Nonehotel2025-12-04T11:19:05.434Z
2152cd7f756-fc65-4ba0-ab01-74521c1fff43100.0d423ce8a-77aa-4c9a-94d4-d1adddcc3472Nonehotel2025-12-04T11:19:05.338Z
2162cd7f756-fc65-4ba0-ab01-74521c1fff43100.0d423ce8a-77aa-4c9a-94d4-d1adddcc3472Nonehotel2025-12-04T11:19:05.597Z
2172ddabbfc-4127-48fc-86dc-ebc4c677efa2100.0d423ce8a-77aa-4c9a-94d4-d1adddcc3472Nonehotel2025-12-04T11:19:05.594Z
\n", "
" ], "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": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
sessionIdexperimentIdeventNamepageproductIdstoreModeuserAgenttsmetadata_referrermetadata_elementText...metadata_dwellTimemetadata_typemetadata_roomTypemetadata_pricemetadata_nightsmetadata_totalmetadata_itemCountdateIndexprice_bucketmetadata_schema
81d423ce8a-77aa-4c9a-94d4-d1adddcc347253aefd07-f66a-4d7f-ba8b-7ea1fc562d35page_view/hotel/productsNonehotelMozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...2025-12-04 11:18:53.473000+00:00NaN...NaNNaNNaNNaNNaNNaNNaN<NA>
82d423ce8a-77aa-4c9a-94d4-d1adddcc347253aefd07-f66a-4d7f-ba8b-7ea1fc562d35page_view/hotel/productsNonehotelMozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...2025-12-04 11:19:05.094000+00:00NaN...NaNNaNNaNNaNNaNNaNNaN<NA>
\n", "

2 rows × 21 columns

\n", "
" ], "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 \n", "82 NaN NaN NaN \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": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
productIddemand_score
0bec37f41-7756-47ae-9219-f5854290f4e70
15e666c06-023a-415b-9976-be0956bbc4050
2d018efc1-25e9-4284-b276-80386e048b250
32cd7f756-fc65-4ba0-ab01-74521c1fff430
451266ddb-5b07-47b7-89ee-5b5cae94bb110
.........
790d1c9a3a-bc37-4417-a59f-de4b994944cb0
80fc64bd74-4dfa-4f78-802a-39d6aa4c39fe0
81d85d4c52-baa0-435f-81ac-b0c27a5251b30
8293bc00e5-8cfe-42af-8322-49bc274076880
8318cc01db-55cc-42a5-aab5-e3ec448548d80
\n", "

84 rows × 2 columns

\n", "
" ], "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": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
productIdprice
02cd7f756-fc65-4ba0-ab01-74521c1fff43100.00
12ddabbfc-4127-48fc-86dc-ebc4c677efa2100.00
251266ddb-5b07-47b7-89ee-5b5cae94bb11100.00
3d018efc1-25e9-4284-b276-80386e048b25100.00
4aaae8177-0803-4421-8702-f3ffeeeadcd9389.04
57f71fbe2-343c-4a46-94ea-07cbd903a86c327.94
6d6affcb8-6616-47f8-af14-2ec8583f0781391.43
70fbcf915-ecf1-4ec3-9b00-8bbc314e2a81900.97
8eceedfb3-ec52-4453-9aab-88dd9a6b6ca3640.54
\n", "
" ], "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": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
productIdelasticitystd_errorn_obs
0d018efc1-25e9-4284-b276-80386e048b25-0.2220540.44710211
12cd7f756-fc65-4ba0-ab01-74521c1fff43-0.0728570.51013011
251266ddb-5b07-47b7-89ee-5b5cae94bb11-0.2910830.34687911
32ddabbfc-4127-48fc-86dc-ebc4c677efa2-10.2239680.00000011
47f71fbe2-343c-4a46-94ea-07cbd903a86c0.0000000.0000009
...............
790d1c9a3a-bc37-4417-a59f-de4b994944cb0.0000000.0000000
80fc64bd74-4dfa-4f78-802a-39d6aa4c39fe0.0000000.0000000
81d85d4c52-baa0-435f-81ac-b0c27a5251b30.0000000.0000000
8293bc00e5-8cfe-42af-8322-49bc274076880.0000000.0000000
8318cc01db-55cc-42a5-aab5-e3ec448548d80.0000000.0000000
\n", "

84 rows × 4 columns

\n", "
" ], "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": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
elasticitystd_errorn_obs
productId
d018efc1-25e9-4284-b276-80386e048b25-0.2220540.44710211
2cd7f756-fc65-4ba0-ab01-74521c1fff43-0.0728570.51013011
51266ddb-5b07-47b7-89ee-5b5cae94bb11-0.2910830.34687911
2ddabbfc-4127-48fc-86dc-ebc4c677efa2-10.2239680.00000011
7f71fbe2-343c-4a46-94ea-07cbd903a86c0.0000000.0000009
............
0d1c9a3a-bc37-4417-a59f-de4b994944cb0.0000000.0000000
fc64bd74-4dfa-4f78-802a-39d6aa4c39fe0.0000000.0000000
d85d4c52-baa0-435f-81ac-b0c27a5251b30.0000000.0000000
93bc00e5-8cfe-42af-8322-49bc274076880.0000000.0000000
18cc01db-55cc-42a5-aab5-e3ec448548d80.0000000.0000000
\n", "

84 rows × 3 columns

\n", "
" ], "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": [ "\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": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
sessionIdexperimentIdeventNamepageproductIdstoreModeuserAgenttsmetadata_referrermetadata_elementText...metadata_pricemetadata_nightsmetadata_totalmetadata_itemCountdateIndexprice_bucketmetadata_schemaelasticitystd_errorn_obs
78c404dbe5-116f-42c0-b199-503516dbbe91fd01774c-f629-4bcb-88b8-c818856af72apage_view/hotel/productsNonehotelMozilla/5.0 (X11; Linux x86_64) AppleWebKit/53...2025-11-29T17:32:45.064ZNaN...NaNNaNNaNNaN<NA>NaNNaNNaN
79c404dbe5-116f-42c0-b199-503516dbbe91fd01774c-f629-4bcb-88b8-c818856af72apage_view/hotel/productsNonehotelMozilla/5.0 (X11; Linux x86_64) AppleWebKit/53...2025-11-29T18:13:53.858ZNaN...NaNNaNNaNNaN<NA>NaNNaNNaN
80d423ce8a-77aa-4c9a-94d4-d1adddcc347253aefd07-f66a-4d7f-ba8b-7ea1fc562d35page_view/hotel/productsNonehotelMozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...2025-12-04T11:13:15.884ZNaN...NaNNaNNaNNaN<NA>NaNNaNNaN
81d423ce8a-77aa-4c9a-94d4-d1adddcc347253aefd07-f66a-4d7f-ba8b-7ea1fc562d35page_view/hotel/productsNonehotelMozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...2025-12-04T11:18:53.473ZNaN...NaNNaNNaNNaN<NA>NaNNaNNaN
82d423ce8a-77aa-4c9a-94d4-d1adddcc347253aefd07-f66a-4d7f-ba8b-7ea1fc562d35page_view/hotel/productsNonehotelMozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...2025-12-04T11:19:05.094ZNaN...NaNNaNNaNNaN<NA>NaNNaNNaN
\n", "

5 rows × 24 columns

\n", "
" ], "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 NaN NaN NaN \n", "79 NaN NaN NaN \n", "80 NaN NaN NaN \n", "81 NaN NaN NaN \n", "82 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": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
idsubject_namexp_human_onlyxp_market_modexp_task_idtask
053aefd07-f66a-4d7f-ba8b-7ea1fc562d35DanielFalsehotel517b8078-cf4c-4a1f-b943-75281c69a5b3{'task_name': 'Cheapest Room', 'task_def_of_do...
1d10f5ab3-a7b7-4e97-8d94-ab06f1537c0aFull AgentFalsehotel517b8078-cf4c-4a1f-b943-75281c69a5b3{'task_name': 'Cheapest Room', 'task_def_of_do...
2fd01774c-f629-4bcb-88b8-c818856af72aDaniel 1Truehotel920c3deb-18c6-4586-bbc4-4ce4d1ae6f2d{'task_name': 'Cheapest Room w/ View', 'task_d...
\n", "
" ], "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": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
sessionIdexperimentIdeventNamepageproductIdstoreModeuserAgenttsmetadata_referrermetadata_elementText...elasticitystd_errorn_obsexp_subjectexp_human_onlyexp_market_modeexp_task_idtask_nametask_def_of_donetask_description
76c404dbe5-116f-42c0-b199-503516dbbe91fd01774c-f629-4bcb-88b8-c818856af72apage_view/hotel/productsNonehotelMozilla/5.0 (X11; Linux x86_64) AppleWebKit/53...2025-11-29T17:32:45.064ZNaN...NaNNaNNaNDaniel 1Truehotel920c3deb-18c6-4586-bbc4-4ce4d1ae6f2dCheapest Room w/ ViewUser added to cart a the cheapest room of all ...Find the cheapest room with a nice view in the...
77c404dbe5-116f-42c0-b199-503516dbbe91fd01774c-f629-4bcb-88b8-c818856af72apage_view/hotel/productsNonehotelMozilla/5.0 (X11; Linux x86_64) AppleWebKit/53...2025-11-29T18:13:53.858ZNaN...NaNNaNNaNDaniel 1Truehotel920c3deb-18c6-4586-bbc4-4ce4d1ae6f2dCheapest Room w/ ViewUser added to cart a the cheapest room of all ...Find the cheapest room with a nice view in the...
78d423ce8a-77aa-4c9a-94d4-d1adddcc347253aefd07-f66a-4d7f-ba8b-7ea1fc562d35page_view/hotel/productsNonehotelMozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...2025-12-04T11:13:15.884ZNaN...NaNNaNNaNDanielFalsehotel517b8078-cf4c-4a1f-b943-75281c69a5b3Cheapest RoomA room was added and purchased.Find the cheapest hotel room in multiple steps...
79d423ce8a-77aa-4c9a-94d4-d1adddcc347253aefd07-f66a-4d7f-ba8b-7ea1fc562d35page_view/hotel/productsNonehotelMozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...2025-12-04T11:18:53.473ZNaN...NaNNaNNaNDanielFalsehotel517b8078-cf4c-4a1f-b943-75281c69a5b3Cheapest RoomA room was added and purchased.Find the cheapest hotel room in multiple steps...
80d423ce8a-77aa-4c9a-94d4-d1adddcc347253aefd07-f66a-4d7f-ba8b-7ea1fc562d35page_view/hotel/productsNonehotelMozilla/5.0 (X11; Linux x86_64; rv:145.0) Geck...2025-12-04T11:19:05.094ZNaN...NaNNaNNaNDanielFalsehotel517b8078-cf4c-4a1f-b943-75281c69a5b3Cheapest RoomA room was added and purchased.Find the cheapest hotel room in multiple steps...
\n", "

5 rows × 31 columns

\n", "
" ], "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 }