{"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":"%matplotlib inline\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nimport seaborn as sns\n\nimport pandas as pd","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-07-06T21:25:10.957006Z","iopub.execute_input":"2022-07-06T21:25:10.957391Z","iopub.status.idle":"2022-07-06T21:25:10.96507Z","shell.execute_reply.started":"2022-07-06T21:25:10.95736Z","shell.execute_reply":"2022-07-06T21:25:10.964008Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from collections import Counter\nfrom catboost import CatBoostRegressor\n\nfrom sklearn.model_selection import train_test_split, cross_val_score\nfrom sklearn.metrics import mean_squared_error","metadata":{"execution":{"iopub.status.busy":"2022-07-06T21:25:11.912129Z","iopub.execute_input":"2022-07-06T21:25:11.913024Z","iopub.status.idle":"2022-07-06T21:25:11.919132Z","shell.execute_reply.started":"2022-07-06T21:25:11.912972Z","shell.execute_reply":"2022-07-06T21:25:11.918107Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import warnings\nwarnings.filterwarnings(\"ignore\")","metadata":{"execution":{"iopub.status.busy":"2022-07-06T21:25:12.597526Z","iopub.execute_input":"2022-07-06T21:25:12.598622Z","iopub.status.idle":"2022-07-06T21:25:12.603432Z","shell.execute_reply.started":"2022-07-06T21:25:12.598582Z","shell.execute_reply":"2022-07-06T21:25:12.602441Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_dirname = \"../input/house-prices-advanced-regression-techniques/train.csv\"\ntest_dirname = \"../input/house-prices-advanced-regression-techniques/test.csv\"","metadata":{"execution":{"iopub.status.busy":"2022-07-06T21:25:13.287395Z","iopub.execute_input":"2022-07-06T21:25:13.287998Z","iopub.status.idle":"2022-07-06T21:25:13.294979Z","shell.execute_reply.started":"2022-07-06T21:25:13.287963Z","shell.execute_reply":"2022-07-06T21:25:13.294014Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train = pd.read_csv(train_dirname)\ndf_train.drop(\"Id\", axis = 1, inplace = True)\ndf_train.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-06T21:25:13.702848Z","iopub.execute_input":"2022-07-06T21:25:13.703191Z","iopub.status.idle":"2022-07-06T21:25:13.743466Z","shell.execute_reply.started":"2022-07-06T21:25:13.703162Z","shell.execute_reply":"2022-07-06T21:25:13.742527Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-06T21:25:15.39092Z","iopub.execute_input":"2022-07-06T21:25:15.391645Z","iopub.status.idle":"2022-07-06T21:25:15.408793Z","shell.execute_reply.started":"2022-07-06T21:25:15.391608Z","shell.execute_reply":"2022-07-06T21:25:15.407668Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.isna().sum().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-06T21:25:16.314849Z","iopub.execute_input":"2022-07-06T21:25:16.315525Z","iopub.status.idle":"2022-07-06T21:25:16.331251Z","shell.execute_reply.started":"2022-07-06T21:25:16.315479Z","shell.execute_reply":"2022-07-06T21:25:16.330129Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Counter(df_train['MiscFeature'])","metadata":{"execution":{"iopub.status.busy":"2022-07-06T21:25:17.150948Z","iopub.execute_input":"2022-07-06T21:25:17.151334Z","iopub.status.idle":"2022-07-06T21:25:17.1593Z","shell.execute_reply.started":"2022-07-06T21:25:17.151303Z","shell.execute_reply":"2022-07-06T21:25:17.158276Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Counter(df_train['PoolQC'])","metadata":{"execution":{"iopub.status.busy":"2022-07-06T21:25:18.09373Z","iopub.execute_input":"2022-07-06T21:25:18.094382Z","iopub.status.idle":"2022-07-06T21:25:18.100951Z","shell.execute_reply.started":"2022-07-06T21:25:18.094348Z","shell.execute_reply":"2022-07-06T21:25:18.099948Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Counter(df_train['Fence'])","metadata":{"execution":{"iopub.status.busy":"2022-07-06T21:25:18.807308Z","iopub.execute_input":"2022-07-06T21:25:18.808013Z","iopub.status.idle":"2022-07-06T21:25:18.820335Z","shell.execute_reply.started":"2022-07-06T21:25:18.80796Z","shell.execute_reply":"2022-07-06T21:25:18.819134Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Counter(df_train['Alley'])","metadata":{"execution":{"iopub.status.busy":"2022-07-06T21:25:19.397388Z","iopub.execute_input":"2022-07-06T21:25:19.398281Z","iopub.status.idle":"2022-07-06T21:25:19.405853Z","shell.execute_reply.started":"2022-07-06T21:25:19.39823Z","shell.execute_reply":"2022-07-06T21:25:19.404776Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.drop(columns = ['Alley', 'MiscFeature','PoolQC','Fence'], inplace = True)","metadata":{"execution":{"iopub.status.busy":"2022-07-06T21:25:20.1882Z","iopub.execute_input":"2022-07-06T21:25:20.18888Z","iopub.status.idle":"2022-07-06T21:25:20.195421Z","shell.execute_reply.started":"2022-07-06T21:25:20.188843Z","shell.execute_reply":"2022-07-06T21:25:20.194232Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(df_train.isna().sum().sum())\ndf_train","metadata":{"execution":{"iopub.status.busy":"2022-07-06T21:25:26.342845Z","iopub.execute_input":"2022-07-06T21:25:26.343258Z","iopub.status.idle":"2022-07-06T21:25:26.382685Z","shell.execute_reply.started":"2022-07-06T21:25:26.343191Z","shell.execute_reply":"2022-07-06T21:25:26.381578Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for column in df_train.columns:\n    count = df_train[column].isna().sum()\n    if count != 0:\n        print(\"Name is:\", column, \"   counter is:\", count, \"    percent is:\", count*100/df_train.shape[0], \n              \"    type is:\",df_train[column].dtype.name)","metadata":{"execution":{"iopub.status.busy":"2022-07-06T21:25:26.951802Z","iopub.execute_input":"2022-07-06T21:25:26.952831Z","iopub.status.idle":"2022-07-06T21:25:26.986832Z","shell.execute_reply.started":"2022-07-06T21:25:26.952779Z","shell.execute_reply":"2022-07-06T21:25:26.985635Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.drop(columns = 'FireplaceQu', inplace = True)","metadata":{"execution":{"iopub.status.busy":"2022-07-06T21:25:29.88729Z","iopub.execute_input":"2022-07-06T21:25:29.888145Z","iopub.status.idle":"2022-07-06T21:25:29.895887Z","shell.execute_reply.started":"2022-07-06T21:25:29.888107Z","shell.execute_reply":"2022-07-06T21:25:29.894984Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"MasVnrArea - categorical","metadata":{}},{"cell_type":"code","source":"cat_columns = []\nnum_columns = []\nfor column in df_train.columns:\n    count = df_train[column].isna().sum()\n    if count != 0:\n        if df_train[column].dtype.name == 'object' or column == 'MasVnrArea':\n            cat_columns.append(column)\n        elif df_train[column].dtype.name != 'object' and column != 'MasVnrArea':\n            num_columns.append(column)","metadata":{"execution":{"iopub.status.busy":"2022-07-06T21:25:31.671603Z","iopub.execute_input":"2022-07-06T21:25:31.672178Z","iopub.status.idle":"2022-07-06T21:25:31.70423Z","shell.execute_reply.started":"2022-07-06T21:25:31.672144Z","shell.execute_reply":"2022-07-06T21:25:31.703252Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cat_columns","metadata":{"execution":{"iopub.status.busy":"2022-07-06T21:25:33.960243Z","iopub.execute_input":"2022-07-06T21:25:33.960791Z","iopub.status.idle":"2022-07-06T21:25:33.967154Z","shell.execute_reply.started":"2022-07-06T21:25:33.960746Z","shell.execute_reply":"2022-07-06T21:25:33.966258Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"num_columns","metadata":{"execution":{"iopub.status.busy":"2022-07-06T21:25:34.68676Z","iopub.execute_input":"2022-07-06T21:25:34.687357Z","iopub.status.idle":"2022-07-06T21:25:34.693638Z","shell.execute_reply.started":"2022-07-06T21:25:34.687324Z","shell.execute_reply":"2022-07-06T21:25:34.692505Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.impute import SimpleImputer","metadata":{"execution":{"iopub.status.busy":"2022-07-06T21:25:35.565063Z","iopub.execute_input":"2022-07-06T21:25:35.565716Z","iopub.status.idle":"2022-07-06T21:25:35.57015Z","shell.execute_reply.started":"2022-07-06T21:25:35.565679Z","shell.execute_reply":"2022-07-06T21:25:35.569248Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train[num_columns] = SimpleImputer(strategy=\"mean\").fit_transform(df_train[num_columns])\ndf_train[cat_columns] = SimpleImputer(strategy=\"most_frequent\").fit_transform(df_train[cat_columns])","metadata":{"execution":{"iopub.status.busy":"2022-07-06T21:25:38.357685Z","iopub.execute_input":"2022-07-06T21:25:38.35864Z","iopub.status.idle":"2022-07-06T21:25:38.378264Z","shell.execute_reply.started":"2022-07-06T21:25:38.358588Z","shell.execute_reply":"2022-07-06T21:25:38.377361Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.isna().sum().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-06T21:25:39.073935Z","iopub.execute_input":"2022-07-06T21:25:39.074444Z","iopub.status.idle":"2022-07-06T21:25:39.090092Z","shell.execute_reply.started":"2022-07-06T21:25:39.074389Z","shell.execute_reply":"2022-07-06T21:25:39.088934Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X = df_train.drop(columns = 'SalePrice')\nY = df_train['SalePrice']","metadata":{"execution":{"iopub.status.busy":"2022-07-06T21:25:39.93893Z","iopub.execute_input":"2022-07-06T21:25:39.939694Z","iopub.status.idle":"2022-07-06T21:25:39.949591Z","shell.execute_reply.started":"2022-07-06T21:25:39.939656Z","shell.execute_reply":"2022-07-06T21:25:39.948685Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"categorical_columns = [c for c in df_train.columns if df_train[c].dtype.name == 'object' and c != 'MasVnrArea']","metadata":{"execution":{"iopub.status.busy":"2022-07-06T21:25:46.997899Z","iopub.execute_input":"2022-07-06T21:25:46.998281Z","iopub.status.idle":"2022-07-06T21:25:47.00669Z","shell.execute_reply.started":"2022-07-06T21:25:46.99825Z","shell.execute_reply":"2022-07-06T21:25:47.005648Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(categorical_columns)","metadata":{"execution":{"iopub.status.busy":"2022-07-06T21:25:47.873091Z","iopub.execute_input":"2022-07-06T21:25:47.873687Z","iopub.status.idle":"2022-07-06T21:25:47.880233Z","shell.execute_reply.started":"2022-07-06T21:25:47.873654Z","shell.execute_reply":"2022-07-06T21:25:47.879122Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"MasVnrArea to numeric\n","metadata":{}},{"cell_type":"markdown","source":"### Attempt to feature eng.","metadata":{}},{"cell_type":"code","source":"fig, ax = plt.subplots()\nax.scatter(x = df_train['GrLivArea'], y = df_train['SalePrice'])\nplt.ylabel('SalePrice', fontsize=13)\nplt.xlabel('GrLivArea', fontsize=13)\nplt.grid()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-06T21:26:09.946003Z","iopub.execute_input":"2022-07-06T21:26:09.946976Z","iopub.status.idle":"2022-07-06T21:26:10.209175Z","shell.execute_reply.started":"2022-07-06T21:26:09.946925Z","shell.execute_reply":"2022-07-06T21:26:10.20828Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train = df_train.drop(df_train[(df_train['GrLivArea']>4000) & (df_train['SalePrice']<300000)].index)\n\n#Check the graphic again\nfig, ax = plt.subplots()\nax.scatter(df_train['GrLivArea'], df_train['SalePrice'])\nplt.ylabel('SalePrice', fontsize=13)\nplt.xlabel('GrLivArea', fontsize=13)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-06T21:29:42.523772Z","iopub.execute_input":"2022-07-06T21:29:42.524343Z","iopub.status.idle":"2022-07-06T21:29:42.77457Z","shell.execute_reply.started":"2022-07-06T21:29:42.524281Z","shell.execute_reply":"2022-07-06T21:29:42.773563Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = df_train.hist(figsize=(35, 33), bins=60, color=\"cyan\",\n                         edgecolor=\"gray\", xlabelsize=10, ylabelsize=10)","metadata":{"execution":{"iopub.status.busy":"2022-07-06T19:51:58.883389Z","iopub.execute_input":"2022-07-06T19:51:58.884269Z","iopub.status.idle":"2022-07-06T19:52:06.731201Z","shell.execute_reply.started":"2022-07-06T19:51:58.884223Z","shell.execute_reply":"2022-07-06T19:52:06.730125Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"LotFrontage,\nLotArea,\nMasVnrArea,\nBsmtFinSF1,\nBsmtFinSF2,\n2ndFlrSF,\nLowQualFinSF,\nMiscVal,\nPoolArea,\nScreenPorch,\n3SsnPorch,\nEnclosedPorch,\nOpenPorchSF,\nWoodDeckSF,\n\n**This data have \"long tail\"**\n\n**Using log1p may improve the score**","metadata":{}},{"cell_type":"code","source":"categorical_features = [i for i in df_train.columns if df_train.dtypes[i] == \"object\"]\ncategoric = df_train[categorical_features]\n\nfig, axes = plt.subplots(\n    round(len(categoric.columns) / 3), 3, figsize=(25, 50))\n\nfor i, ax in enumerate(fig.axes):\n\n    if i < len(categoric.columns) - 1:\n        ax.set_xticklabels(ax.xaxis.get_majorticklabels(), rotation=45)\n        sns.countplot(x=categoric.columns[i], alpha=0.7, data=categoric, ax=ax)\n\nfig.tight_layout()","metadata":{"execution":{"iopub.status.busy":"2022-07-06T19:52:06.732776Z","iopub.execute_input":"2022-07-06T19:52:06.733194Z","iopub.status.idle":"2022-07-06T19:52:15.867999Z","shell.execute_reply.started":"2022-07-06T19:52:06.733161Z","shell.execute_reply":"2022-07-06T19:52:15.866956Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Street,LandContour,Utilities,LandSlope,Condition2, RoofMatl,** \n\n**ExterCond,Heating,BsmtFinType2,GarageQual, GarageCond, Functional for deleting**\n\n","metadata":{}},{"cell_type":"code","source":"delete = ['Street','LandContour','Utilities','LandSlope','Condition2', 'RoofMatl','ExterCond','Heating',\n          'BsmtFinType2','GarageQual', 'GarageCond']\n\n#df_train.drop(columns = delete, inplace = True)","metadata":{"execution":{"iopub.status.busy":"2022-07-06T19:52:15.869882Z","iopub.execute_input":"2022-07-06T19:52:15.870299Z","iopub.status.idle":"2022-07-06T19:52:15.878431Z","shell.execute_reply.started":"2022-07-06T19:52:15.870261Z","shell.execute_reply":"2022-07-06T19:52:15.877301Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"log1p = ['LotFrontage','LotArea','MasVnrArea','BsmtFinSF1','BsmtFinSF2','2ndFlrSF','LowQualFinSF',\n         'MiscVal','PoolArea','ScreenPorch','3SsnPorch','EnclosedPorch','OpenPorchSF','WoodDeckSF']\n\nfig = df_train[log1p].hist(figsize=(35, 33), bins=60, color=\"cyan\",\n                         edgecolor=\"gray\", xlabelsize=10, ylabelsize=10)\n","metadata":{"execution":{"iopub.status.busy":"2022-07-06T19:52:15.882087Z","iopub.execute_input":"2022-07-06T19:52:15.882536Z","iopub.status.idle":"2022-07-06T19:52:18.755917Z","shell.execute_reply.started":"2022-07-06T19:52:15.882501Z","shell.execute_reply":"2022-07-06T19:52:18.754836Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x = df_train['MasVnrArea']\nx.hist(bins = 50)","metadata":{"execution":{"iopub.status.busy":"2022-07-06T19:52:18.757684Z","iopub.execute_input":"2022-07-06T19:52:18.758059Z","iopub.status.idle":"2022-07-06T19:52:19.007994Z","shell.execute_reply.started":"2022-07-06T19:52:18.758012Z","shell.execute_reply":"2022-07-06T19:52:19.007132Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### After the test I found out that np.log and deleting degrades the score -(\n### However, we can to delete column names \"Utilities\" because it has all similar values - \"All\"","metadata":{}},{"cell_type":"code","source":"df_train.drop(columns = 'Utilities', inplace = True)","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X = df_train.drop(columns = 'SalePrice')\nY = df_train['SalePrice']","metadata":{"execution":{"iopub.status.busy":"2022-07-06T19:52:19.011012Z","iopub.execute_input":"2022-07-06T19:52:19.011709Z","iopub.status.idle":"2022-07-06T19:52:19.01824Z","shell.execute_reply.started":"2022-07-06T19:52:19.01167Z","shell.execute_reply":"2022-07-06T19:52:19.017042Z"},"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)","metadata":{"execution":{"iopub.status.busy":"2022-07-06T19:52:19.019759Z","iopub.execute_input":"2022-07-06T19:52:19.020185Z","iopub.status.idle":"2022-07-06T19:52:19.029997Z","shell.execute_reply.started":"2022-07-06T19:52:19.020148Z","shell.execute_reply":"2022-07-06T19:52:19.028981Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\"\"\"\nfrom sklearn.model_selection import KFold\n\ncategorical_columns = [c for c in df_train.columns if df_train[c].dtype.name == 'object' and c != 'MasVnrArea']\n\ncv = KFold(n_splits=10, shuffle=True, random_state=42)\n\nparam = {'learning_rate': [0.03, 0.1],\n        'depth': [4, 6, 10],\n        'l2_leaf_reg': [1, 3, 5, 7, 9]}\n\ncb = CatBoostRegressor(random_state=42, \n                       logging_level='Silent', \n                       task_type = 'GPU', \n                       cat_features = categorical_columns)\n\ngrid_search_result = cb.grid_search(param, X=X_train, cv=cv, y=y_train)\n\"\"\"\n","metadata":{"execution":{"iopub.status.busy":"2022-07-06T19:53:07.118297Z","iopub.execute_input":"2022-07-06T19:53:07.119363Z","iopub.status.idle":"2022-07-06T20:36:05.238261Z","shell.execute_reply.started":"2022-07-06T19:53:07.119327Z","shell.execute_reply":"2022-07-06T20:36:05.237355Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\"\"\"categorical_columns = [c for c in df_train.columns if df_train[c].dtype.name == 'object' and c != 'MasVnrArea']\n\ncatboost = CatBoostRegressor(iterations = 1000,\n                             learning_rate = 0.03,\n                             depth =  4,\n                             l2_leaf_reg = 7)\ncatboost.fit(X_train, y_train, cat_features = categorical_columns, silent = True)\"\"\"","metadata":{"execution":{"iopub.status.busy":"2022-07-06T20:52:09.884252Z","iopub.execute_input":"2022-07-06T20:52:09.884793Z","iopub.status.idle":"2022-07-06T20:52:18.519127Z","shell.execute_reply.started":"2022-07-06T20:52:09.88475Z","shell.execute_reply":"2022-07-06T20:52:18.518135Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"categorical_columns = [c for c in df_train.columns if df_train[c].dtype.name == 'object' and c != 'MasVnrArea']\n\ncatboost = CatBoostRegressor()\ncatboost.fit(X_train, y_train, cat_features = categorical_columns, silent = True)","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dt_test = pd.read_csv(test_dirname)\nNames = dt_test['Id'].apply(int)\ndt_test.drop(\"Id\", axis = 1, inplace = True)\n\ndt_test","metadata":{"execution":{"iopub.status.busy":"2022-07-06T20:52:23.446412Z","iopub.execute_input":"2022-07-06T20:52:23.446882Z","iopub.status.idle":"2022-07-06T20:52:23.510132Z","shell.execute_reply.started":"2022-07-06T20:52:23.446839Z","shell.execute_reply":"2022-07-06T20:52:23.508594Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dt_test.drop(columns = 'FireplaceQu', inplace = True)\ndt_test.drop(columns = ['Alley', 'MiscFeature','PoolQC','Fence'], inplace = True)\ndt_test.drop(columns = 'Utilities', inplace = True)","metadata":{"execution":{"iopub.status.busy":"2022-07-06T20:52:26.29113Z","iopub.execute_input":"2022-07-06T20:52:26.29182Z","iopub.status.idle":"2022-07-06T20:52:26.301252Z","shell.execute_reply.started":"2022-07-06T20:52:26.291782Z","shell.execute_reply":"2022-07-06T20:52:26.300213Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cat = []\nnum = []\nfor column in dt_test.columns:\n    count = dt_test[column].isna().sum()\n    if count != 0:\n        if dt_test[column].dtype.name == 'object' or column == 'MasVnrArea':\n            cat.append(column)\n        elif dt_test[column].dtype.name != 'object' and column != 'MasVnrArea':\n            num.append(column)","metadata":{"execution":{"iopub.status.busy":"2022-07-06T20:52:28.479346Z","iopub.execute_input":"2022-07-06T20:52:28.480284Z","iopub.status.idle":"2022-07-06T20:52:28.512572Z","shell.execute_reply.started":"2022-07-06T20:52:28.480235Z","shell.execute_reply":"2022-07-06T20:52:28.511257Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dt_test[num] = SimpleImputer(strategy=\"mean\").fit_transform(dt_test[num])\ndt_test[cat] = SimpleImputer(strategy=\"most_frequent\").fit_transform(dt_test[cat])","metadata":{"execution":{"iopub.status.busy":"2022-07-06T20:52:28.909444Z","iopub.execute_input":"2022-07-06T20:52:28.909787Z","iopub.status.idle":"2022-07-06T20:52:28.932429Z","shell.execute_reply.started":"2022-07-06T20:52:28.909758Z","shell.execute_reply":"2022-07-06T20:52:28.931568Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#dt_test.drop(columns = delete, inplace = True)","metadata":{"execution":{"iopub.status.busy":"2022-07-06T20:52:31.817131Z","iopub.execute_input":"2022-07-06T20:52:31.817754Z","iopub.status.idle":"2022-07-06T20:52:31.82604Z","shell.execute_reply.started":"2022-07-06T20:52:31.817716Z","shell.execute_reply":"2022-07-06T20:52:31.824884Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_pred = catboost.predict(dt_test)\ny_pred","metadata":{"execution":{"iopub.status.busy":"2022-07-06T20:52:32.763406Z","iopub.execute_input":"2022-07-06T20:52:32.763752Z","iopub.status.idle":"2022-07-06T20:52:32.791087Z","shell.execute_reply.started":"2022-07-06T20:52:32.763724Z","shell.execute_reply":"2022-07-06T20:52:32.790202Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Names","metadata":{"execution":{"iopub.status.busy":"2022-07-06T20:52:33.708793Z","iopub.execute_input":"2022-07-06T20:52:33.709666Z","iopub.status.idle":"2022-07-06T20:52:33.719331Z","shell.execute_reply.started":"2022-07-06T20:52:33.709615Z","shell.execute_reply":"2022-07-06T20:52:33.718235Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pred_df = pd.DataFrame(list(zip(Names, y_pred)), columns = ['Id', 'SalePrice'])\npred_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-06T20:52:36.291959Z","iopub.execute_input":"2022-07-06T20:52:36.292339Z","iopub.status.idle":"2022-07-06T20:52:36.304369Z","shell.execute_reply.started":"2022-07-06T20:52:36.292309Z","shell.execute_reply":"2022-07-06T20:52:36.303438Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pred_df.to_csv(\"submission.csv\", index=False)","metadata":{"execution":{"iopub.status.busy":"2022-07-06T20:52:37.390084Z","iopub.execute_input":"2022-07-06T20:52:37.390778Z","iopub.status.idle":"2022-07-06T20:52:37.403958Z","shell.execute_reply.started":"2022-07-06T20:52:37.39074Z","shell.execute_reply":"2022-07-06T20:52:37.403059Z"},"trusted":true},"execution_count":null,"outputs":[]}]}