{"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":"#importing libraries \n\nimport pandas as pd\nimport numpy as np\nimport time\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nfrom scipy.stats import randint\nfrom sklearn.impute import SimpleImputer\nfrom sklearn.pipeline import make_pipeline\nfrom sklearn.compose import ColumnTransformer\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.feature_selection import RFECV\nfrom sklearn.decomposition import PCA\nfrom sklearn.feature_selection import chi2, VarianceThreshold\nfrom sklearn.metrics import mean_squared_error, mean_absolute_error, mean_absolute_percentage_error, r2_score\nfrom sklearn.preprocessing import StandardScaler, MinMaxScaler\nfrom sklearn.preprocessing import OneHotEncoder , LabelEncoder\nfrom sklearn.preprocessing import OrdinalEncoder\nfrom sklearn.model_selection import GridSearchCV, RandomizedSearchCV\nfrom sklearn.ensemble import RandomForestRegressor, GradientBoostingRegressor\nfrom xgboost import XGBRegressor\n\n# reading data CVS to dataframe\n\ndata = pd.read_csv(\"../input/house-prices-advanced-regression-techniques/train.csv\") \n","metadata":{"id":"A_C6T4IeTzOF","execution":{"iopub.status.busy":"2022-08-06T10:52:17.329686Z","iopub.execute_input":"2022-08-06T10:52:17.330143Z","iopub.status.idle":"2022-08-06T10:52:17.358208Z","shell.execute_reply.started":"2022-08-06T10:52:17.330098Z","shell.execute_reply":"2022-08-06T10:52:17.357007Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data=data.set_index('Id') #for reseting index as Id\ndata.head()","metadata":{"id":"2ebK7tLCwFfD","outputId":"4f3305b4-a080-4fa4-f9a7-15cc00c208d8","execution":{"iopub.status.busy":"2022-08-06T10:52:17.360109Z","iopub.execute_input":"2022-08-06T10:52:17.360484Z","iopub.status.idle":"2022-08-06T10:52:17.388789Z","shell.execute_reply.started":"2022-08-06T10:52:17.360449Z","shell.execute_reply":"2022-08-06T10:52:17.387396Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data['MSZoning'].apply(str)","metadata":{"id":"yl6t4k1qfiOZ","outputId":"617ad8be-f9b2-4815-8b25-2791aaee08e6","execution":{"iopub.status.busy":"2022-08-06T10:52:17.391001Z","iopub.execute_input":"2022-08-06T10:52:17.391356Z","iopub.status.idle":"2022-08-06T10:52:17.401396Z","shell.execute_reply.started":"2022-08-06T10:52:17.391322Z","shell.execute_reply":"2022-08-06T10:52:17.400217Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.isna().sum().sort_values(ascending = False) # to see nan values","metadata":{"id":"rXUa3Yy90lQv","outputId":"b161851b-ce89-4d49-8a61-33552c4d29da","execution":{"iopub.status.busy":"2022-08-06T10:52:17.402916Z","iopub.execute_input":"2022-08-06T10:52:17.403770Z","iopub.status.idle":"2022-08-06T10:52:17.425170Z","shell.execute_reply.started":"2022-08-06T10:52:17.403721Z","shell.execute_reply":"2022-08-06T10:52:17.424248Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"P1 =data[['Alley','PoolQC','Fence','MiscFeature','FireplaceQu']]\nper =P1.isnull().sum()/len(P1)*100 # to check null values in percentage\nper","metadata":{"id":"DECYnmdhT-Hp","outputId":"e5806079-7550-4fae-cf0d-9ff9f0750064","execution":{"iopub.status.busy":"2022-08-06T10:52:17.426828Z","iopub.execute_input":"2022-08-06T10:52:17.427689Z","iopub.status.idle":"2022-08-06T10:52:17.441503Z","shell.execute_reply.started":"2022-08-06T10:52:17.427636Z","shell.execute_reply":"2022-08-06T10:52:17.440258Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Percentage of missing values is more then 80% \n\ndata=data.drop(['Alley','PoolQC','Fence','MiscFeature'], axis = 1)\ndata.shape","metadata":{"id":"H18iQ5wFT-Ek","outputId":"f91c5756-ae52-431c-bb58-46044cc13198","execution":{"iopub.status.busy":"2022-08-06T10:52:17.443109Z","iopub.execute_input":"2022-08-06T10:52:17.443958Z","iopub.status.idle":"2022-08-06T10:52:17.453006Z","shell.execute_reply.started":"2022-08-06T10:52:17.443919Z","shell.execute_reply":"2022-08-06T10:52:17.452003Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"correlation matrix","metadata":{}},{"cell_type":"code","source":"## correlation matrix\n\n## get correlations\ndata_corr = data.corr()\n\n## irrelevant fields to be defined\nfields = ['SalePrice']\n\n## drop rows if needed\ndata_corr.drop(fields, inplace=True)\n\n## drop cols if needed\ndata_corr.drop(fields, axis=1, inplace=True)\n\ndata_corr.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-06T10:52:17.454933Z","iopub.execute_input":"2022-08-06T10:52:17.455263Z","iopub.status.idle":"2022-08-06T10:52:17.494407Z","shell.execute_reply.started":"2022-08-06T10:52:17.455233Z","shell.execute_reply":"2022-08-06T10:52:17.493243Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"## plotting the heatmap to identify highly correlated features \n\nfig, ax = plt.subplots(figsize=(20,18))\n## mask\nmask = np.triu(np.ones_like(data_corr, dtype=np.bool_))\n\n## adjust mask and df\nmask = mask[1:, :-1]\ncorr = data_corr.iloc[1:,:-1].copy()\n\n## color map\ncmap = sns.diverging_palette(0, 230, 90, 60, as_cmap=True)\n\n## plot heatmap\nsns.heatmap(corr, mask=mask, annot=True, fmt=\".2f\", cmap=cmap,\n           linewidths=2,\n           vmin=-1, vmax=1, cbar_kws={\"shrink\": .8},square=True)\n\n## yticks\nplt.yticks(rotation=0)\nplt.show()\n","metadata":{"execution":{"iopub.status.busy":"2022-08-06T10:52:17.496693Z","iopub.execute_input":"2022-08-06T10:52:17.497801Z","iopub.status.idle":"2022-08-06T10:52:20.626600Z","shell.execute_reply.started":"2022-08-06T10:52:17.497751Z","shell.execute_reply":"2022-08-06T10:52:20.625337Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"## checking the correlationship between two variables\n\nfig, ax = plt.subplots(1, figsize=(12,8))\nsns.kdeplot(data = data, y='1stFlrSF', x='TotalBsmtSF', cmap='Blues',\n           shade=True, thresh=0.05, clip=(-1,2000))\nplt.scatter(y=data['1stFlrSF'], x=data['TotalBsmtSF'], color='orangered')","metadata":{"execution":{"iopub.status.busy":"2022-08-06T10:52:20.628629Z","iopub.execute_input":"2022-08-06T10:52:20.629040Z","iopub.status.idle":"2022-08-06T10:52:21.706199Z","shell.execute_reply.started":"2022-08-06T10:52:20.629003Z","shell.execute_reply":"2022-08-06T10:52:21.704924Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#drop the traget column\nX= data\ny= X.pop('SalePrice')","metadata":{"id":"vpWIZxxrT9_O","execution":{"iopub.status.busy":"2022-08-06T10:52:21.709811Z","iopub.execute_input":"2022-08-06T10:52:21.710286Z","iopub.status.idle":"2022-08-06T10:52:21.716700Z","shell.execute_reply.started":"2022-08-06T10:52:21.710237Z","shell.execute_reply":"2022-08-06T10:52:21.715568Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(data.shape)","metadata":{"id":"fK2h80buVxEA","outputId":"d807d519-9a04-417a-f6cf-50cc2b549e14","execution":{"iopub.status.busy":"2022-08-06T10:52:21.718201Z","iopub.execute_input":"2022-08-06T10:52:21.718547Z","iopub.status.idle":"2022-08-06T10:52:21.731900Z","shell.execute_reply.started":"2022-08-06T10:52:21.718514Z","shell.execute_reply":"2022-08-06T10:52:21.730769Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"spliting the data set","metadata":{"id":"0ibKCM200UE1"}},{"cell_type":"code","source":"X_train, X_test, y_train, y_test = train_test_split(X, y, train_size=0.8, random_state= 999999)","metadata":{"id":"tK0RS5jVT95t","execution":{"iopub.status.busy":"2022-08-06T10:52:21.733483Z","iopub.execute_input":"2022-08-06T10:52:21.734374Z","iopub.status.idle":"2022-08-06T10:52:21.745373Z","shell.execute_reply.started":"2022-08-06T10:52:21.734335Z","shell.execute_reply":"2022-08-06T10:52:21.744295Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# select categorical and numerical column names\nX_cat_columns = X.select_dtypes(exclude=\"number\").copy().columns \nX_num_columns = X.select_dtypes(include=\"number\").copy().columns\n\n# create numerical pipeline, only with the SimpleImputer(strategy=\"median\") and data scaling\nscaler = MinMaxScaler()\nnumeric_pipe = make_pipeline(scaler,\n                             SimpleImputer(strategy=\"median\"))\n                             \n \n# create categorical pipeline, with the SimpleImputer(fill_value=\"N_A\") and the OneHotEncoder\n\ncategoric_pipe = make_pipeline(\n    SimpleImputer(strategy=\"most_frequent\"), # you can select this one also strategy=\"constant\", fill_value=\"N_A\"\n    OneHotEncoder(handle_unknown = 'ignore', sparse=False) # covert all categorical data in the form of 0 and 1\n)","metadata":{"id":"YBj4PCpOT93v","execution":{"iopub.status.busy":"2022-08-06T10:52:21.747123Z","iopub.execute_input":"2022-08-06T10:52:21.747850Z","iopub.status.idle":"2022-08-06T10:52:21.759595Z","shell.execute_reply.started":"2022-08-06T10:52:21.747809Z","shell.execute_reply":"2022-08-06T10:52:21.758159Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Pipelines can contain many different steps inside. I would divide them into 2 groups: Preprocessing pipelines and Modelling pipelines. A Modelling pipeline has a model as their last step, whereas a preprocessing pipeline doesn't.\n","metadata":{"id":"_zmap3iv19Bq"}},{"cell_type":"markdown","source":"- Preprocessing pipelines: Those pipelines only transform the predictor features (the X) by filling NAs, encoding categorical features, scaling, etc. You always have to fit them with X_train. Then, you can call the .transform() method to transform both the X_train and the X_test. (Sometimes, you fit and transform X_train in a single step, by using the .fit_transform() method, but you're still performing these 2 separate steps). Any time that you call transform() you get as an output the transformed data, X_train or X_test.","metadata":{"id":"SOpjgP5l0Pvs"}},{"cell_type":"code","source":"from sklearn.compose import ColumnTransformer  #make_column_Transformer then dont need to mention names\n\npreprocessor = ColumnTransformer(\n    transformers=[\n        (\"num_pipe\", numeric_pipe, X_num_columns),\n        (\"cat_pipe\", categoric_pipe, X_cat_columns)\n      \n    ]\n)","metadata":{"id":"e0lQ2XVaWirm","execution":{"iopub.status.busy":"2022-08-06T10:52:21.761155Z","iopub.execute_input":"2022-08-06T10:52:21.761693Z","iopub.status.idle":"2022-08-06T10:52:21.768639Z","shell.execute_reply.started":"2022-08-06T10:52:21.761628Z","shell.execute_reply":"2022-08-06T10:52:21.767741Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# To display pipeline\nfrom sklearn import set_config\nset_config(display = 'diagram')","metadata":{"id":"j3EkVI6FYIle","execution":{"iopub.status.busy":"2022-08-06T10:52:21.771447Z","iopub.execute_input":"2022-08-06T10:52:21.773041Z","iopub.status.idle":"2022-08-06T10:52:21.784894Z","shell.execute_reply.started":"2022-08-06T10:52:21.772985Z","shell.execute_reply":"2022-08-06T10:52:21.783884Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Using Linear Regression\nThe variable(SalePrice) you want to predict is called the dependent variable.","metadata":{"id":"KbMdvm0Ca_73"}},{"cell_type":"code","source":"performances = {}","metadata":{"id":"qV7lJTbJhR_x","execution":{"iopub.status.busy":"2022-08-06T10:52:21.789962Z","iopub.execute_input":"2022-08-06T10:52:21.791239Z","iopub.status.idle":"2022-08-06T10:52:21.797838Z","shell.execute_reply.started":"2022-08-06T10:52:21.791185Z","shell.execute_reply":"2022-08-06T10:52:21.796586Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"preprocessor.fit_transform(X_train).shape","metadata":{"id":"yFGyKYojhzf4","outputId":"bd108f8e-2dac-4d12-ddc4-b468b140f360","execution":{"iopub.status.busy":"2022-08-06T10:52:21.799581Z","iopub.execute_input":"2022-08-06T10:52:21.800296Z","iopub.status.idle":"2022-08-06T10:52:21.852621Z","shell.execute_reply.started":"2022-08-06T10:52:21.800249Z","shell.execute_reply":"2022-08-06T10:52:21.851354Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.linear_model import LinearRegression\nfull_pipe_LR = make_pipeline(\n    preprocessor,\n    LinearRegression())\n\nfull_pipe_LR.fit(X_train, y_train)\n\nLR_pred = full_pipe_LR.predict(X_test)\n\nperformances[\"baseline_LR\"]= r2_score(y_test, LR_pred)\nperformances","metadata":{"id":"PFpRFVjzbJAo","outputId":"6d9d7414-c941-4e0e-b049-c804fb04f431","execution":{"iopub.status.busy":"2022-08-06T10:52:21.854260Z","iopub.execute_input":"2022-08-06T10:52:21.854649Z","iopub.status.idle":"2022-08-06T10:52:21.978202Z","shell.execute_reply.started":"2022-08-06T10:52:21.854612Z","shell.execute_reply":"2022-08-06T10:52:21.976892Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# LR with PCA \n\nfrom sklearn.linear_model import LinearRegression\nfull_pipe_LR = make_pipeline(\n    preprocessor,\n    PCA(n_components=97),\n    LinearRegression())\n\nfull_pipe_LR.fit(X_train, y_train)\n\nLR_pred = full_pipe_LR.predict(X_test)\n\nperformances[\"PCA95_LR\"]= r2_score(y_test, LR_pred)\nperformances","metadata":{"id":"SBa5gaR7j0V_","outputId":"e4394d85-f351-4861-ff62-f107ddf4f437","execution":{"iopub.status.busy":"2022-08-06T10:52:21.979917Z","iopub.execute_input":"2022-08-06T10:52:21.981178Z","iopub.status.idle":"2022-08-06T10:52:22.925383Z","shell.execute_reply.started":"2022-08-06T10:52:21.981123Z","shell.execute_reply":"2022-08-06T10:52:22.923820Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"##XGBRegressor","metadata":{"id":"wKFqOJb4sE0a"}},{"cell_type":"code","source":"from xgboost import XGBRegressor\n\n#Using pipeline\nfull_pipe_XGB = make_pipeline(\n    preprocessor,\n    XGBRegressor(n_estimators=950,learning_rate=0.05,n_jobs=-1))\n\nfull_pipe_XGB.fit(X_train, y_train)\n\nXGB_pred = full_pipe_XGB.predict(X_test)\n\nperformances[\"XGB_pred\"]= r2_score(y_test, XGB_pred)\nperformances","metadata":{"id":"KkVlG28MsD-S","outputId":"93946f72-a02b-477a-cc7d-663596955290","execution":{"iopub.status.busy":"2022-08-06T10:52:22.927976Z","iopub.execute_input":"2022-08-06T10:52:22.929819Z","iopub.status.idle":"2022-08-06T10:52:33.664912Z","shell.execute_reply.started":"2022-08-06T10:52:22.929765Z","shell.execute_reply":"2022-08-06T10:52:33.663610Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Using Random Forest Regressor","metadata":{"id":"X79TqRQraol4"}},{"cell_type":"code","source":"from sklearn.ensemble import RandomForestRegressor\nRF = RandomForestRegressor(n_estimators=150, random_state=0)","metadata":{"id":"WbTGVh2AX_GI","execution":{"iopub.status.busy":"2022-08-06T10:52:33.666903Z","iopub.execute_input":"2022-08-06T10:52:33.667655Z","iopub.status.idle":"2022-08-06T10:52:33.673509Z","shell.execute_reply.started":"2022-08-06T10:52:33.667605Z","shell.execute_reply":"2022-08-06T10:52:33.672268Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"full_pipeline = make_pipeline(preprocessor,\n                              RF)","metadata":{"id":"P9k9Pyz5X3Hg","execution":{"iopub.status.busy":"2022-08-06T10:52:33.674761Z","iopub.execute_input":"2022-08-06T10:52:33.675121Z","iopub.status.idle":"2022-08-06T10:52:33.685725Z","shell.execute_reply.started":"2022-08-06T10:52:33.675089Z","shell.execute_reply":"2022-08-06T10:52:33.684438Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"full_pipeline.fit(X_train, y_train)","metadata":{"id":"looRsjNGXIZe","outputId":"3ea4e86c-7446-4911-a8db-42fd19b3c742","execution":{"iopub.status.busy":"2022-08-06T10:52:33.687028Z","iopub.execute_input":"2022-08-06T10:52:33.688166Z","iopub.status.idle":"2022-08-06T10:52:37.725457Z","shell.execute_reply.started":"2022-08-06T10:52:33.688112Z","shell.execute_reply":"2022-08-06T10:52:37.724610Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"preds = full_pipeline.predict(X_train)\npreds[0:5]","metadata":{"id":"MgwY1JnUWihx","outputId":"8c72ad26-2ffd-4e30-a344-3d66c699fae2","execution":{"iopub.status.busy":"2022-08-06T10:52:37.726553Z","iopub.execute_input":"2022-08-06T10:52:37.727234Z","iopub.status.idle":"2022-08-06T10:52:37.813750Z","shell.execute_reply.started":"2022-08-06T10:52:37.727198Z","shell.execute_reply":"2022-08-06T10:52:37.812484Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Check on test file","metadata":{"id":"WYeCbgtgadwr"}},{"cell_type":"code","source":"test_data = pd.read_csv(\"../input/house-prices-advanced-regression-techniques/test.csv\")","metadata":{"id":"n4oqqeSwYymx","execution":{"iopub.status.busy":"2022-08-06T10:52:37.815149Z","iopub.execute_input":"2022-08-06T10:52:37.815587Z","iopub.status.idle":"2022-08-06T10:52:37.840845Z","shell.execute_reply.started":"2022-08-06T10:52:37.815550Z","shell.execute_reply":"2022-08-06T10:52:37.839724Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_data.set_index(\"Id\", inplace=True)  #reset index as Id","metadata":{"id":"zBLltnx9Yykv","execution":{"iopub.status.busy":"2022-08-06T10:52:37.842406Z","iopub.execute_input":"2022-08-06T10:52:37.842901Z","iopub.status.idle":"2022-08-06T10:52:37.849692Z","shell.execute_reply.started":"2022-08-06T10:52:37.842854Z","shell.execute_reply":"2022-08-06T10:52:37.848543Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"##Percentage of missing values\n\nPt =test_data[['Alley','PoolQC','Fence','MiscFeature','FireplaceQu']]  \npert =P1.isnull().sum()/len(P1)*100\npert","metadata":{"id":"wQRdaO-RY7EK","outputId":"53219b43-f038-4651-ecf2-337e1d56c7de","execution":{"iopub.status.busy":"2022-08-06T10:52:37.850772Z","iopub.execute_input":"2022-08-06T10:52:37.851637Z","iopub.status.idle":"2022-08-06T10:52:37.869779Z","shell.execute_reply.started":"2022-08-06T10:52:37.851598Z","shell.execute_reply":"2022-08-06T10:52:37.868477Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Percentage of missing values is more then 80% then dropp it\n\ntest_data=test_data.drop(['Alley','PoolQC','Fence','MiscFeature'], axis = 1)","metadata":{"id":"E-9JizcRY7AT","execution":{"iopub.status.busy":"2022-08-06T10:52:37.871456Z","iopub.execute_input":"2022-08-06T10:52:37.872686Z","iopub.status.idle":"2022-08-06T10:52:37.881216Z","shell.execute_reply.started":"2022-08-06T10:52:37.872609Z","shell.execute_reply":"2022-08-06T10:52:37.879972Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# To predict test data using XGB full pipeline\ntest_preds = full_pipe_XGB.predict(test_data)  \n","metadata":{"id":"FmWjWMHwY6-J","execution":{"iopub.status.busy":"2022-08-06T10:52:37.882578Z","iopub.execute_input":"2022-08-06T10:52:37.883463Z","iopub.status.idle":"2022-08-06T10:52:37.944932Z","shell.execute_reply.started":"2022-08-06T10:52:37.883418Z","shell.execute_reply":"2022-08-06T10:52:37.943737Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Two cloumns are needed to make dataframe \nresult = pd.DataFrame({'Id': test_data.index,             \n                       'SalePrice': test_preds})\n","metadata":{"id":"KadC1C7xY618","execution":{"iopub.status.busy":"2022-08-06T10:52:37.946525Z","iopub.execute_input":"2022-08-06T10:52:37.946916Z","iopub.status.idle":"2022-08-06T10:52:37.953111Z","shell.execute_reply.started":"2022-08-06T10:52:37.946881Z","shell.execute_reply":"2022-08-06T10:52:37.951846Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"result","metadata":{"id":"u4QQri54ltNS","outputId":"50ba166a-83b6-4580-fb6e-9e7321274bd0","execution":{"iopub.status.busy":"2022-08-06T10:52:37.954530Z","iopub.execute_input":"2022-08-06T10:52:37.955125Z","iopub.status.idle":"2022-08-06T10:52:37.973515Z","shell.execute_reply.started":"2022-08-06T10:52:37.955087Z","shell.execute_reply":"2022-08-06T10:52:37.971938Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# To covert dataframe to CSV\nresult.to_csv('Submission.csv', index=False)","metadata":{"id":"KRRQ_qtNaLMw","execution":{"iopub.status.busy":"2022-08-06T10:52:37.975797Z","iopub.execute_input":"2022-08-06T10:52:37.976539Z","iopub.status.idle":"2022-08-06T10:52:37.987556Z","shell.execute_reply.started":"2022-08-06T10:52:37.976490Z","shell.execute_reply":"2022-08-06T10:52:37.986089Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# For download CSV file from colab\n#from google.colab import files\n#files.download(\"Submission.csv\")","metadata":{"id":"pXEnaozJl9VT","outputId":"fc99e7ff-c5a7-4f51-8c4f-d01b5bc35e33","execution":{"iopub.status.busy":"2022-08-06T10:52:37.989219Z","iopub.execute_input":"2022-08-06T10:52:37.989721Z","iopub.status.idle":"2022-08-06T10:52:37.994923Z","shell.execute_reply.started":"2022-08-06T10:52:37.989674Z","shell.execute_reply":"2022-08-06T10:52:37.993906Z"},"trusted":true},"execution_count":null,"outputs":[]}]}