{"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":"import numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\n%matplotlib inline\nimport seaborn as sns","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:54:32.205822Z","iopub.execute_input":"2022-07-16T07:54:32.206983Z","iopub.status.idle":"2022-07-16T07:54:32.217443Z","shell.execute_reply.started":"2022-07-16T07:54:32.206926Z","shell.execute_reply":"2022-07-16T07:54:32.216540Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df=pd.read_csv(\"../input/house-prices-advanced-regression-techniques/train.csv\")\ndf.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:54:32.859604Z","iopub.execute_input":"2022-07-16T07:54:32.860283Z","iopub.status.idle":"2022-07-16T07:54:32.908813Z","shell.execute_reply.started":"2022-07-16T07:54:32.860247Z","shell.execute_reply":"2022-07-16T07:54:32.907538Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.shape","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:54:33.599598Z","iopub.execute_input":"2022-07-16T07:54:33.600604Z","iopub.status.idle":"2022-07-16T07:54:33.607513Z","shell.execute_reply.started":"2022-07-16T07:54:33.600563Z","shell.execute_reply":"2022-07-16T07:54:33.606236Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.columns","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:54:34.491247Z","iopub.execute_input":"2022-07-16T07:54:34.492059Z","iopub.status.idle":"2022-07-16T07:54:34.499504Z","shell.execute_reply.started":"2022-07-16T07:54:34.492023Z","shell.execute_reply":"2022-07-16T07:54:34.498696Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.heatmap(df.isnull(),yticklabels=False,cbar=False)","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:54:35.179231Z","iopub.execute_input":"2022-07-16T07:54:35.179833Z","iopub.status.idle":"2022-07-16T07:54:35.526482Z","shell.execute_reply.started":"2022-07-16T07:54:35.179781Z","shell.execute_reply":"2022-07-16T07:54:35.525359Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.drop(\"Alley\",axis=1,inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:54:35.877933Z","iopub.execute_input":"2022-07-16T07:54:35.878931Z","iopub.status.idle":"2022-07-16T07:54:35.885446Z","shell.execute_reply.started":"2022-07-16T07:54:35.878888Z","shell.execute_reply":"2022-07-16T07:54:35.884363Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df[\"LotFrontage\"]=df[\"LotFrontage\"].fillna(df[\"LotFrontage\"]).mean()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:54:36.694635Z","iopub.execute_input":"2022-07-16T07:54:36.695865Z","iopub.status.idle":"2022-07-16T07:54:36.701902Z","shell.execute_reply.started":"2022-07-16T07:54:36.695812Z","shell.execute_reply":"2022-07-16T07:54:36.700988Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df[\"BsmtCond\"]=df[\"BsmtCond\"].fillna(df[\"BsmtCond\"].mode()[0])\ndf[\"BsmtQual\"]=df[\"BsmtQual\"].fillna(df[\"BsmtQual\"].mode()[0])","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:54:38.669790Z","iopub.execute_input":"2022-07-16T07:54:38.670829Z","iopub.status.idle":"2022-07-16T07:54:38.679237Z","shell.execute_reply.started":"2022-07-16T07:54:38.670777Z","shell.execute_reply":"2022-07-16T07:54:38.677910Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df[\"FireplaceQu\"]=df[\"FireplaceQu\"].fillna(df[\"FireplaceQu\"].mode()[0])\ndf[\"GarageType\"]=df[\"GarageType\"].fillna(df[\"GarageType\"].mode()[0])","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:54:39.677491Z","iopub.execute_input":"2022-07-16T07:54:39.678270Z","iopub.status.idle":"2022-07-16T07:54:39.685968Z","shell.execute_reply.started":"2022-07-16T07:54:39.678228Z","shell.execute_reply":"2022-07-16T07:54:39.685028Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.drop([\"GarageYrBlt\"],axis=1,inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:54:41.373848Z","iopub.execute_input":"2022-07-16T07:54:41.374221Z","iopub.status.idle":"2022-07-16T07:54:41.381422Z","shell.execute_reply.started":"2022-07-16T07:54:41.374190Z","shell.execute_reply":"2022-07-16T07:54:41.379972Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['GarageFinish']=df['GarageFinish'].fillna(df['GarageFinish'].mode()[0])\ndf['GarageQual']=df['GarageQual'].fillna(df['GarageQual'].mode()[0])\ndf['GarageCond']=df['GarageCond'].fillna(df['GarageCond'].mode()[0])","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:54:43.075602Z","iopub.execute_input":"2022-07-16T07:54:43.076389Z","iopub.status.idle":"2022-07-16T07:54:43.087491Z","shell.execute_reply.started":"2022-07-16T07:54:43.076351Z","shell.execute_reply":"2022-07-16T07:54:43.086225Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.drop([\"PoolQC\",\"Fence\",\"MiscFeature\"],axis=1,inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:54:44.762136Z","iopub.execute_input":"2022-07-16T07:54:44.763275Z","iopub.status.idle":"2022-07-16T07:54:44.770530Z","shell.execute_reply.started":"2022-07-16T07:54:44.763217Z","shell.execute_reply":"2022-07-16T07:54:44.769714Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.shape","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:54:47.868404Z","iopub.execute_input":"2022-07-16T07:54:47.868811Z","iopub.status.idle":"2022-07-16T07:54:47.876234Z","shell.execute_reply.started":"2022-07-16T07:54:47.868776Z","shell.execute_reply":"2022-07-16T07:54:47.875065Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.drop([\"Id\"],axis=1,inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:54:49.341375Z","iopub.execute_input":"2022-07-16T07:54:49.341993Z","iopub.status.idle":"2022-07-16T07:54:49.348818Z","shell.execute_reply.started":"2022-07-16T07:54:49.341953Z","shell.execute_reply":"2022-07-16T07:54:49.347951Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:54:50.630675Z","iopub.execute_input":"2022-07-16T07:54:50.631080Z","iopub.status.idle":"2022-07-16T07:54:50.649125Z","shell.execute_reply.started":"2022-07-16T07:54:50.631047Z","shell.execute_reply":"2022-07-16T07:54:50.647852Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['MasVnrType']=df['MasVnrType'].fillna(df['MasVnrType'].mode()[0])\ndf['MasVnrArea']=df['MasVnrArea'].fillna(df['MasVnrArea'].mode()[0])","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:54:52.171577Z","iopub.execute_input":"2022-07-16T07:54:52.172563Z","iopub.status.idle":"2022-07-16T07:54:52.179841Z","shell.execute_reply.started":"2022-07-16T07:54:52.172521Z","shell.execute_reply":"2022-07-16T07:54:52.179005Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.heatmap(df.isnull(),yticklabels=False,cbar=False,cmap=\"coolwarm\")","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:54:53.782964Z","iopub.execute_input":"2022-07-16T07:54:53.783827Z","iopub.status.idle":"2022-07-16T07:54:54.118552Z","shell.execute_reply.started":"2022-07-16T07:54:53.783784Z","shell.execute_reply":"2022-07-16T07:54:54.117214Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['BsmtExposure']=df['BsmtExposure'].fillna(df['BsmtExposure'].mode()[0])","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:54:59.693104Z","iopub.execute_input":"2022-07-16T07:54:59.693517Z","iopub.status.idle":"2022-07-16T07:54:59.701434Z","shell.execute_reply.started":"2022-07-16T07:54:59.693485Z","shell.execute_reply":"2022-07-16T07:54:59.700351Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['BsmtFinType2']=df['BsmtFinType2'].fillna(df['BsmtFinType2'].mode()[0])","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:55:01.673193Z","iopub.execute_input":"2022-07-16T07:55:01.674158Z","iopub.status.idle":"2022-07-16T07:55:01.681353Z","shell.execute_reply.started":"2022-07-16T07:55:01.674117Z","shell.execute_reply":"2022-07-16T07:55:01.679749Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.heatmap(df.isnull())","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:55:02.740090Z","iopub.execute_input":"2022-07-16T07:55:02.741342Z","iopub.status.idle":"2022-07-16T07:55:03.360746Z","shell.execute_reply.started":"2022-07-16T07:55:02.741299Z","shell.execute_reply":"2022-07-16T07:55:03.359435Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.dropna(inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:55:08.097806Z","iopub.execute_input":"2022-07-16T07:55:08.098173Z","iopub.status.idle":"2022-07-16T07:55:08.113327Z","shell.execute_reply.started":"2022-07-16T07:55:08.098143Z","shell.execute_reply":"2022-07-16T07:55:08.112250Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.shape","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:55:08.732129Z","iopub.execute_input":"2022-07-16T07:55:08.732514Z","iopub.status.idle":"2022-07-16T07:55:08.739121Z","shell.execute_reply.started":"2022-07-16T07:55:08.732483Z","shell.execute_reply":"2022-07-16T07:55:08.738158Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.head(2)","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:55:10.378746Z","iopub.execute_input":"2022-07-16T07:55:10.379511Z","iopub.status.idle":"2022-07-16T07:55:10.401500Z","shell.execute_reply.started":"2022-07-16T07:55:10.379475Z","shell.execute_reply":"2022-07-16T07:55:10.400711Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"columns=['MSZoning','Street','LotShape','LandContour','Utilities','LotConfig','LandSlope','Neighborhood',\n         'Condition2','BldgType','Condition1','HouseStyle','SaleType',\n        'SaleCondition','ExterCond',\n         'ExterQual','Foundation','BsmtQual','BsmtCond','BsmtExposure','BsmtFinType1','BsmtFinType2',\n        'RoofStyle','RoofMatl','Exterior1st','Exterior2nd','MasVnrType','Heating','HeatingQC',\n         'CentralAir',\n         'Electrical','KitchenQual','Functional',\n         'FireplaceQu','GarageType','GarageFinish','GarageQual','GarageCond','PavedDrive']","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:55:21.975943Z","iopub.execute_input":"2022-07-16T07:55:21.976732Z","iopub.status.idle":"2022-07-16T07:55:21.982899Z","shell.execute_reply.started":"2022-07-16T07:55:21.976692Z","shell.execute_reply":"2022-07-16T07:55:21.981972Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(columns)","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:55:22.512254Z","iopub.execute_input":"2022-07-16T07:55:22.513087Z","iopub.status.idle":"2022-07-16T07:55:22.520588Z","shell.execute_reply.started":"2022-07-16T07:55:22.513036Z","shell.execute_reply":"2022-07-16T07:55:22.519581Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def category_onehot_multcols(multcolumns):\n    df_final=final_df\n    i=0\n    for fields in multcolumns:\n        \n        print(fields)\n        df1=pd.get_dummies(final_df[fields],drop_first=True)\n        \n        final_df.drop([fields],axis=1,inplace=True)\n        if i==0:\n            df_final=df1.copy()\n        else:\n            \n            df_final=pd.concat([df_final,df1],axis=1)\n        i=i+1\n       \n        \n    df_final=pd.concat([final_df,df_final],axis=1)\n        \n    return df_final","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:55:23.218115Z","iopub.execute_input":"2022-07-16T07:55:23.218853Z","iopub.status.idle":"2022-07-16T07:55:23.228287Z","shell.execute_reply.started":"2022-07-16T07:55:23.218818Z","shell.execute_reply":"2022-07-16T07:55:23.227112Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"main_df=df.copy()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:55:28.223465Z","iopub.execute_input":"2022-07-16T07:55:28.224180Z","iopub.status.idle":"2022-07-16T07:55:28.229194Z","shell.execute_reply.started":"2022-07-16T07:55:28.224142Z","shell.execute_reply":"2022-07-16T07:55:28.228136Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df=pd.read_csv(\"../input/house-prices-advanced-regression-techniques/test.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:55:29.855314Z","iopub.execute_input":"2022-07-16T07:55:29.855728Z","iopub.status.idle":"2022-07-16T07:55:29.883390Z","shell.execute_reply.started":"2022-07-16T07:55:29.855696Z","shell.execute_reply":"2022-07-16T07:55:29.882201Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df.shape","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:55:34.249197Z","iopub.execute_input":"2022-07-16T07:55:34.250218Z","iopub.status.idle":"2022-07-16T07:55:34.256195Z","shell.execute_reply.started":"2022-07-16T07:55:34.250180Z","shell.execute_reply":"2022-07-16T07:55:34.255153Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.heatmap(test_df.isnull())","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:55:35.057615Z","iopub.execute_input":"2022-07-16T07:55:35.058326Z","iopub.status.idle":"2022-07-16T07:55:35.593515Z","shell.execute_reply.started":"2022-07-16T07:55:35.058278Z","shell.execute_reply":"2022-07-16T07:55:35.592171Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df['LotFrontage']=test_df['LotFrontage'].fillna(test_df['LotFrontage'].mean())\ntest_df['MSZoning']=test_df['MSZoning'].fillna(test_df['MSZoning'].mode()[0])\ntest_df.drop(['Alley'],axis=1,inplace=True)\ntest_df['BsmtCond']=test_df['BsmtCond'].fillna(test_df['BsmtCond'].mode()[0])\ntest_df['BsmtQual']=test_df['BsmtQual'].fillna(test_df['BsmtQual'].mode()[0])\ntest_df['FireplaceQu']=test_df['FireplaceQu'].fillna(test_df['FireplaceQu'].mode()[0])\ntest_df['GarageType']=test_df['GarageType'].fillna(test_df['GarageType'].mode()[0])\ntest_df.drop(['GarageYrBlt'],axis=1,inplace=True)\ntest_df['GarageFinish']=test_df['GarageFinish'].fillna(test_df['GarageFinish'].mode()[0])\ntest_df['GarageQual']=test_df['GarageQual'].fillna(test_df['GarageQual'].mode()[0])\ntest_df['GarageCond']=test_df['GarageCond'].fillna(test_df['GarageCond'].mode()[0])\n\ntest_df.drop(['PoolQC','Fence','MiscFeature'],axis=1,inplace=True)\n\ntest_df.drop(['Id'],axis=1,inplace=True)\ntest_df['MasVnrType']=test_df['MasVnrType'].fillna(test_df['MasVnrType'].mode()[0])\ntest_df['MasVnrArea']=test_df['MasVnrArea'].fillna(test_df['MasVnrArea'].mode()[0])\n","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:55:41.242632Z","iopub.execute_input":"2022-07-16T07:55:41.243044Z","iopub.status.idle":"2022-07-16T07:55:41.274255Z","shell.execute_reply.started":"2022-07-16T07:55:41.243011Z","shell.execute_reply":"2022-07-16T07:55:41.273344Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.heatmap(test_df.isnull(),yticklabels=False,cbar=False,cmap='viridis')","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:55:46.649003Z","iopub.execute_input":"2022-07-16T07:55:46.649613Z","iopub.status.idle":"2022-07-16T07:55:46.979835Z","shell.execute_reply.started":"2022-07-16T07:55:46.649576Z","shell.execute_reply":"2022-07-16T07:55:46.978504Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df['BsmtExposure']=test_df['BsmtExposure'].fillna(test_df['BsmtExposure'].mode()[0])","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:55:51.190241Z","iopub.execute_input":"2022-07-16T07:55:51.191087Z","iopub.status.idle":"2022-07-16T07:55:51.198184Z","shell.execute_reply.started":"2022-07-16T07:55:51.191049Z","shell.execute_reply":"2022-07-16T07:55:51.196958Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df['BsmtFinType2']=test_df['BsmtFinType2'].fillna(test_df['BsmtFinType2'].mode()[0])","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:55:51.794974Z","iopub.execute_input":"2022-07-16T07:55:51.795374Z","iopub.status.idle":"2022-07-16T07:55:51.802918Z","shell.execute_reply.started":"2022-07-16T07:55:51.795343Z","shell.execute_reply":"2022-07-16T07:55:51.801611Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df['Utilities']=test_df['Utilities'].fillna(test_df['Utilities'].mode()[0])\ntest_df['Exterior1st']=test_df['Exterior1st'].fillna(test_df['Exterior1st'].mode()[0])\ntest_df['Exterior2nd']=test_df['Exterior2nd'].fillna(test_df['Exterior2nd'].mode()[0])\ntest_df['BsmtFinType1']=test_df['BsmtFinType1'].fillna(test_df['BsmtFinType1'].mode()[0])\ntest_df['BsmtFinSF1']=test_df['BsmtFinSF1'].fillna(test_df['BsmtFinSF1'].mean())\ntest_df['BsmtFinSF2']=test_df['BsmtFinSF2'].fillna(test_df['BsmtFinSF2'].mean())\ntest_df['BsmtUnfSF']=test_df['BsmtUnfSF'].fillna(test_df['BsmtUnfSF'].mean())\ntest_df['TotalBsmtSF']=test_df['TotalBsmtSF'].fillna(test_df['TotalBsmtSF'].mean())\ntest_df['BsmtFullBath']=test_df['BsmtFullBath'].fillna(test_df['BsmtFullBath'].mode()[0])\ntest_df['BsmtHalfBath']=test_df['BsmtHalfBath'].fillna(test_df['BsmtHalfBath'].mode()[0])\ntest_df['KitchenQual']=test_df['KitchenQual'].fillna(test_df['KitchenQual'].mode()[0])\ntest_df['Functional']=test_df['Functional'].fillna(test_df['Functional'].mode()[0])\ntest_df['GarageCars']=test_df['GarageCars'].fillna(test_df['GarageCars'].mean())\ntest_df['GarageArea']=test_df['GarageArea'].fillna(test_df['GarageArea'].mean())\ntest_df['SaleType']=test_df['SaleType'].fillna(test_df['SaleType'].mode()[0])","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:55:52.725571Z","iopub.execute_input":"2022-07-16T07:55:52.726863Z","iopub.status.idle":"2022-07-16T07:55:52.754213Z","shell.execute_reply.started":"2022-07-16T07:55:52.726806Z","shell.execute_reply":"2022-07-16T07:55:52.753126Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df.shape","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:55:53.407923Z","iopub.execute_input":"2022-07-16T07:55:53.408344Z","iopub.status.idle":"2022-07-16T07:55:53.415807Z","shell.execute_reply.started":"2022-07-16T07:55:53.408309Z","shell.execute_reply":"2022-07-16T07:55:53.414556Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"final_df=pd.concat([df,test_df],axis=0)","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:55:54.030869Z","iopub.execute_input":"2022-07-16T07:55:54.031633Z","iopub.status.idle":"2022-07-16T07:55:54.049868Z","shell.execute_reply.started":"2022-07-16T07:55:54.031577Z","shell.execute_reply":"2022-07-16T07:55:54.048943Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"final_df=category_onehot_multcols(columns)","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:55:54.944424Z","iopub.execute_input":"2022-07-16T07:55:54.944848Z","iopub.status.idle":"2022-07-16T07:55:55.074198Z","shell.execute_reply.started":"2022-07-16T07:55:54.944812Z","shell.execute_reply":"2022-07-16T07:55:55.072951Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"final_df.shape","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:55:59.381195Z","iopub.execute_input":"2022-07-16T07:55:59.381600Z","iopub.status.idle":"2022-07-16T07:55:59.388546Z","shell.execute_reply.started":"2022-07-16T07:55:59.381564Z","shell.execute_reply":"2022-07-16T07:55:59.387701Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"final_df =final_df.loc[:,~final_df.columns.duplicated()]\nfinal_df.shape","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:56:00.637830Z","iopub.execute_input":"2022-07-16T07:56:00.638401Z","iopub.status.idle":"2022-07-16T07:56:00.647923Z","shell.execute_reply.started":"2022-07-16T07:56:00.638368Z","shell.execute_reply":"2022-07-16T07:56:00.646929Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train=final_df.iloc[:1422,:]\ntest=final_df.iloc[1422:,:]","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:56:03.560859Z","iopub.execute_input":"2022-07-16T07:56:03.561278Z","iopub.status.idle":"2022-07-16T07:56:03.567065Z","shell.execute_reply.started":"2022-07-16T07:56:03.561244Z","shell.execute_reply":"2022-07-16T07:56:03.565948Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:56:04.073222Z","iopub.execute_input":"2022-07-16T07:56:04.074477Z","iopub.status.idle":"2022-07-16T07:56:04.099303Z","shell.execute_reply.started":"2022-07-16T07:56:04.074435Z","shell.execute_reply":"2022-07-16T07:56:04.098181Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test.drop([\"SalePrice\"],axis=1,inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:56:08.684685Z","iopub.execute_input":"2022-07-16T07:56:08.685837Z","iopub.status.idle":"2022-07-16T07:56:08.696422Z","shell.execute_reply.started":"2022-07-16T07:56:08.685798Z","shell.execute_reply":"2022-07-16T07:56:08.695033Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"xtrain=train.drop([\"SalePrice\"],axis=1)\nytrain=train[\"SalePrice\"]","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:56:16.776273Z","iopub.execute_input":"2022-07-16T07:56:16.777518Z","iopub.status.idle":"2022-07-16T07:56:16.784506Z","shell.execute_reply.started":"2022-07-16T07:56:16.777462Z","shell.execute_reply":"2022-07-16T07:56:16.783728Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import xgboost\ncls=xgboost.XGBRegressor()\nreg=xgboost.XGBRegressor()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T07:58:15.413083Z","iopub.execute_input":"2022-07-16T07:58:15.413590Z","iopub.status.idle":"2022-07-16T07:58:15.639387Z","shell.execute_reply.started":"2022-07-16T07:58:15.413547Z","shell.execute_reply":"2022-07-16T07:58:15.638210Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"booster=['gbtree','gblinear']\nbase_score=[0.25,0.5,0.75,1]","metadata":{"execution":{"iopub.status.busy":"2022-07-16T08:00:11.119413Z","iopub.execute_input":"2022-07-16T08:00:11.119853Z","iopub.status.idle":"2022-07-16T08:00:11.125142Z","shell.execute_reply.started":"2022-07-16T08:00:11.119817Z","shell.execute_reply":"2022-07-16T08:00:11.124249Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"n_estimators = [100, 500, 900, 1100, 1500]\nmax_depth = [2, 3, 5, 10, 15]\nbooster=['gbtree','gblinear']\nlearning_rate=[0.05,0.1,0.15,0.20]\nmin_child_weight=[1,2,3,4]\n\n# Define the grid of hyperparameters to search\nhyperparameter_grid = {\n    'n_estimators': n_estimators,\n    'max_depth':max_depth,\n    'learning_rate':learning_rate,\n    'min_child_weight':min_child_weight,\n    'booster':booster,\n    'base_score':base_score\n    }","metadata":{"execution":{"iopub.status.busy":"2022-07-16T08:00:28.187142Z","iopub.execute_input":"2022-07-16T08:00:28.187887Z","iopub.status.idle":"2022-07-16T08:00:28.193993Z","shell.execute_reply.started":"2022-07-16T08:00:28.187852Z","shell.execute_reply":"2022-07-16T08:00:28.192981Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.model_selection import RandomizedSearchCV\nrandom_cv = RandomizedSearchCV(estimator=reg,\n            param_distributions=hyperparameter_grid,\n            cv=5, n_iter=50,\n            scoring = 'neg_mean_absolute_error',n_jobs = 4,\n            verbose = 5, \n            return_train_score = True,\n            random_state=42)","metadata":{"execution":{"iopub.status.busy":"2022-07-16T08:01:56.875223Z","iopub.execute_input":"2022-07-16T08:01:56.875872Z","iopub.status.idle":"2022-07-16T08:01:56.881227Z","shell.execute_reply.started":"2022-07-16T08:01:56.875834Z","shell.execute_reply":"2022-07-16T08:01:56.880125Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"random_cv.fit(xtrain,ytrain)","metadata":{"execution":{"iopub.status.busy":"2022-07-16T08:02:16.127310Z","iopub.execute_input":"2022-07-16T08:02:16.127732Z","iopub.status.idle":"2022-07-16T08:14:05.317370Z","shell.execute_reply.started":"2022-07-16T08:02:16.127697Z","shell.execute_reply":"2022-07-16T08:14:05.316320Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}