{"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-07-25T04:33:42.792788Z","iopub.execute_input":"2022-07-25T04:33:42.793297Z","iopub.status.idle":"2022-07-25T04:33:42.823948Z","shell.execute_reply.started":"2022-07-25T04:33:42.793198Z","shell.execute_reply":"2022-07-25T04:33:42.823079Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install chart_studio\n!pip install cufflinks","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:33:42.825550Z","iopub.execute_input":"2022-07-25T04:33:42.826184Z","iopub.status.idle":"2022-07-25T04:34:09.565345Z","shell.execute_reply.started":"2022-07-25T04:33:42.826152Z","shell.execute_reply":"2022-07-25T04:34:09.563841Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import chart_studio.plotly as py\nimport plotly.express as px\nimport seaborn as sns\nimport cufflinks as cf\nimport plotly.graph_objects as go\nfrom plotly.offline import download_plotlyjs,init_notebook_mode,plot,iplot\ninit_notebook_mode(connected = True)\ncf.go_offline()","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:09.568188Z","iopub.execute_input":"2022-07-25T04:34:09.568585Z","iopub.status.idle":"2022-07-25T04:34:12.658939Z","shell.execute_reply.started":"2022-07-25T04:34:09.568543Z","shell.execute_reply":"2022-07-25T04:34:12.657740Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"holidays_events = pd.read_csv('../input/store-sales-time-series-forecasting/holidays_events.csv')\ntransaction = pd.read_csv('../input/store-sales-time-series-forecasting/transactions.csv')\noil = pd.read_csv('../input/store-sales-time-series-forecasting/oil.csv')\nstores = pd.read_csv('../input/store-sales-time-series-forecasting/stores.csv')\ntrain = pd.read_csv('../input/store-sales-time-series-forecasting/train.csv')\ntest = pd.read_csv('../input/store-sales-time-series-forecasting/test.csv')","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:12.661468Z","iopub.execute_input":"2022-07-25T04:34:12.661908Z","iopub.status.idle":"2022-07-25T04:34:15.739950Z","shell.execute_reply.started":"2022-07-25T04:34:12.661873Z","shell.execute_reply":"2022-07-25T04:34:15.738268Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"holidays_events.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:15.741354Z","iopub.execute_input":"2022-07-25T04:34:15.741898Z","iopub.status.idle":"2022-07-25T04:34:15.758301Z","shell.execute_reply.started":"2022-07-25T04:34:15.741859Z","shell.execute_reply":"2022-07-25T04:34:15.756962Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"oil.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:15.760289Z","iopub.execute_input":"2022-07-25T04:34:15.761050Z","iopub.status.idle":"2022-07-25T04:34:15.779732Z","shell.execute_reply.started":"2022-07-25T04:34:15.760997Z","shell.execute_reply":"2022-07-25T04:34:15.778220Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"stores.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:15.783339Z","iopub.execute_input":"2022-07-25T04:34:15.784195Z","iopub.status.idle":"2022-07-25T04:34:15.798448Z","shell.execute_reply.started":"2022-07-25T04:34:15.784110Z","shell.execute_reply":"2022-07-25T04:34:15.796939Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"transaction.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:15.800186Z","iopub.execute_input":"2022-07-25T04:34:15.800888Z","iopub.status.idle":"2022-07-25T04:34:15.827813Z","shell.execute_reply.started":"2022-07-25T04:34:15.800840Z","shell.execute_reply":"2022-07-25T04:34:15.825676Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:15.830023Z","iopub.execute_input":"2022-07-25T04:34:15.831008Z","iopub.status.idle":"2022-07-25T04:34:16.122846Z","shell.execute_reply.started":"2022-07-25T04:34:15.830932Z","shell.execute_reply":"2022-07-25T04:34:16.121605Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"oil['dcoilwtico'] = oil['dcoilwtico'].fillna(oil['dcoilwtico'].mean())","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:16.127082Z","iopub.execute_input":"2022-07-25T04:34:16.127504Z","iopub.status.idle":"2022-07-25T04:34:16.139025Z","shell.execute_reply.started":"2022-07-25T04:34:16.127472Z","shell.execute_reply":"2022-07-25T04:34:16.137459Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"stores.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:16.140744Z","iopub.execute_input":"2022-07-25T04:34:16.141175Z","iopub.status.idle":"2022-07-25T04:34:16.165126Z","shell.execute_reply.started":"2022-07-25T04:34:16.141138Z","shell.execute_reply":"2022-07-25T04:34:16.163782Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"oil.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:16.167087Z","iopub.execute_input":"2022-07-25T04:34:16.168128Z","iopub.status.idle":"2022-07-25T04:34:16.181544Z","shell.execute_reply.started":"2022-07-25T04:34:16.168079Z","shell.execute_reply":"2022-07-25T04:34:16.180629Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:16.184059Z","iopub.execute_input":"2022-07-25T04:34:16.184475Z","iopub.status.idle":"2022-07-25T04:34:16.203427Z","shell.execute_reply.started":"2022-07-25T04:34:16.184440Z","shell.execute_reply":"2022-07-25T04:34:16.202338Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"holidays_events.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:16.205014Z","iopub.execute_input":"2022-07-25T04:34:16.206284Z","iopub.status.idle":"2022-07-25T04:34:16.229734Z","shell.execute_reply.started":"2022-07-25T04:34:16.206235Z","shell.execute_reply":"2022-07-25T04:34:16.228578Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dataset = pd.merge(train,stores,on = 'store_nbr')\ndataset","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:16.231481Z","iopub.execute_input":"2022-07-25T04:34:16.232257Z","iopub.status.idle":"2022-07-25T04:34:17.160109Z","shell.execute_reply.started":"2022-07-25T04:34:16.232212Z","shell.execute_reply":"2022-07-25T04:34:17.158860Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"holidays_events = holidays_events.drop(columns = ['description','locale'])\ndataset = dataset.merge(holidays_events,how='left', left_on='date', right_on='date')\ndataset","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:17.161636Z","iopub.execute_input":"2022-07-25T04:34:17.162056Z","iopub.status.idle":"2022-07-25T04:34:18.240889Z","shell.execute_reply.started":"2022-07-25T04:34:17.162022Z","shell.execute_reply":"2022-07-25T04:34:18.240055Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dataset = dataset.merge(oil,how = 'left',left_on = 'date',right_on = 'date')\ndataset","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:18.242332Z","iopub.execute_input":"2022-07-25T04:34:18.242709Z","iopub.status.idle":"2022-07-25T04:34:19.301091Z","shell.execute_reply.started":"2022-07-25T04:34:18.242676Z","shell.execute_reply":"2022-07-25T04:34:19.299836Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dataset.rename(columns={'type_y':'day_type'},inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:19.302510Z","iopub.execute_input":"2022-07-25T04:34:19.302887Z","iopub.status.idle":"2022-07-25T04:34:19.308693Z","shell.execute_reply.started":"2022-07-25T04:34:19.302854Z","shell.execute_reply":"2022-07-25T04:34:19.307733Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dataset['day_type'] = dataset['day_type'].fillna('Normal')\ndataset","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:19.309959Z","iopub.execute_input":"2022-07-25T04:34:19.310616Z","iopub.status.idle":"2022-07-25T04:34:19.559245Z","shell.execute_reply.started":"2022-07-25T04:34:19.310577Z","shell.execute_reply":"2022-07-25T04:34:19.557810Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import datetime as dt\ndataset['date'] = pd.to_datetime(dataset['date']) \ndataset['day'] = dataset['date'].dt.day_name()\ndataset['month'] = dataset['date'].dt.month\ndataset['year'] = dataset['date'].dt.year\ndataset['day_of_week'] = dataset['date'].dt.dayofweek\ndataset['day_of_week']\ndataset","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:19.561382Z","iopub.execute_input":"2022-07-25T04:34:19.562107Z","iopub.status.idle":"2022-07-25T04:34:21.786829Z","shell.execute_reply.started":"2022-07-25T04:34:19.562069Z","shell.execute_reply":"2022-07-25T04:34:21.785602Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dataset.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:21.788061Z","iopub.execute_input":"2022-07-25T04:34:21.788390Z","iopub.status.idle":"2022-07-25T04:34:22.825066Z","shell.execute_reply.started":"2022-07-25T04:34:21.788361Z","shell.execute_reply":"2022-07-25T04:34:22.823782Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dataset.drop(columns = ['locale_name','transferred','dcoilwtico'],inplace = True)","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:22.827084Z","iopub.execute_input":"2022-07-25T04:34:22.827740Z","iopub.status.idle":"2022-07-25T04:34:24.370152Z","shell.execute_reply.started":"2022-07-25T04:34:22.827705Z","shell.execute_reply":"2022-07-25T04:34:24.368712Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import scipy.stats as st\nfrom math import ceil\n\ndef sample_size(N,confidence_level,margin,proportion):\n    z = st.norm.ppf(1-(1 - confidence_level) / 2)\n    n0 = z**2 * proportion * (1 - proportion) / margin**2\n    n = n0 / (1 + (n0 - 1) / N)\n    n = ceil(n)\n    return n","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:24.371598Z","iopub.execute_input":"2022-07-25T04:34:24.371993Z","iopub.status.idle":"2022-07-25T04:34:24.379953Z","shell.execute_reply.started":"2022-07-25T04:34:24.371961Z","shell.execute_reply":"2022-07-25T04:34:24.378623Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sampleSize = sample_size(len(dataset),0.95,0.05,0.5) \nsampleSize","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:24.381816Z","iopub.execute_input":"2022-07-25T04:34:24.382211Z","iopub.status.idle":"2022-07-25T04:34:24.401823Z","shell.execute_reply.started":"2022-07-25T04:34:24.382178Z","shell.execute_reply":"2022-07-25T04:34:24.399513Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sampleData = dataset.sample(sampleSize)","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:24.404269Z","iopub.execute_input":"2022-07-25T04:34:24.405277Z","iopub.status.idle":"2022-07-25T04:34:24.598927Z","shell.execute_reply.started":"2022-07-25T04:34:24.405217Z","shell.execute_reply":"2022-07-25T04:34:24.597334Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:24.600916Z","iopub.execute_input":"2022-07-25T04:34:24.601302Z","iopub.status.idle":"2022-07-25T04:34:24.608279Z","shell.execute_reply.started":"2022-07-25T04:34:24.601270Z","shell.execute_reply":"2022-07-25T04:34:24.606595Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.set(rc = {'figure.figsize':(16,8)})\nax = sns.barplot('family','sales',data = sampleData)\nplt.xticks(rotation=90)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:24.610312Z","iopub.execute_input":"2022-07-25T04:34:24.611088Z","iopub.status.idle":"2022-07-25T04:34:26.033858Z","shell.execute_reply.started":"2022-07-25T04:34:24.611040Z","shell.execute_reply":"2022-07-25T04:34:26.032694Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.set(rc = {'figure.figsize':(22,15)})\nax = sns.boxplot(x=\"city\", y=\"sales\", data=sampleData)","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:26.041916Z","iopub.execute_input":"2022-07-25T04:34:26.042341Z","iopub.status.idle":"2022-07-25T04:34:26.702446Z","shell.execute_reply.started":"2022-07-25T04:34:26.042308Z","shell.execute_reply":"2022-07-25T04:34:26.701245Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(dataset[(dataset['city']=='Quito') & (dataset['sales']>2000)])","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:26.704024Z","iopub.execute_input":"2022-07-25T04:34:26.704436Z","iopub.status.idle":"2022-07-25T04:34:26.950384Z","shell.execute_reply.started":"2022-07-25T04:34:26.704402Z","shell.execute_reply":"2022-07-25T04:34:26.949006Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(dataset[(dataset['city']=='Guayaquil') & (dataset['sales']>2000)])","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:26.951589Z","iopub.execute_input":"2022-07-25T04:34:26.951917Z","iopub.status.idle":"2022-07-25T04:34:27.169053Z","shell.execute_reply.started":"2022-07-25T04:34:26.951889Z","shell.execute_reply":"2022-07-25T04:34:27.167543Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"px.bar(sampleData,x = 'type_x',y = 'sales',color = 'day_type')","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:27.170539Z","iopub.execute_input":"2022-07-25T04:34:27.170913Z","iopub.status.idle":"2022-07-25T04:34:28.165002Z","shell.execute_reply.started":"2022-07-25T04:34:27.170881Z","shell.execute_reply":"2022-07-25T04:34:28.163763Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"px.bar(sampleData,x = 'family',y = 'sales',color = 'day_type')","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:28.166670Z","iopub.execute_input":"2022-07-25T04:34:28.167129Z","iopub.status.idle":"2022-07-25T04:34:28.260920Z","shell.execute_reply.started":"2022-07-25T04:34:28.167084Z","shell.execute_reply":"2022-07-25T04:34:28.259683Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"px.pie(sampleData,values = 'sales',names = 'day_type',title = 'Sales and Day Type',hover_name = 'day_type')","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:28.262219Z","iopub.execute_input":"2022-07-25T04:34:28.262612Z","iopub.status.idle":"2022-07-25T04:34:28.337831Z","shell.execute_reply.started":"2022-07-25T04:34:28.262578Z","shell.execute_reply":"2022-07-25T04:34:28.336571Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"px.pie(sampleData,values = 'sales',names = 'type_x',title = 'Sales and Type',hover_name = 'type_x')","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:28.339410Z","iopub.execute_input":"2022-07-25T04:34:28.339769Z","iopub.status.idle":"2022-07-25T04:34:28.400905Z","shell.execute_reply.started":"2022-07-25T04:34:28.339741Z","shell.execute_reply":"2022-07-25T04:34:28.399603Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"px.bar(sampleData,x = 'day',y = 'sales',color = 'type_x',title = 'Day vs Sales')","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:28.402229Z","iopub.execute_input":"2022-07-25T04:34:28.402579Z","iopub.status.idle":"2022-07-25T04:34:28.486310Z","shell.execute_reply.started":"2022-07-25T04:34:28.402549Z","shell.execute_reply":"2022-07-25T04:34:28.485391Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"px.bar(sampleData,x = 'month',y = 'sales',color = 'day_type')","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:28.487481Z","iopub.execute_input":"2022-07-25T04:34:28.488055Z","iopub.status.idle":"2022-07-25T04:34:28.579748Z","shell.execute_reply.started":"2022-07-25T04:34:28.488020Z","shell.execute_reply":"2022-07-25T04:34:28.577943Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"px.bar(sampleData,x = 'month',y = 'sales',color = 'family')","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:28.581218Z","iopub.execute_input":"2022-07-25T04:34:28.581902Z","iopub.status.idle":"2022-07-25T04:34:28.782365Z","shell.execute_reply.started":"2022-07-25T04:34:28.581862Z","shell.execute_reply":"2022-07-25T04:34:28.781209Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.bar(sampleData,x = 'store_nbr',y = 'sales',title = 'Stores vs Sales',color = 'type_x')\nfig.update_layout(uniformtext_minsize = 8)\nfig","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:28.783952Z","iopub.execute_input":"2022-07-25T04:34:28.784319Z","iopub.status.idle":"2022-07-25T04:34:28.874744Z","shell.execute_reply.started":"2022-07-25T04:34:28.784288Z","shell.execute_reply":"2022-07-25T04:34:28.873306Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# This graph shows sales of each city over years","metadata":{}},{"cell_type":"code","source":"px.density_heatmap(sampleData,x = 'city',y = 'year',z = 'sales',color_continuous_scale = 'Viridis')","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:28.876647Z","iopub.execute_input":"2022-07-25T04:34:28.877123Z","iopub.status.idle":"2022-07-25T04:34:28.974211Z","shell.execute_reply.started":"2022-07-25T04:34:28.877080Z","shell.execute_reply":"2022-07-25T04:34:28.972797Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"px.bar(sampleData,x = 'cluster',y='sales',color = 'day_type',range_y = [0,50000])","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:28.975807Z","iopub.execute_input":"2022-07-25T04:34:28.976578Z","iopub.status.idle":"2022-07-25T04:34:29.065348Z","shell.execute_reply.started":"2022-07-25T04:34:28.976535Z","shell.execute_reply":"2022-07-25T04:34:29.064196Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X = dataset[['store_nbr','onpromotion','family','month','day','type_x','day_type','cluster']]\nX","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:29.066857Z","iopub.execute_input":"2022-07-25T04:34:29.067858Z","iopub.status.idle":"2022-07-25T04:34:29.263603Z","shell.execute_reply.started":"2022-07-25T04:34:29.067821Z","shell.execute_reply":"2022-07-25T04:34:29.262366Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.preprocessing import LabelEncoder\nfrom sklearn.model_selection import train_test_split","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:29.264712Z","iopub.execute_input":"2022-07-25T04:34:29.265469Z","iopub.status.idle":"2022-07-25T04:34:29.398556Z","shell.execute_reply.started":"2022-07-25T04:34:29.265436Z","shell.execute_reply":"2022-07-25T04:34:29.397435Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"le = LabelEncoder()\nX['day'] = le.fit_transform(X['day'])\nX['family'] = le.fit_transform(X['family'])\nX['type_x'] = le.fit_transform(X['type_x'])\nX","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:29.400056Z","iopub.execute_input":"2022-07-25T04:34:29.400510Z","iopub.status.idle":"2022-07-25T04:34:32.003666Z","shell.execute_reply.started":"2022-07-25T04:34:29.400474Z","shell.execute_reply":"2022-07-25T04:34:32.002474Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X['day_type'] = le.fit_transform(X['day_type'])\nX","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:32.005201Z","iopub.execute_input":"2022-07-25T04:34:32.005979Z","iopub.status.idle":"2022-07-25T04:34:32.710192Z","shell.execute_reply.started":"2022-07-25T04:34:32.005941Z","shell.execute_reply":"2022-07-25T04:34:32.708951Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y = dataset['sales']\ny","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:32.711653Z","iopub.execute_input":"2022-07-25T04:34:32.712037Z","iopub.status.idle":"2022-07-25T04:34:32.721624Z","shell.execute_reply.started":"2022-07-25T04:34:32.711995Z","shell.execute_reply":"2022-07-25T04:34:32.720410Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train,X_test,y_train,y_test = train_test_split(X,y,test_size = 0.2)\nX_train.shape,X_test.shape,y_train.shape,y_test.shape","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:32.723140Z","iopub.execute_input":"2022-07-25T04:34:32.724209Z","iopub.status.idle":"2022-07-25T04:34:33.734785Z","shell.execute_reply.started":"2022-07-25T04:34:32.724159Z","shell.execute_reply":"2022-07-25T04:34:33.733611Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.ensemble import RandomForestRegressor\nRFR = RandomForestRegressor(n_estimators = 10)\nRFR.fit(X_train,y_train)","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:34:33.736407Z","iopub.execute_input":"2022-07-25T04:34:33.736771Z","iopub.status.idle":"2022-07-25T04:35:59.023752Z","shell.execute_reply.started":"2022-07-25T04:34:33.736743Z","shell.execute_reply":"2022-07-25T04:35:59.022603Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"RFR.score(X_train,y_train)","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:35:59.025470Z","iopub.execute_input":"2022-07-25T04:35:59.026194Z","iopub.status.idle":"2022-07-25T04:36:20.655017Z","shell.execute_reply.started":"2022-07-25T04:35:59.026152Z","shell.execute_reply":"2022-07-25T04:36:20.653782Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"RFR.score(X_test,y_test)","metadata":{"execution":{"iopub.status.busy":"2022-07-25T04:36:20.656381Z","iopub.execute_input":"2022-07-25T04:36:20.657311Z","iopub.status.idle":"2022-07-25T04:36:26.191252Z","shell.execute_reply.started":"2022-07-25T04:36:20.657277Z","shell.execute_reply":"2022-07-25T04:36:26.190304Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}