{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"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","execution":{"iopub.status.busy":"2022-08-09T07:06:40.972221Z","iopub.execute_input":"2022-08-09T07:06:40.972728Z","iopub.status.idle":"2022-08-09T07:06:41.008590Z","shell.execute_reply.started":"2022-08-09T07:06:40.972621Z","shell.execute_reply":"2022-08-09T07:06:41.007359Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Import necessary libraries and make necessary arrangements\nimport time\nimport numpy as np\nimport pandas as pd\nfrom matplotlib import pyplot as plt\nimport seaborn as sns\nimport xgboost \nimport lightgbm as lgb\nimport warnings\nfrom sklearn.preprocessing import LabelEncoder\n\npd.set_option('display.max_columns', None)\npd.set_option('display.width', 500)\nwarnings.filterwarnings('ignore')","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:06:48.338966Z","iopub.execute_input":"2022-08-09T07:06:48.339510Z","iopub.status.idle":"2022-08-09T07:06:50.324348Z","shell.execute_reply.started":"2022-08-09T07:06:48.339462Z","shell.execute_reply":"2022-08-09T07:06:50.323136Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\n# Date Features\ndef create_date_features(df):\n    df['month'] = df.Date.dt.month\n    df['day_of_month'] = df.Date.dt.day\n    df['day_of_year'] = df.Date.dt.dayofyear\n    df['week_of_year'] = df.Date.dt.weekofyear\n    df['day_of_week'] = df.Date.dt.dayofweek\n    df['year'] = df.Date.dt.year\n    #df[\"is_wknd\"] = df.Date.dt.weekday // 4\n    #df['is_month_start'] = df.Date.dt.is_month_start.astype(int)\n    #df['is_month_end'] = df.Date.dt.is_month_end.astype(int)\n    return df\n\n# Random Noise\ndef random_noise(dataframe):\n    return np.random.normal(scale=2.0, size=(len(dataframe),))\n\n# Lag/Shifted Features\ndef lag_features(dataframe, lags):\n    for lag in lags:\n        dataframe['sales_lag_' + str(lag)] = dataframe.groupby([\"store_nbr\", \"family\"])['sales'].transform(\n            lambda x: x.shift(lag)) + random_noise(dataframe)\n    return dataframe\n\n# Rolling Mean Features\ndef roll_mean_features(dataframe, windows):\n    for window in windows:\n        dataframe['sales_roll_mean_' + str(window)] = dataframe.groupby([\"store_nbr\", \"family\"])['sales']. \\\n                                                          transform(\n            lambda x: x.shift(16).rolling(window=window, min_periods=7, win_type=\"triang\").mean()) + random_noise(\n            dataframe)\n    return dataframe\n\n# Exponentially Weighted Mean Features\ndef ewm_features(dataframe, alphas, lags):\n    for alpha in alphas:\n        for lag in lags:\n            dataframe['sales_ewm_alpha_' + str(alpha).replace(\".\", \"\") + \"_lag_\" + str(lag)] = \\\n                dataframe.groupby([\"store_nbr\", \"family\"])['sales'].transform(lambda x: x.shift(lag).ewm(alpha=alpha).mean())\n    return dataframe\n\n\n# Feature Importance\ndef plot_lgb_importances(model, plot=False, num=10):\n\n    gain = model.feature_importance('gain')\n    feat_imp = pd.DataFrame({'feature': model.feature_name(),\n                             'split': model.feature_importance('split'),\n                             'gain': 100 * gain / gain.sum()}).sort_values('gain', ascending=False)\n    if plot:\n        plt.figure(figsize=(10, 10))\n        sns.set(font_scale=1)\n        sns.barplot(x=\"gain\", y=\"feature\", data=feat_imp[0:25])\n        plt.title('feature')\n        plt.tight_layout()\n        plt.show()\n    else:\n        print(feat_imp.head(num))\n        ","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:06:52.012381Z","iopub.execute_input":"2022-08-09T07:06:52.012856Z","iopub.status.idle":"2022-08-09T07:06:52.031540Z","shell.execute_reply.started":"2022-08-09T07:06:52.012815Z","shell.execute_reply":"2022-08-09T07:06:52.030153Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train=pd.read_csv(\"../input/store-sales-time-series-forecasting/train.csv\",index_col=0)\ndf_test =pd.read_csv(\"../input/store-sales-time-series-forecasting/test.csv\",index_col=0)\ndf_transactions = pd.read_csv(\"../input/store-sales-time-series-forecasting/transactions.csv\")\ndf_stores = pd.read_csv(\"../input/store-sales-time-series-forecasting/stores.csv\")\ndf_holidays = pd.read_csv(\"../input/store-sales-time-series-forecasting/holidays_events.csv\")\n\n\ndf_oil = pd.read_csv(\"../input/store-sales-time-series-forecasting/oil.csv\")\ndf_oil['date'] = df_oil['date'].astype(\"datetime64\")\ndf_date = pd.DataFrame(pd.date_range(\"2013-01-01\",\"2017-08-31\"),columns=[\"date\"])\ndf_oil = df_date.merge(df_oil,left_on='date',right_on='date',how='left').fillna(method='ffill').fillna(method='bfill')","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:06:59.378769Z","iopub.execute_input":"2022-08-09T07:06:59.379286Z","iopub.status.idle":"2022-08-09T07:07:04.865420Z","shell.execute_reply.started":"2022-08-09T07:06:59.379246Z","shell.execute_reply":"2022-08-09T07:07:04.864176Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_all = df_train.append(df_test)\ndf_all = df_all.merge(df_stores,left_on=\"store_nbr\",right_on=\"store_nbr\",how=\"left\")\ndf_holidays = df_holidays.rename(columns = {\"type\":\"Holiday_type\"})\ndf_all = df_all.merge(df_holidays,left_on=\"date\",right_on=\"date\",how=\"left\")\ndf_all = df_all.merge(df_transactions,left_on=[\"date\",\"store_nbr\"],right_on=[\"date\",\"store_nbr\"],how=\"left\")\ndf_all[\"date\"] = df_all[\"date\"].astype(\"datetime64\")\ndf_all = df_all.merge(df_oil,left_on=\"date\",right_on=\"date\",how=\"left\")\ndf_all = df_all.replace(\",\",\"_\",regex=True)\ndf_all = df_all.rename(columns = {\"date\":\"Date\"})","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:07:04.867303Z","iopub.execute_input":"2022-08-09T07:07:04.867693Z","iopub.status.idle":"2022-08-09T07:07:51.750016Z","shell.execute_reply.started":"2022-08-09T07:07:04.867655Z","shell.execute_reply":"2022-08-09T07:07:51.748829Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_all[\"family\"].unique()","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:07:51.751578Z","iopub.execute_input":"2022-08-09T07:07:51.751937Z","iopub.status.idle":"2022-08-09T07:07:51.990258Z","shell.execute_reply.started":"2022-08-09T07:07:51.751903Z","shell.execute_reply":"2022-08-09T07:07:51.989055Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_all.columns","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:07:51.994139Z","iopub.execute_input":"2022-08-09T07:07:51.994539Z","iopub.status.idle":"2022-08-09T07:07:52.002589Z","shell.execute_reply.started":"2022-08-09T07:07:51.994502Z","shell.execute_reply":"2022-08-09T07:07:52.001105Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_all[\"description\"].nunique(),df_all[\"transferred\"].nunique()","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:07:52.004003Z","iopub.execute_input":"2022-08-09T07:07:52.004522Z","iopub.status.idle":"2022-08-09T07:07:52.322784Z","shell.execute_reply.started":"2022-08-09T07:07:52.004469Z","shell.execute_reply":"2022-08-09T07:07:52.321528Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_all[(df_all[\"store_nbr\"]==9) & (df_all[\"family\"]==\"AUTOMOTIVE\")].tail(10)","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:07:52.324459Z","iopub.execute_input":"2022-08-09T07:07:52.325800Z","iopub.status.idle":"2022-08-09T07:07:52.566067Z","shell.execute_reply.started":"2022-08-09T07:07:52.325731Z","shell.execute_reply":"2022-08-09T07:07:52.564829Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"col = ['Date',\n       'store_nbr', \n       'family', \n       'sales', \n       'onpromotion', \n       #'city', \n       #'state',\n       #'type', \n       'cluster', \n       'Holiday_type', \n       'locale', \n       #'locale_name',\n       'description', \n       'transferred',\n       'dcoilwtico'\n      ]\ndf = df_all[col]","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:07:52.567801Z","iopub.execute_input":"2022-08-09T07:07:52.568135Z","iopub.status.idle":"2022-08-09T07:07:52.799076Z","shell.execute_reply.started":"2022-08-09T07:07:52.568105Z","shell.execute_reply":"2022-08-09T07:07:52.797804Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:07:52.800530Z","iopub.execute_input":"2022-08-09T07:07:52.800896Z","iopub.status.idle":"2022-08-09T07:07:52.819557Z","shell.execute_reply.started":"2022-08-09T07:07:52.800863Z","shell.execute_reply":"2022-08-09T07:07:52.818357Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df[\"store_nbr\"].nunique(),df[\"family\"].nunique()","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:07:52.820718Z","iopub.execute_input":"2022-08-09T07:07:52.821900Z","iopub.status.idle":"2022-08-09T07:07:53.087005Z","shell.execute_reply.started":"2022-08-09T07:07:52.821857Z","shell.execute_reply":"2022-08-09T07:07:53.085729Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.loc[:,\"store_nbr\"] = df[\"store_nbr\"].astype(\"category\")\ndf.loc[:,\"family\"] = df[\"family\"].astype(\"category\")\ndf.loc[:,\"onpromotion\"] = df[\"onpromotion\"].astype(\"int64\")\n#df.loc[:,\"city\"] = df[\"city\"].astype(\"category\")\n#df.loc[:,\"state\"] = df[\"state\"].astype(\"category\")\n#df.loc[:,\"type\"] = df[\"type\"].astype(\"category\")\ndf.loc[:,\"Holiday_type\"] = df[\"Holiday_type\"].astype(\"category\")\ndf.loc[:,\"locale\"] = df[\"locale\"].astype(\"category\")\n#df.loc[:,\"locale_name\"] = df[\"locale_name\"].astype(\"category\")\ndf.loc[:,\"description\"] = df[\"description\"].astype(\"category\")\ndf.loc[:,\"transferred\"] = df[\"transferred\"].astype(\"category\")","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:07:53.089977Z","iopub.execute_input":"2022-08-09T07:07:53.090456Z","iopub.status.idle":"2022-08-09T07:07:54.743361Z","shell.execute_reply.started":"2022-08-09T07:07:53.090403Z","shell.execute_reply":"2022-08-09T07:07:54.742050Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"zero_index = df.groupby([\"store_nbr\",\"family\"]).sum()[df.groupby([\"store_nbr\",\"family\"]).sum()[\"sales\"]==0].index","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:07:54.745187Z","iopub.execute_input":"2022-08-09T07:07:54.745683Z","iopub.status.idle":"2022-08-09T07:07:55.179160Z","shell.execute_reply.started":"2022-08-09T07:07:54.745633Z","shell.execute_reply":"2022-08-09T07:07:55.178041Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Data Engineering","metadata":{"execution":{"iopub.status.busy":"2022-08-08T01:41:06.102058Z","iopub.status.idle":"2022-08-08T01:41:06.103071Z","shell.execute_reply.started":"2022-08-08T01:41:06.102792Z","shell.execute_reply":"2022-08-08T01:41:06.102819Z"}}},{"cell_type":"code","source":"df = create_date_features(df)\ndf = lag_features(df, lags = [16,17,18,19,20,21,22,30,31,90,180,365])\ndf = roll_mean_features(df,[16,17,18,30])\n\nalphas = [0.95,0.9, 0.8, 0.5]\nlags =[1, 7,30]\ndf = ewm_features(df, alphas, lags)\n\ndf['sales'] = np.log1p(df[\"sales\"].values)","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:07:55.180515Z","iopub.execute_input":"2022-08-09T07:07:55.180867Z","iopub.status.idle":"2022-08-09T07:08:45.298936Z","shell.execute_reply.started":"2022-08-09T07:07:55.180833Z","shell.execute_reply":"2022-08-09T07:08:45.297691Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_all[\"family\"]=df_all[\"family\"].astype(\"category\")\ndf_all[\"store_nbr\"]=df_all[\"store_nbr\"].astype(\"category\")\ndf_all[\"city\"]=df_all[\"city\"].astype(\"category\")\ndf_all[\"state\"]=df_all[\"state\"].astype(\"category\")\ndf_all[\"type\"]=df_all[\"type\"].astype(\"category\")","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:09:00.552944Z","iopub.execute_input":"2022-08-09T07:09:00.553386Z","iopub.status.idle":"2022-08-09T07:09:03.290024Z","shell.execute_reply.started":"2022-08-09T07:09:00.553348Z","shell.execute_reply":"2022-08-09T07:09:03.288591Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Train Test Split","metadata":{}},{"cell_type":"code","source":"df= df[df[\"Date\"]>\"2013-12-31\"]\n\nval = df[(df[\"Date\"]>\"2017-08-01\")&(df[\"Date\"]<=\"2017-08-15\")]\ntrain  = df[df[\"Date\"]<=\"2017-08-01\"]\ntest = df[df[\"Date\"]>\"2017-08-15\"]\n\ncol_X = [col for col in train.columns if col not in ['Date', 'sales','year']]\n\ny_train = train[\"sales\"]\ny_val = val[\"sales\"]\nX_train = train[col_X]\nX_val = val[col_X]\nX_test = test[col_X]\ny_test = test[\"sales\"]","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:09:04.974407Z","iopub.execute_input":"2022-08-09T07:09:04.974833Z","iopub.status.idle":"2022-08-09T07:09:07.200805Z","shell.execute_reply.started":"2022-08-09T07:09:04.974794Z","shell.execute_reply":"2022-08-09T07:09:07.199547Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Train Model","metadata":{}},{"cell_type":"code","source":"# LightGBM parameters\nlgb_params = {'metric': {'mse'},\n              'boosting_type' : 'gbdt',\n              'num_leaves': 8,\n              'learning_rate': 0.2,\n              #'feature_fraction': 0.8,\n              'max_depth': 7,\n              'verbose': 0,\n              'num_boost_round': 5000,\n              'early_stopping_rounds': 200,\n              'nthread': -1,\n             'force_col_wise':True}\n\nlgbtrain = lgb.Dataset(data=X_train, label=y_train, feature_name=col_X)\nlgbtest = lgb.Dataset(data=X_val, label=y_val, reference=lgbtrain, feature_name=col_X)\n\n#del Y_train, X_train, Y_test,X_test","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:09:17.095863Z","iopub.execute_input":"2022-08-09T07:09:17.097070Z","iopub.status.idle":"2022-08-09T07:09:17.103791Z","shell.execute_reply.started":"2022-08-09T07:09:17.097024Z","shell.execute_reply":"2022-08-09T07:09:17.102514Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import mean_absolute_error\nmodel = lgb.train(lgb_params, lgbtrain,\n                  valid_sets=[lgbtrain, lgbtest],\n                  num_boost_round=lgb_params['num_boost_round'],\n                  early_stopping_rounds=lgb_params['early_stopping_rounds'],\n                  #feval=mean_absolute_error,\n                  verbose_eval=100,\n                  )","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:09:23.541471Z","iopub.execute_input":"2022-08-09T07:09:23.541933Z","iopub.status.idle":"2022-08-09T07:21:11.647362Z","shell.execute_reply.started":"2022-08-09T07:09:23.541893Z","shell.execute_reply":"2022-08-09T07:21:11.645567Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_pred_val = model.predict(X_val, num_iteration=model.best_iteration)","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:21:23.460240Z","iopub.execute_input":"2022-08-09T07:21:23.460670Z","iopub.status.idle":"2022-08-09T07:21:25.298086Z","shell.execute_reply.started":"2022-08-09T07:21:23.460633Z","shell.execute_reply":"2022-08-09T07:21:25.296823Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import mean_squared_log_error","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:21:27.270914Z","iopub.execute_input":"2022-08-09T07:21:27.271336Z","iopub.status.idle":"2022-08-09T07:21:27.276791Z","shell.execute_reply.started":"2022-08-09T07:21:27.271300Z","shell.execute_reply":"2022-08-09T07:21:27.275721Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_pred_val[y_pred_val<0]=0","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:21:29.423197Z","iopub.execute_input":"2022-08-09T07:21:29.423680Z","iopub.status.idle":"2022-08-09T07:21:29.430424Z","shell.execute_reply.started":"2022-08-09T07:21:29.423639Z","shell.execute_reply":"2022-08-09T07:21:29.429069Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mean_squared_log_error(np.expm1(y_val), np.expm1(y_pred_val))","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:21:30.480638Z","iopub.execute_input":"2022-08-09T07:21:30.481576Z","iopub.status.idle":"2022-08-09T07:21:30.493137Z","shell.execute_reply.started":"2022-08-09T07:21:30.481520Z","shell.execute_reply":"2022-08-09T07:21:30.492066Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.scatter(np.expm1(y_val),np.expm1(y_pred_val))","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:21:33.942784Z","iopub.execute_input":"2022-08-09T07:21:33.943293Z","iopub.status.idle":"2022-08-09T07:21:34.256542Z","shell.execute_reply.started":"2022-08-09T07:21:33.943253Z","shell.execute_reply":"2022-08-09T07:21:34.255268Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.feature_importance()","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:21:40.935756Z","iopub.execute_input":"2022-08-09T07:21:40.936303Z","iopub.status.idle":"2022-08-09T07:21:40.948700Z","shell.execute_reply.started":"2022-08-09T07:21:40.936257Z","shell.execute_reply":"2022-08-09T07:21:40.947161Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.feature_name()","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:21:43.589437Z","iopub.execute_input":"2022-08-09T07:21:43.589911Z","iopub.status.idle":"2022-08-09T07:21:43.598614Z","shell.execute_reply.started":"2022-08-09T07:21:43.589871Z","shell.execute_reply":"2022-08-09T07:21:43.597271Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Submission","metadata":{"execution":{"iopub.status.busy":"2022-08-09T07:22:22.184835Z","iopub.execute_input":"2022-08-09T07:22:22.185343Z","iopub.status.idle":"2022-08-09T07:22:22.190529Z","shell.execute_reply.started":"2022-08-09T07:22:22.185295Z","shell.execute_reply":"2022-08-09T07:22:22.189396Z"}}},{"cell_type":"code","source":"submission = pd.read_csv(\"../input/store-sales-time-series-forecasting/sample_submission.csv\")\ny_test = model.predict(X_test, num_iteration=model.best_iteration)","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:01:04.136180Z","iopub.execute_input":"2022-08-09T08:01:04.136647Z","iopub.status.idle":"2022-08-09T08:01:06.155979Z","shell.execute_reply.started":"2022-08-09T08:01:04.136606Z","shell.execute_reply":"2022-08-09T08:01:06.154871Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_test[y_test<0]=0","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:01:06.157943Z","iopub.execute_input":"2022-08-09T08:01:06.158619Z","iopub.status.idle":"2022-08-09T08:01:06.163284Z","shell.execute_reply.started":"2022-08-09T08:01:06.158578Z","shell.execute_reply":"2022-08-09T08:01:06.162152Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission[\"sales\"] = np.expm1(y_test)","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:01:18.056317Z","iopub.execute_input":"2022-08-09T08:01:18.056720Z","iopub.status.idle":"2022-08-09T08:01:18.062862Z","shell.execute_reply.started":"2022-08-09T08:01:18.056685Z","shell.execute_reply":"2022-08-09T08:01:18.061600Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.to_csv(\"submission.csv\",index=False)","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:01:24.429517Z","iopub.execute_input":"2022-08-09T08:01:24.429934Z","iopub.status.idle":"2022-08-09T08:01:24.504318Z","shell.execute_reply.started":"2022-08-09T08:01:24.429896Z","shell.execute_reply":"2022-08-09T08:01:24.503064Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:01:25.390981Z","iopub.execute_input":"2022-08-09T08:01:25.391398Z","iopub.status.idle":"2022-08-09T08:01:25.404659Z","shell.execute_reply.started":"2022-08-09T08:01:25.391360Z","shell.execute_reply":"2022-08-09T08:01:25.403288Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}