{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":7391,"databundleVersionId":44328,"sourceType":"competition"},{"sourceId":10987108,"sourceType":"datasetVersion","datasetId":6838419}],"dockerImageVersionId":30918,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"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":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2025-03-11T02:29:32.624279Z","iopub.execute_input":"2025-03-11T02:29:32.624552Z","iopub.status.idle":"2025-03-11T02:29:32.931786Z","shell.execute_reply.started":"2025-03-11T02:29:32.624527Z","shell.execute_reply":"2025-03-11T02:29:32.930784Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!pip install category_encoders\n!pip install tensorflow keras\n\nimport numpy\nimport matplotlib.pyplot as plt\nimport pandas as pd\nimport math\nfrom keras.models import Sequential\nfrom keras.layers import Dense,Dropout\nfrom keras.layers import LSTM\nfrom sklearn.preprocessing import MinMaxScaler, OneHotEncoder, LabelEncoder\n\nfrom sklearn.model_selection import train_test_split\nfrom tensorflow.keras.preprocessing.sequence import TimeseriesGenerator\n\nfrom sklearn.metrics import mean_squared_error\n!apt-get install p7zip-full -y","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-11T06:26:29.471873Z","iopub.execute_input":"2025-03-11T06:26:29.472267Z","iopub.status.idle":"2025-03-11T06:26:39.668234Z","shell.execute_reply.started":"2025-03-11T06:26:29.472240Z","shell.execute_reply":"2025-03-11T06:26:39.666620Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import os\nos.listdir('/kaggle/working')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-11T03:44:20.402779Z","iopub.execute_input":"2025-03-11T03:44:20.403152Z","iopub.status.idle":"2025-03-11T03:44:20.409035Z","shell.execute_reply.started":"2025-03-11T03:44:20.403129Z","shell.execute_reply":"2025-03-11T03:44:20.408029Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import os\nos.listdir('/kaggle/input/data-zip')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-11T03:44:27.694538Z","iopub.execute_input":"2025-03-11T03:44:27.694830Z","iopub.status.idle":"2025-03-11T03:44:27.709818Z","shell.execute_reply.started":"2025-03-11T03:44:27.694803Z","shell.execute_reply":"2025-03-11T03:44:27.709102Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train = pd.read_csv('../input/data-zip/train.csv', low_memory=False)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-11T03:44:49.882312Z","iopub.execute_input":"2025-03-11T03:44:49.882604Z","iopub.status.idle":"2025-03-11T03:46:30.309251Z","shell.execute_reply.started":"2025-03-11T03:44:49.882580Z","shell.execute_reply":"2025-03-11T03:46:30.308298Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print(train.columns)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-11T03:46:37.353515Z","iopub.execute_input":"2025-03-11T03:46:37.353829Z","iopub.status.idle":"2025-03-11T03:46:37.360623Z","shell.execute_reply.started":"2025-03-11T03:46:37.353796Z","shell.execute_reply":"2025-03-11T03:46:37.359402Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!7z x /kaggle/input/favorita-grocery-sales-forecasting/stores.csv.7z -o/kaggle/working/","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-11T03:46:47.810878Z","iopub.execute_input":"2025-03-11T03:46:47.811231Z","iopub.status.idle":"2025-03-11T03:46:48.022783Z","shell.execute_reply.started":"2025-03-11T03:46:47.811204Z","shell.execute_reply":"2025-03-11T03:46:48.021509Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!7z x /kaggle/input/favorita-grocery-sales-forecasting/holidays_events.csv.7z -o/kaggle/working/\n!7z x /kaggle/input/favorita-grocery-sales-forecasting/items.csv.7z -o/kaggle/working/\n!7z x /kaggle/input/favorita-grocery-sales-forecasting/test.csv.7z -o/kaggle/working/","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-11T03:47:43.090992Z","iopub.execute_input":"2025-03-11T03:47:43.091401Z","iopub.status.idle":"2025-03-11T03:47:44.340162Z","shell.execute_reply.started":"2025-03-11T03:47:43.091375Z","shell.execute_reply":"2025-03-11T03:47:44.339157Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"holidays_events = pd.read_csv('../working/holidays_events.csv')\nitems = pd.read_csv('../working/items.csv')\ntest = pd.read_csv('../working/test.csv')\nstores = pd.read_csv('../working/stores.csv')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-11T03:47:54.120755Z","iopub.execute_input":"2025-03-11T03:47:54.121125Z","iopub.status.idle":"2025-03-11T03:47:54.989269Z","shell.execute_reply.started":"2025-03-11T03:47:54.121101Z","shell.execute_reply":"2025-03-11T03:47:54.988317Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print(holidays_events.columns)\nprint(items.columns)\nprint(test.columns)\nprint(stores.columns)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-11T03:48:01.939190Z","iopub.execute_input":"2025-03-11T03:48:01.939471Z","iopub.status.idle":"2025-03-11T03:48:01.945165Z","shell.execute_reply.started":"2025-03-11T03:48:01.939451Z","shell.execute_reply":"2025-03-11T03:48:01.944063Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print(\"\\nHolidays_event:\")\nprint(holidays_events.head())\n\nprint(\"\\nItems:\")\nprint(items.head())\n\nprint(\"\\nTest:\")\nprint(test.head())\n\nprint(\"\\nStores:\")\nprint(stores.head())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-11T03:48:05.169576Z","iopub.execute_input":"2025-03-11T03:48:05.169884Z","iopub.status.idle":"2025-03-11T03:48:05.195510Z","shell.execute_reply.started":"2025-03-11T03:48:05.169859Z","shell.execute_reply":"2025-03-11T03:48:05.194730Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Join Data**","metadata":{}},{"cell_type":"code","source":"train_items = pd.merge(train, items, how='left', on=['item_nbr'])\nprint(train_items.head())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-11T03:48:08.891589Z","iopub.execute_input":"2025-03-11T03:48:08.891853Z","iopub.status.idle":"2025-03-11T03:48:19.791543Z","shell.execute_reply.started":"2025-03-11T03:48:08.891833Z","shell.execute_reply":"2025-03-11T03:48:19.790663Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print(train_items.head())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-11T03:48:22.892542Z","iopub.execute_input":"2025-03-11T03:48:22.892838Z","iopub.status.idle":"2025-03-11T03:48:22.899763Z","shell.execute_reply.started":"2025-03-11T03:48:22.892812Z","shell.execute_reply":"2025-03-11T03:48:22.898449Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"mask=train_items['family'] == \"LIQUOR,WINE,BEER\"\ntrain_items_formatted=train_items.loc[mask]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-11T03:50:08.993995Z","iopub.execute_input":"2025-03-11T03:50:08.994295Z","iopub.status.idle":"2025-03-11T03:50:15.276366Z","shell.execute_reply.started":"2025-03-11T03:50:08.994270Z","shell.execute_reply":"2025-03-11T03:50:15.274946Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_items_formatted.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-11T06:01:57.445860Z","iopub.execute_input":"2025-03-11T06:01:57.446244Z","iopub.status.idle":"2025-03-11T06:01:57.460123Z","shell.execute_reply.started":"2025-03-11T06:01:57.446217Z","shell.execute_reply":"2025-03-11T06:01:57.459046Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_items_formatted.to_csv('/kaggle/working/train_items_formatted.csv')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-11T03:52:44.534191Z","iopub.execute_input":"2025-03-11T03:52:44.534501Z","iopub.status.idle":"2025-03-11T03:52:47.018302Z","shell.execute_reply.started":"2025-03-11T03:52:44.534480Z","shell.execute_reply":"2025-03-11T03:52:47.017192Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_items_stores = pd.merge(train_items_formatted, stores, how='left', on=['store_nbr'])\nprint(train_items_stores.head())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-11T06:02:04.241309Z","iopub.execute_input":"2025-03-11T06:02:04.241643Z","iopub.status.idle":"2025-03-11T06:02:04.917336Z","shell.execute_reply.started":"2025-03-11T06:02:04.241618Z","shell.execute_reply":"2025-03-11T06:02:04.916163Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_items_stores_holidays_events = pd.merge(train_items_stores, holidays_events, how='left', on=['date'])\ntrain_items_stores_holidays_events.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-11T06:02:08.596950Z","iopub.execute_input":"2025-03-11T06:02:08.597423Z","iopub.status.idle":"2025-03-11T06:02:09.814543Z","shell.execute_reply.started":"2025-03-11T06:02:08.597389Z","shell.execute_reply":"2025-03-11T06:02:09.813143Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"unique_values_type_y = train_items_stores_holidays_events['type_y'].unique()\nunique_values_transferred = train_items_stores_holidays_events['transferred'].unique()\nunique_values_onpromotion = train_items_stores_holidays_events['onpromotion'].unique()\n\n\nprint(\"\\nUnique_values_type_y:\")\nprint(unique_values_type_y)\n\nprint(\"\\nTransferred:\")\nprint(unique_values_transferred)\n\nprint(\"\\nOnpromotion:\")\nprint(unique_values_onpromotion)\n\nprint(len(train_items_stores_holidays_events))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-11T06:02:12.372623Z","iopub.execute_input":"2025-03-11T06:02:12.373030Z","iopub.status.idle":"2025-03-11T06:02:12.448161Z","shell.execute_reply.started":"2025-03-11T06:02:12.372975Z","shell.execute_reply":"2025-03-11T06:02:12.446955Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"filtered_train_items_stores_holidays_events = train_items_stores_holidays_events[\n    (train_items_stores_holidays_events[\"city\"].isin([\"Guayaquil\", \"Quito\"]))]\nprint(len(filtered_train_items_stores_holidays_events))\n\nunique_values_type_y = filtered_train_items_stores_holidays_events['type_y'].unique()\nunique_values_transferred = filtered_train_items_stores_holidays_events['transferred'].unique()\nunique_values_onpromotion = filtered_train_items_stores_holidays_events['onpromotion'].unique()\nunique_values_locale = filtered_train_items_stores_holidays_events['locale'].unique()\nunique_values_locale_name = filtered_train_items_stores_holidays_events['locale_name'].unique()\nunique_values_description = filtered_train_items_stores_holidays_events['description'].unique()\n\n\n\nprint(\"\\nUnique_values_type_y:\")\nprint(unique_values_type_y)\n\nprint(\"\\nTransferred:\")\nprint(unique_values_transferred)\n\nprint(\"\\nOnpromotion:\")\nprint(unique_values_onpromotion)\n\nprint(\"\\nLocale:\")\nprint(unique_values_locale)\n\nprint(\"\\nLocale_name:\")\nprint(unique_values_locale_name)\n\nprint(\"\\nDescription:\")\nprint(unique_values_description)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-11T06:15:36.073472Z","iopub.execute_input":"2025-03-11T06:15:36.073877Z","iopub.status.idle":"2025-03-11T06:15:36.255245Z","shell.execute_reply.started":"2025-03-11T06:15:36.073844Z","shell.execute_reply":"2025-03-11T06:15:36.254349Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"#filtered_train_items_stores_holidays_events.head()\nprint(filtered_train_items_stores_holidays_events.info())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-11T06:16:45.271171Z","iopub.execute_input":"2025-03-11T06:16:45.271513Z","iopub.status.idle":"2025-03-11T06:16:45.444432Z","shell.execute_reply.started":"2025-03-11T06:16:45.271486Z","shell.execute_reply":"2025-03-11T06:16:45.443733Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Replace NaN values\nfiltered_train_items_stores_holidays_events = (\n    filtered_train_items_stores_holidays_events.copy()\n)\n# Convert 'date' to datetime\nfiltered_train_items_stores_holidays_events['date'] = pd.to_datetime(filtered_train_items_stores_holidays_events['date'])\n\n# Feature Engineering: Extract useful features from 'date'\nfiltered_train_items_stores_holidays_events['year'] = filtered_train_items_stores_holidays_events['date'].dt.year\nfiltered_train_items_stores_holidays_events['month'] = filtered_train_items_stores_holidays_events['date'].dt.month\nfiltered_train_items_stores_holidays_events['day'] = filtered_train_items_stores_holidays_events['date'].dt.day\nfiltered_train_items_stores_holidays_events['weekday'] = filtered_train_items_stores_holidays_events['date'].dt.weekday\n\nfiltered_train_items_stores_holidays_events.fillna({\"type_y\":\"Normal day\"}, inplace=True)  # Replace NaN in type_y with \"Unknown\"\nfiltered_train_items_stores_holidays_events.fillna({\"locale\":\"Unknown\"}, inplace=True)  # Replace NaN in onpromotion with False\nfiltered_train_items_stores_holidays_events.fillna({\"locale_name\":\"Unknown\"}, inplace=True)  # No holiday name\nfiltered_train_items_stores_holidays_events.fillna({\"description\":\"No Holiday\"}, inplace=True)  # No holiday description\nfiltered_train_items_stores_holidays_events.fillna({\"onpromotion\": False}, inplace=True)  # Replace NaN in onpromotion with False\nfiltered_train_items_stores_holidays_events.fillna({\"transferred\": False}, inplace=True)  # Replace NaN in transferred with False\nfiltered_train_items_stores_holidays_events['transferred'] = filtered_train_items_stores_holidays_events['transferred'].astype(int)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-11T06:16:58.169238Z","iopub.execute_input":"2025-03-11T06:16:58.169568Z","iopub.status.idle":"2025-03-11T06:16:58.394448Z","shell.execute_reply.started":"2025-03-11T06:16:58.169542Z","shell.execute_reply":"2025-03-11T06:16:58.393384Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Encode categorical variables\nencoder = LabelEncoder()\nencoded_city = encoder.fit_transform(filtered_train_items_stores_holidays_events['city'])\nencoded_type_y = encoder.fit_transform(filtered_train_items_stores_holidays_events['type_y'])\n\nfiltered_train_items_stores_holidays_events[\"encoded_city\"] = encoded_city\nfiltered_train_items_stores_holidays_events[\"encoded_type_y\"] = encoded_type_y","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-11T06:17:07.976723Z","iopub.execute_input":"2025-03-11T06:17:07.977112Z","iopub.status.idle":"2025-03-11T06:17:08.119514Z","shell.execute_reply.started":"2025-03-11T06:17:07.977082Z","shell.execute_reply":"2025-03-11T06:17:08.117941Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"unique_values_transferred = filtered_train_items_stores_holidays_events['city'].unique()\n\nprint(unique_values_transferred)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-11T06:17:49.517264Z","iopub.execute_input":"2025-03-11T06:17:49.517636Z","iopub.status.idle":"2025-03-11T06:17:49.544773Z","shell.execute_reply.started":"2025-03-11T06:17:49.517608Z","shell.execute_reply":"2025-03-11T06:17:49.543481Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"filtered_train_items_stores_holidays_events=filtered_train_items_stores_holidays_events.groupby(['date', 'year', 'month', 'day', 'weekday', 'encoded_city', 'encoded_type_y', 'transferred'], as_index=False).agg({\"unit_sales\": \"sum\"})\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-11T06:17:56.970088Z","iopub.execute_input":"2025-03-11T06:17:56.970423Z","iopub.status.idle":"2025-03-11T06:17:57.051674Z","shell.execute_reply.started":"2025-03-11T06:17:56.970397Z","shell.execute_reply":"2025-03-11T06:17:57.050783Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"filtered_train_items_stores_holidays_events.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-11T06:19:45.333958Z","iopub.execute_input":"2025-03-11T06:19:45.334397Z","iopub.status.idle":"2025-03-11T06:19:45.347907Z","shell.execute_reply.started":"2025-03-11T06:19:45.334365Z","shell.execute_reply":"2025-03-11T06:19:45.346688Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Normalize/Scale 'unit_sales' and other numeric features\nscaler = MinMaxScaler()\nfiltered_train_items_stores_holidays_events[['unit_sales']] = scaler.fit_transform(filtered_train_items_stores_holidays_events[['unit_sales']])\n\nprint(filtered_train_items_stores_holidays_events.head())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-11T06:19:25.188670Z","iopub.execute_input":"2025-03-11T06:19:25.189068Z","iopub.status.idle":"2025-03-11T06:19:25.201426Z","shell.execute_reply.started":"2025-03-11T06:19:25.189038Z","shell.execute_reply":"2025-03-11T06:19:25.200491Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Select features and target\nX = filtered_train_items_stores_holidays_events[['year', 'month', 'day', 'weekday', 'encoded_city', 'encoded_type_y', 'transferred']]\ny = filtered_train_items_stores_holidays_events['unit_sales']","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-11T06:23:43.129315Z","iopub.execute_input":"2025-03-11T06:23:43.129706Z","iopub.status.idle":"2025-03-11T06:23:43.136840Z","shell.execute_reply.started":"2025-03-11T06:23:43.129675Z","shell.execute_reply":"2025-03-11T06:23:43.135688Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Convert data into sequences for LSTM\nsequence_length = 10  # Adjust the sequence length based on your needs\ngenerator = TimeseriesGenerator(X.values, y.values, length=sequence_length, batch_size=32)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-11T06:26:57.028436Z","iopub.execute_input":"2025-03-11T06:26:57.028829Z","iopub.status.idle":"2025-03-11T06:26:57.035593Z","shell.execute_reply.started":"2025-03-11T06:26:57.028798Z","shell.execute_reply":"2025-03-11T06:26:57.034629Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Split the data into train and test sets\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, shuffle=False)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-11T06:27:16.985895Z","iopub.execute_input":"2025-03-11T06:27:16.986287Z","iopub.status.idle":"2025-03-11T06:27:16.994976Z","shell.execute_reply.started":"2025-03-11T06:27:16.986260Z","shell.execute_reply":"2025-03-11T06:27:16.993872Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Build the LSTM Model\nmodel = Sequential()\nmodel.add(LSTM(64, activation='relu', input_shape=(sequence_length, X_train.shape[1])))\nmodel.add(Dropout(0.2))\nmodel.add(Dense(1))  # Output layer for regression\n\n# Compile the model\nmodel.compile(optimizer='adam', loss='mean_squared_error')\n\n# Train the model\nmodel.fit(generator, epochs=50, verbose=1)\n\n# Evaluate the model\nX_test_reshaped = X_test.values.reshape((X_test.shape[0], 1, X_test.shape[1]))  # Adjust dimensions\nloss = model.evaluate(X_test_reshaped, y_test, verbose=0)\nprint(f'Model Loss: {loss}')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-11T06:34:15.757131Z","iopub.execute_input":"2025-03-11T06:34:15.757494Z","iopub.status.idle":"2025-03-11T06:34:48.948056Z","shell.execute_reply.started":"2025-03-11T06:34:15.757468Z","shell.execute_reply":"2025-03-11T06:34:48.946690Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import matplotlib.pyplot as plt\n\n# Assuming 'date' column is already in datetime format\nplt.figure(figsize=(12, 6))\n\n# Plot training data\nplt.plot(filtered_train_items_stores_holidays_events['date'][:len(X_train)], y_train, label=\"Train Data\", color='blue')\n\n# Plot test data\nplt.plot(filtered_train_items_stores_holidays_events['date'][len(X_train):], y_test, label=\"Test Data\", color='red')\n\nplt.xlabel('Date')\nplt.ylabel('Unit Sales')\nplt.title('Train vs Test Data')\nplt.legend()\nplt.show()\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-11T06:38:46.839643Z","iopub.execute_input":"2025-03-11T06:38:46.840061Z","iopub.status.idle":"2025-03-11T06:38:47.186494Z","shell.execute_reply.started":"2025-03-11T06:38:46.840031Z","shell.execute_reply":"2025-03-11T06:38:47.185339Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"date, unit_sales, city, type_y, transferred","metadata":{}},{"cell_type":"code","source":"train_items_stores_holidays_events.to_csv('/kaggle/working/train_items_stores_holidays_events.csv')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-11T04:01:48.633622Z","iopub.execute_input":"2025-03-11T04:01:48.634058Z","iopub.status.idle":"2025-03-11T04:01:52.327748Z","shell.execute_reply.started":"2025-03-11T04:01:48.634029Z","shell.execute_reply":"2025-03-11T04:01:52.326759Z"}},"outputs":[],"execution_count":null}]}