{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.11.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"nvidiaTeslaT4","dataSources":[{"sourceId":7391,"databundleVersionId":44328,"sourceType":"competition"}],"dockerImageVersionId":31193,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"cfe399a8-74f7-48a7-ad98-50d53b29df5a","_cell_guid":"968dbeac-886c-4e13-8210-be1527f37f83","trusted":true,"collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2025-12-16T17:07:28.482661Z","iopub.execute_input":"2025-12-16T17:07:28.483271Z","iopub.status.idle":"2025-12-16T17:07:29.580083Z","shell.execute_reply.started":"2025-12-16T17:07:28.483243Z","shell.execute_reply":"2025-12-16T17:07:29.579322Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Loading Data","metadata":{}},{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport os","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-16T17:07:29.581509Z","iopub.execute_input":"2025-12-16T17:07:29.581918Z","iopub.status.idle":"2025-12-16T17:07:29.585326Z","shell.execute_reply.started":"2025-12-16T17:07:29.581888Z","shell.execute_reply":"2025-12-16T17:07:29.584476Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!pip install py7zr --quiet","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-16T17:07:29.586174Z","iopub.execute_input":"2025-12-16T17:07:29.586418Z","iopub.status.idle":"2025-12-16T17:07:35.131716Z","shell.execute_reply.started":"2025-12-16T17:07:29.586392Z","shell.execute_reply":"2025-12-16T17:07:35.130861Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import py7zr\n\nbase_path = \"/kaggle/input/favorita-grocery-sales-forecasting\"\n\nfiles = [\n    \"train.csv.7z\",\n    \"test.csv.7z\",\n    \"stores.csv.7z\",\n    \"items.csv.7z\",\n    \"holidays_events.csv.7z\",\n    \"transactions.csv.7z\",\n    \"oil.csv.7z\",\n    \"sample_submission.csv.7z\"\n]\n\nfor f in files:\n    with py7zr.SevenZipFile(f\"{base_path}/{f}\", mode='r') as z:\n        z.extractall(\"/kaggle/working\")\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-16T17:07:35.133057Z","iopub.execute_input":"2025-12-16T17:07:35.133994Z","iopub.status.idle":"2025-12-16T17:08:52.721173Z","shell.execute_reply.started":"2025-12-16T17:07:35.133964Z","shell.execute_reply":"2025-12-16T17:08:52.720267Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train = pd.read_csv(\"/kaggle/working/train.csv\")\ntest = pd.read_csv(\"/kaggle/working/test.csv\")\nstores = pd.read_csv(\"/kaggle/working/stores.csv\")\nitems = pd.read_csv(\"/kaggle/working/items.csv\")\nholidays = pd.read_csv(\"/kaggle/working/holidays_events.csv\")\ntransactions = pd.read_csv(\"/kaggle/working/transactions.csv\")\noil = pd.read_csv(\"/kaggle/working/oil.csv\")\nsample_sub = pd.read_csv(\"/kaggle/working/sample_submission.csv\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-16T17:08:52.723343Z","iopub.execute_input":"2025-12-16T17:08:52.723875Z","iopub.status.idle":"2025-12-16T17:10:03.154450Z","shell.execute_reply.started":"2025-12-16T17:08:52.723851Z","shell.execute_reply":"2025-12-16T17:10:03.153795Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-16T17:10:03.155253Z","iopub.execute_input":"2025-12-16T17:10:03.155487Z","iopub.status.idle":"2025-12-16T17:10:03.176248Z","shell.execute_reply.started":"2025-12-16T17:10:03.155466Z","shell.execute_reply":"2025-12-16T17:10:03.175523Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train.info()\ntrain.describe()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-16T17:10:03.177154Z","iopub.execute_input":"2025-12-16T17:10:03.177432Z","iopub.status.idle":"2025-12-16T17:10:15.829558Z","shell.execute_reply.started":"2025-12-16T17:10:03.177406Z","shell.execute_reply":"2025-12-16T17:10:15.828889Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-16T17:10:15.830404Z","iopub.execute_input":"2025-12-16T17:10:15.830741Z","iopub.status.idle":"2025-12-16T17:10:15.840614Z","shell.execute_reply.started":"2025-12-16T17:10:15.830717Z","shell.execute_reply":"2025-12-16T17:10:15.839948Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test.info()\ntest.describe()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-16T17:10:15.841317Z","iopub.execute_input":"2025-12-16T17:10:15.841540Z","iopub.status.idle":"2025-12-16T17:10:16.059499Z","shell.execute_reply.started":"2025-12-16T17:10:15.841513Z","shell.execute_reply":"2025-12-16T17:10:16.058764Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Phase 1: Data Exploration Code","metadata":{}},{"cell_type":"markdown","source":"Because the Corporación Favorita dataset is massive (the training data has approximately 125 million rows), loading it all into memory at once might crashes standard environments.\n\nThis code will explore the dataset efficiently (using \"chunking\") to help us decide which Store, Category, or Timeframe to focus on without crashing our RAM.","metadata":{}},{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nimport gc  # Garbage collection to manage RAM\n\nbase_path = '/kaggle/working/'\n\n# ---------------------------------------------------------\n# 1. INSPECT AUXILIARY FILES (Small & Easy to Load)\n# ---------------------------------------------------------\nprint(\"--- Loading Auxiliary Files ---\")\n\n# Stores: crucial for picking a specific store or cluster\nstores = pd.read_csv(base_path + 'stores.csv')\nprint(f\"Stores shape: {stores.shape}\")\nprint(stores.head())\n\n# Items: contains 'family' and 'perishable' info - good for Multimodal/Embeddings\nitems = pd.read_csv(base_path + 'items.csv')\nprint(f\"\\nItems shape: {items.shape}\")\nprint(items.head())\n\n# Oil: Exogenous variable (economic health)\noil = pd.read_csv(base_path + 'oil.csv')\nprint(f\"\\nOil shape: {oil.shape}\")\n\n# Transactions: Footfall data\ntransactions = pd.read_csv(base_path + 'transactions.csv')\nprint(f\"\\nTransactions shape: {transactions.shape}\")\n\n# ---------------------------------------------------------\n# 2. INTELLIGENT INSPECTION OF TRAIN.CSV (The Giant)\n# ---------------------------------------------------------\nprint(\"\\n--- analyzing train.csv (Chunking Method) ---\")\nprint(\"Reading the first 5 rows to understand structure...\")\ntrain_head = pd.read_csv(base_path + 'train.csv', nrows=5)\nprint(train_head)\n\n# We need to know which store has the most consistent data without loading 125M rows.\n# We will iterate through the file in chunks.\n\nchunksize = 5_000_000  # Process 5 million rows at a time\nstore_counts = {}\ndate_min = None\ndate_max = None\ntotal_rows = 0\n\n# Define types to save memory\ndtypes = {\n    'id': 'int32',\n    'store_nbr': 'int8',\n    'item_nbr': 'int32',\n    'unit_sales': 'float32',\n    'onpromotion': 'object' # Boolean but often contains NaNs or distinct values\n}\n\nprint(f\"\\nStreaming train.csv to gather statistics (this may take a few minutes)...\")\n\ntry:\n    for chunk in pd.read_csv(base_path + 'train.csv', dtype=dtypes, chunksize=chunksize, parse_dates=['date']):\n        # Update date range\n        chunk_min = chunk['date'].min()\n        chunk_max = chunk['date'].max()\n        \n        if date_min is None or chunk_min < date_min:\n            date_min = chunk_min\n        if date_max is None or chunk_max > date_max:\n            date_max = chunk_max\n            \n        # Count rows per store in this chunk\n        counts = chunk['store_nbr'].value_counts().to_dict()\n        \n        for store, count in counts.items():\n            store_counts[store] = store_counts.get(store, 0) + count\n            \n        total_rows += len(chunk)\n        print(f\"Processed {total_rows} rows...\", end='\\r')\n\n    print(f\"\\n\\nTotal Rows: {total_rows}\")\n    print(f\"Date Range: {date_min} to {date_max}\")\n\nexcept Exception as e:\n    print(f\"Error reading file (ensure it is unzipped): {e}\")\n\n# ---------------------------------------------------------\n# 3. DECISION SUPPORT: WHICH STORE TO CHOOSE?\n# ---------------------------------------------------------\n\n# Convert store counts to DataFrame\nstore_stats = pd.DataFrame(list(store_counts.items()), columns=['store_nbr', 'total_records'])\nstore_stats = store_stats.sort_values('total_records', ascending=False)\n\n# Merge with store metadata to see City/Type/Cluster\nrich_store_stats = pd.merge(store_stats, stores, on='store_nbr')\n\nprint(\"\\n--- Top 10 Stores by Data Volume ---\")\nprint(rich_store_stats.head(10))\n\n# Check Transactions volume for the top store to ensure it's active\ntop_store = rich_store_stats.iloc[0]['store_nbr']\nprint(f\"\\nChecking transaction history for Store {top_store}...\")\ntop_store_trans = transactions[transactions['store_nbr'] == top_store]\n\nplt.figure(figsize=(12, 4))\nplt.plot(pd.to_datetime(top_store_trans['date']), top_store_trans['transactions'])\nplt.title(f'Daily Transactions for Store {top_store}')\nplt.xlabel('Date')\nplt.ylabel('Transactions')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-16T17:10:16.060513Z","iopub.execute_input":"2025-12-16T17:10:16.060826Z","iopub.status.idle":"2025-12-16T17:11:46.799340Z","shell.execute_reply.started":"2025-12-16T17:10:16.060805Z","shell.execute_reply":"2025-12-16T17:11:46.798022Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Store 44 is the perfect candidate.**\n\nWhy?\n\n1. Volume: ~3.5 million rows is the \"Goldilocks\" zone—large enough to train a complex Deep Learning model (satisfying the course requirement for \"non-trivial datasets\") but small enough to manipulate in memory without needing a distributed cluster.\n2. Consistency: the plot shows very clean signals. The peaks (likely December/Christmas) repeat reliably. There are no massive \"dead zones\" where the store was closed for months, which simplifies preprocessing.\n3. Richness: It is a \"Type A\" store in \"Quito\" (the capital). This means it likely reacts strongly to the oil.csv (national economy) and holidays_events.csv data, making your model inputs richer.\n\n","metadata":{}},{"cell_type":"markdown","source":"## 1.2 Data Preprocessing and Pipeline Design\n\n### 1. Strategic Subset Selection\nGiven the massive scale of the original dataset (~125 million rows), loading the entire dataset into memory is computationally prohibitive and inefficient for rapid architectural iteration. To balance **technical depth** with **computational feasibility**, we developed a targeted subset strategy:\n\n*   **Target Selection:** We isolated **Store 44** (located in Quito).\n*   **Rationale:**\n    *   **Data Volume:** Store 44 provides approximately 3.5 million data points, which is sufficiently large to train complex deep learning architectures (like Transformers) without requiring distributed computing clusters.\n    *   **Signal Quality:** Preliminary analysis showed stable transaction consistency with distinct seasonal patterns, ideal for sequence modeling.\n    *   **Metadata Richness:** Being a \"Type A\" store in the capital city, it allows us to leverage maximum external covariates (local holidays, national economic data).\n\n### 2. Multimodal Feature Integration\nTo satisfy the requirement for **Multimodal AI**, we engineered a composite dataset merging disparate data sources into a unified timeline.\n\n#### A. Economic Context (Oil Prices)\n*   **Raw Data:** Daily oil prices (`dcoilwtico`), serving as a proxy for Ecuador’s economic health.\n*   **Challenge:** The raw financial data excludes weekends and holidays, creating temporal gaps.\n*   **Solution:** We reindexed the data to a continuous daily calendar and applied **Forward-Fill/Backward-Fill interpolation**. This ensures the neural network receives a continuous dense vector without `NaN` values, which would otherwise disrupt gradient descent.\n\n#### B. Event Context (Holidays)\n*   **Raw Data:** A calendar of holidays (`holidays_events.csv`).\n*   **Filtering Logic:** We implemented a spatial filter to retain only **National** holidays and **Local** holidays specific to Quito.\n*   **Sanitization:** \"Transferred\" holidays (days where the day off was moved to a different date) were removed to prevent noise. This feature is prepared for **Entity Embedding** layers (categorical $\\rightarrow$ dense vector).\n\n#### C. Static Covariates (Item Metadata)\n*   We merged item-specific attributes (`Family`, `Class`, `Perishable`) onto the time-series data. This allows the model to learn shared representations across similar product categories (e.g., learning that \"Dairy\" items behave similarly during power outages).\n\n### 3. Handling \"Big Data\" via Chunking\nTo process the 5GB+ `train.csv` file without crashing RAM, we implemented an iterative **Chunking Strategy**:\n1.  The file is read in batches of 5 million rows.\n2.  Each batch is filtered in-memory to extract only rows belonging to Store 44.\n3.  Processed chunks are aggregated into a single store-specific DataFrame.\nThis demonstrates a scalable workflow capable of handling datasets larger than available memory.\n\n### 4. Data Cleaning and Sanitization\nTo ensure stability in the Loss Function (specifically for RMSLE or MSE), we applied the following rigorous cleaning steps:\n\n*   **Negative Value Clipping:** The raw data contains negative `unit_sales` (representing product returns). As standard Deep Learning regression loss functions (and Log transforms) cannot handle negative targets, these were clipped to 0.\n*   **Binary Promotion Encoding:** The `onpromotion` column contained mixed types (`NaN`, `True`, `False`). We standardized this into a binary integer tensor (`0` or `1`) to ensure consistent input shapes for the network.\n\n### 5. Leakage Prevention (Train/Test Split)\nA critical component of our design is the strict separation of temporal data to prevent **Data Leakage**:\n\n*   **Training Set (2013–2017):** Includes `transactions` (footfall data) as a feature, allowing the model to learn the correlation between foot traffic and sales.\n*   **Test Set (Future):** Excludes `transactions`. Since we cannot know future footfall with certainty, excluding this feature (or treating it as a latent variable) ensures our model evaluation mimics real-world deployment conditions.\n*   **Unified Pipeline:** Both sets were processed via a shared `merge_features` function to guarantee identical feature engineering and schema consistency.","metadata":{}},{"cell_type":"code","source":"holidays.head(10)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-16T17:11:46.800152Z","iopub.status.idle":"2025-12-16T17:11:46.800491Z","shell.execute_reply.started":"2025-12-16T17:11:46.800323Z","shell.execute_reply":"2025-12-16T17:11:46.800339Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport gc\nimport warnings\n\nwarnings.simplefilter(action='ignore', category=FutureWarning)\n\n# ---------------------------------------------------------\n# CONFIGURATION\n# ---------------------------------------------------------\nBASE_PATH = '/kaggle/working/'\nOUTPUT_TRAIN_FILE = 'all_stores_train.csv'\nOUTPUT_TEST_FILE = 'all_stores_test.csv'\n\n# ---------------------------------------------------------\n# 1. LOAD & PREP AUXILIARY DATA (Common to Train & Test)\n# ---------------------------------------------------------\nprint(\"--- 1. Preparing Auxiliary Data ---\")\n\n# ITEMS\nitems = pd.read_csv(BASE_PATH + 'items.csv')\n\n# OIL\noil = pd.read_csv(BASE_PATH + 'oil.csv')\noil['date'] = pd.to_datetime(oil['date'])\nfull_date_range = pd.date_range(start='2013-01-01', end='2017-08-31')\noil = oil.set_index('date').reindex(full_date_range)\noil['dcoilwtico'] = oil['dcoilwtico'].ffill().bfill()\noil = oil.reset_index().rename(columns={'index': 'date'})\n\n# HOLIDAYS\nholidays = pd.read_csv(BASE_PATH + 'holidays_events.csv')\nholidays['date'] = pd.to_datetime(holidays['date'])\n# Keep National + Local (Quito)\nmask_national = holidays['locale'] == 'National'\nmask_local = (holidays['locale'] == 'Local') & (holidays['locale_name'] == 'Quito')\nholidays = holidays[mask_national | mask_local]\nholidays = holidays[holidays['transferred'] == False]  # Remove transferred\nholidays = holidays[['date', 'type', 'description']]\nholidays.rename(columns={'type': 'holiday_type'}, inplace=True)\nholidays = holidays.drop_duplicates(subset='date')  # Keep first if multiple\n\n# TRANSACTIONS\ntransactions = pd.read_csv(BASE_PATH + 'transactions.csv')\ntransactions['date'] = pd.to_datetime(transactions['date'])\n\nprint(\"Auxiliary data ready.\")\n\n# ---------------------------------------------------------\n# 2. HELPER FUNCTION: MERGE FEATURES\n# ---------------------------------------------------------\ndef merge_features(df, is_train=True):\n    \"\"\"Merges Items, Oil, Holidays, and creates date features\"\"\"\n    \n    # Merge Items\n    df = pd.merge(df, items, on='item_nbr', how='left')\n    \n    # Merge Oil\n    df = pd.merge(df, oil, on='date', how='left')\n    \n    # Merge Holidays\n    df = pd.merge(df, holidays, on='date', how='left')\n    df['holiday_type'] = df['holiday_type'].fillna('Work Day')\n    df['description'] = df['description'].fillna(\"No Holiday\")\n    \n    # Date Features\n    df['day_of_week'] = df['date'].dt.dayofweek\n    df['day_of_month'] = df['date'].dt.day\n    df['month'] = df['date'].dt.month\n    df['year'] = df['date'].dt.year\n    \n    return df\n\n# ---------------------------------------------------------\n# 3. PROCESS TRAIN DATA (ALL STORES)\n# ---------------------------------------------------------\nprint(\"\\n--- 2. Processing Train Data for All Stores ---\")\n\ndtypes_train = {\n    'id': 'int32',\n    'store_nbr': 'int8',\n    'item_nbr': 'int32',\n    'unit_sales': 'float32',\n    'onpromotion': 'object'\n}\n\nchunksize = 5_000_000\ntrain_chunks = []\n\nfor chunk in pd.read_csv(BASE_PATH + 'train.csv', dtype=dtypes_train, chunksize=chunksize, parse_dates=['date']):\n    # Filter 2016-2017 only\n    chunk = chunk[(chunk['date'].dt.year >= 2016) & (chunk['date'].dt.year <= 2017)]\n    \n    if len(chunk) > 0:\n        # Clip negative sales\n        chunk['unit_sales'] = chunk['unit_sales'].clip(lower=0)\n        \n        # Onpromotion preprocessing\n        chunk['onpromotion'] = chunk['onpromotion'].fillna(False)\n        chunk['onpromotion'] = (chunk['onpromotion'].astype(str) == 'True').astype(int)\n        \n        train_chunks.append(chunk)\n    print(f\"Processing chunks...\", end='\\r')\n\n# Combine all\ntrain_df = pd.concat(train_chunks, axis=0)\ndel train_chunks\ngc.collect()\n\n# Merge features\ntrain_df = merge_features(train_df, is_train=True)\n\n# Merge transactions\ntrain_df = pd.merge(train_df, transactions[['store_nbr', 'date', 'transactions']], \n                    on=['store_nbr','date'], how='left')\ntrain_df['transactions'] = train_df['transactions'].fillna(0)\n\n# Sort\ntrain_df = train_df.sort_values(['store_nbr','item_nbr','date'])\nprint(f\"\\nTrain Shape: {train_df.shape}\")\nprint(train_df.head(3))\n\n# Save\ntrain_df.to_csv(OUTPUT_TRAIN_FILE, index=False)\nprint(f\"Saved {OUTPUT_TRAIN_FILE}\")\n\n# ---------------------------------------------------------\n# 4. PROCESS TEST DATA (ALL STORES)\n# ---------------------------------------------------------\nprint(\"\\n--- 3. Processing Test Data for All Stores ---\")\n\ntest_df = pd.read_csv(BASE_PATH + 'test.csv', parse_dates=['date'])\n# Filter 2016-2017 if needed, though test is usually Aug 2017\ntest_df['onpromotion'] = test_df['onpromotion'].fillna(False).astype(int)\n\n# Merge features\ntest_df = merge_features(test_df, is_train=False)\n\n# Sort\ntest_df = test_df.sort_values(['store_nbr','item_nbr','date'])\nprint(f\"Test Shape: {test_df.shape}\")\nprint(test_df.head(3))\n\n# Save\ntest_df.to_csv(OUTPUT_TEST_FILE, index=False)\nprint(f\"Saved {OUTPUT_TEST_FILE}\")","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import pandas as pd\n#, 48, 8, 49, 50, 11\nTOP_STORES = [44, 47, 45, 46, 3]\n\ntrain_df = pd.read_csv('/kaggle/working/all_stores_train.csv', parse_dates=['date'])\n\ntrain_df = train_df[train_df['store_nbr'].isin(TOP_STORES)]\n\ntrain_df = train_df.sort_values(['store_nbr', 'item_nbr', 'date'])\n\nprint(\"Filtered Train Shape:\", train_df.shape)\n\ntrain_df.to_csv('top5_stores_train.csv', index=False)\nprint(\"Saved top5_stores_train.csv\")\n\ntest_df = pd.read_csv('/kaggle/working/all_stores_test.csv', parse_dates=['date'])\n\ntest_df = test_df[test_df['store_nbr'].isin(TOP_STORES)]\n\ntest_df = test_df.sort_values(['store_nbr', 'item_nbr', 'date'])\n\nprint(\"Filtered Test Shape:\", test_df.shape)\n\ntest_df.to_csv('top5_stores_test.csv', index=False)\nprint(\"Saved top5_stores_test.csv\")\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-16T17:30:03.481880Z","iopub.execute_input":"2025-12-16T17:30:03.482214Z","iopub.status.idle":"2025-12-16T17:32:41.719441Z","shell.execute_reply.started":"2025-12-16T17:30:03.482189Z","shell.execute_reply":"2025-12-16T17:32:41.718637Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_df.info","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-16T17:26:59.240251Z","iopub.execute_input":"2025-12-16T17:26:59.240966Z","iopub.status.idle":"2025-12-16T17:26:59.261747Z","shell.execute_reply.started":"2025-12-16T17:26:59.240935Z","shell.execute_reply":"2025-12-16T17:26:59.261003Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import shutil\nimport os\n\ninput_file = '/kaggle/working/all_stores_train.csv'\nzip_file = '/kaggle/working/all_stores_train.zip'\n\nprint(\"Zipping file...\")\nshutil.make_archive(\n    base_name=zip_file.replace('.zip', ''),\n    format='zip',\n    root_dir='/kaggle/working',\n    base_dir='all_stores_train.csv'\n)\n\nprint(f\"Zip created: {zip_file}\")\nprint(\"Original size:\", os.path.getsize(input_file) / 1e9, \"GB\")\nprint(\"Zip size:\", os.path.getsize(zip_file) / 1e9, \"GB\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-16T17:11:46.804118Z","iopub.status.idle":"2025-12-16T17:11:46.804404Z","shell.execute_reply.started":"2025-12-16T17:11:46.804248Z","shell.execute_reply":"2025-12-16T17:11:46.804263Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_df.tail(20)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-16T17:27:28.537596Z","iopub.execute_input":"2025-12-16T17:27:28.538422Z","iopub.status.idle":"2025-12-16T17:27:28.555646Z","shell.execute_reply.started":"2025-12-16T17:27:28.538391Z","shell.execute_reply":"2025-12-16T17:27:28.554794Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_df.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-16T17:27:08.125777Z","iopub.execute_input":"2025-12-16T17:27:08.126079Z","iopub.status.idle":"2025-12-16T17:27:08.138103Z","shell.execute_reply.started":"2025-12-16T17:27:08.126057Z","shell.execute_reply":"2025-12-16T17:27:08.137263Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"We now have two files:\n1. store_all_train.csv: Contains history (2013–2017).\n  * Features: Date, Oil Price, Item Family, Promotion (0/1), Holiday Type, Transactions, Target (Sales).\n\n2. store_all_test.csv: Contains the future (Aug 16–31, 2017).\n  * Features: Date, Oil Price, Item Family, Promotion (0/1), Holiday Type.\n  * Missing: Transactions, Target (Sales).","metadata":{}}]}