{"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 pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nimport os\n\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.linear_model import LinearRegression\nfrom sklearn.tree import DecisionTreeRegressor\nfrom sklearn.neighbors import KNeighborsRegressor\nfrom sklearn.ensemble import RandomForestRegressor\nfrom sklearn.ensemble import GradientBoostingRegressor\n\nfrom sklearn import metrics\nfrom sklearn.metrics import r2_score\n\nfrom sklearn.model_selection import GridSearchCV\n\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-14T11:02:02.118581Z","iopub.execute_input":"2022-07-14T11:02:02.119036Z","iopub.status.idle":"2022-07-14T11:02:03.514406Z","shell.execute_reply.started":"2022-07-14T11:02:02.118957Z","shell.execute_reply":"2022-07-14T11:02:03.512723Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def cek_outliers (df, features):\n    Q1 = df[features].quantile(0.25)\n    Q3 = df[features].quantile(0.75)\n    IQR = Q3 - Q1\n    lower_bound = Q1 - 1.5*IQR\n    upper_bound = Q3 + 1.5*IQR\n    q_lower_bound=df[features][(df[features])<lower_bound].count()\n    q_upper_bound=df[features][(df[features])>upper_bound].count()\n    print(f'lower_bound ={lower_bound}, upper_bound ={upper_bound}')\n    print(f'Total outlier lower = {q_lower_bound}, Total outlier upper = {q_upper_bound}')\n    return lower_bound,upper_bound\n\ndef remove_outliers (df, features, lower, upper):\n    df = df[(df[features]<=upper)]\n    df = df[(df[features]>=lower)]\n    return df\n\ndef cek_akurasi_supervised_regression (model, X_test, y_test):\n    predict_model = model.predict(X_test)\n    print('Mean Absolute Percentage Error:', metrics.mean_absolute_percentage_error(y_test, predict_model))\n    print('Mean Absolute Error:', metrics.mean_absolute_error(y_test, predict_model))\n    print('Mean Squared Error:', metrics.mean_squared_error(y_test, predict_model))\n    print('Root Mean Squared Error:', np.sqrt(metrics.mean_squared_error(y_test, predict_model)))\n    print('R Squared Score is:', metrics.r2_score(y_test, predict_model)) \n\ndef feature_importance(model):\n    importance = model.coef_\n    # summarize feature importance\n    for i,v in enumerate(importance):\n        print('Feature: %0d, Score: %.5f' % (i,v))\n    # plot feature importance\n    plt.bar([x for x in range(len(importance))], importance)\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:03.517923Z","iopub.execute_input":"2022-07-14T11:02:03.518646Z","iopub.status.idle":"2022-07-14T11:02:03.537965Z","shell.execute_reply.started":"2022-07-14T11:02:03.518598Z","shell.execute_reply":"2022-07-14T11:02:03.536741Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.read_csv('/kaggle/input/house-prices-advanced-regression-techniques/train.csv')\ndf.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:03.539704Z","iopub.execute_input":"2022-07-14T11:02:03.540415Z","iopub.status.idle":"2022-07-14T11:02:03.646071Z","shell.execute_reply.started":"2022-07-14T11:02:03.540370Z","shell.execute_reply":"2022-07-14T11:02:03.645132Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.columns","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:03.648112Z","iopub.execute_input":"2022-07-14T11:02:03.648726Z","iopub.status.idle":"2022-07-14T11:02:03.656018Z","shell.execute_reply.started":"2022-07-14T11:02:03.648688Z","shell.execute_reply":"2022-07-14T11:02:03.654982Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.info()","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:03.657573Z","iopub.execute_input":"2022-07-14T11:02:03.657903Z","iopub.status.idle":"2022-07-14T11:02:03.697334Z","shell.execute_reply.started":"2022-07-14T11:02:03.657875Z","shell.execute_reply":"2022-07-14T11:02:03.696449Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = df.drop(columns=['Id'])","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:03.698984Z","iopub.execute_input":"2022-07-14T11:02:03.699343Z","iopub.status.idle":"2022-07-14T11:02:03.705582Z","shell.execute_reply.started":"2022-07-14T11:02:03.699310Z","shell.execute_reply":"2022-07-14T11:02:03.704599Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['LotFrontage'] = df['LotFrontage'].fillna(0)","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:03.707176Z","iopub.execute_input":"2022-07-14T11:02:03.707693Z","iopub.status.idle":"2022-07-14T11:02:03.717798Z","shell.execute_reply.started":"2022-07-14T11:02:03.707663Z","shell.execute_reply":"2022-07-14T11:02:03.717006Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['LotFrontage'].head()","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:03.718979Z","iopub.execute_input":"2022-07-14T11:02:03.719478Z","iopub.status.idle":"2022-07-14T11:02:03.734165Z","shell.execute_reply.started":"2022-07-14T11:02:03.719444Z","shell.execute_reply":"2022-07-14T11:02:03.733018Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['Alley'].head()","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:03.735664Z","iopub.execute_input":"2022-07-14T11:02:03.736453Z","iopub.status.idle":"2022-07-14T11:02:03.745895Z","shell.execute_reply.started":"2022-07-14T11:02:03.736419Z","shell.execute_reply":"2022-07-14T11:02:03.744999Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['Alley'] = df['Alley'].fillna('NoAlley')","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:03.749591Z","iopub.execute_input":"2022-07-14T11:02:03.749970Z","iopub.status.idle":"2022-07-14T11:02:03.756718Z","shell.execute_reply.started":"2022-07-14T11:02:03.749938Z","shell.execute_reply":"2022-07-14T11:02:03.755616Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:03.758227Z","iopub.execute_input":"2022-07-14T11:02:03.759435Z","iopub.status.idle":"2022-07-14T11:02:03.784313Z","shell.execute_reply.started":"2022-07-14T11:02:03.759396Z","shell.execute_reply":"2022-07-14T11:02:03.782711Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['MasVnrType'][(df['MasVnrType'].isna())]","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:03.786123Z","iopub.execute_input":"2022-07-14T11:02:03.788519Z","iopub.status.idle":"2022-07-14T11:02:03.797105Z","shell.execute_reply.started":"2022-07-14T11:02:03.788480Z","shell.execute_reply":"2022-07-14T11:02:03.796263Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['MasVnrType'] = df['MasVnrType'].fillna('None')","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:03.798329Z","iopub.execute_input":"2022-07-14T11:02:03.799474Z","iopub.status.idle":"2022-07-14T11:02:03.807516Z","shell.execute_reply.started":"2022-07-14T11:02:03.799441Z","shell.execute_reply":"2022-07-14T11:02:03.806473Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['MasVnrArea'][(df['MasVnrArea'].isna())]","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:03.808960Z","iopub.execute_input":"2022-07-14T11:02:03.809326Z","iopub.status.idle":"2022-07-14T11:02:03.820918Z","shell.execute_reply.started":"2022-07-14T11:02:03.809295Z","shell.execute_reply":"2022-07-14T11:02:03.820154Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['MasVnrArea'] = df['MasVnrArea'].fillna(0)","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:03.821982Z","iopub.execute_input":"2022-07-14T11:02:03.822796Z","iopub.status.idle":"2022-07-14T11:02:03.832536Z","shell.execute_reply.started":"2022-07-14T11:02:03.822765Z","shell.execute_reply":"2022-07-14T11:02:03.831374Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['BsmtQual'][(df['BsmtQual'].isna())]","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:03.834286Z","iopub.execute_input":"2022-07-14T11:02:03.835606Z","iopub.status.idle":"2022-07-14T11:02:03.849904Z","shell.execute_reply.started":"2022-07-14T11:02:03.835554Z","shell.execute_reply":"2022-07-14T11:02:03.849004Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['BsmtQual'].unique()","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:03.851665Z","iopub.execute_input":"2022-07-14T11:02:03.852028Z","iopub.status.idle":"2022-07-14T11:02:03.866210Z","shell.execute_reply.started":"2022-07-14T11:02:03.851995Z","shell.execute_reply":"2022-07-14T11:02:03.865347Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(x=df['BsmtQual'])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:03.867513Z","iopub.execute_input":"2022-07-14T11:02:03.868043Z","iopub.status.idle":"2022-07-14T11:02:04.131831Z","shell.execute_reply.started":"2022-07-14T11:02:03.868011Z","shell.execute_reply":"2022-07-14T11:02:04.130650Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['BsmtQual'] = df['BsmtQual'].fillna('NoBasement')","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:04.133653Z","iopub.execute_input":"2022-07-14T11:02:04.134446Z","iopub.status.idle":"2022-07-14T11:02:04.142446Z","shell.execute_reply.started":"2022-07-14T11:02:04.134399Z","shell.execute_reply":"2022-07-14T11:02:04.140756Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(x=df['BsmtCond'])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:04.144617Z","iopub.execute_input":"2022-07-14T11:02:04.145170Z","iopub.status.idle":"2022-07-14T11:02:04.331079Z","shell.execute_reply.started":"2022-07-14T11:02:04.145137Z","shell.execute_reply":"2022-07-14T11:02:04.330275Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['BsmtCond'] = df['BsmtCond'].fillna('NoBasement')","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:04.332471Z","iopub.execute_input":"2022-07-14T11:02:04.333369Z","iopub.status.idle":"2022-07-14T11:02:04.339026Z","shell.execute_reply.started":"2022-07-14T11:02:04.333336Z","shell.execute_reply":"2022-07-14T11:02:04.338104Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(x=df['BsmtCond'])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:04.343682Z","iopub.execute_input":"2022-07-14T11:02:04.344848Z","iopub.status.idle":"2022-07-14T11:02:04.555040Z","shell.execute_reply.started":"2022-07-14T11:02:04.344767Z","shell.execute_reply":"2022-07-14T11:02:04.554184Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(x=df['BsmtExposure'])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:04.556091Z","iopub.execute_input":"2022-07-14T11:02:04.556940Z","iopub.status.idle":"2022-07-14T11:02:04.730990Z","shell.execute_reply.started":"2022-07-14T11:02:04.556906Z","shell.execute_reply":"2022-07-14T11:02:04.730129Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['BsmtExposure'] = df['BsmtExposure'].fillna('NoBasement')","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:04.732552Z","iopub.execute_input":"2022-07-14T11:02:04.733650Z","iopub.status.idle":"2022-07-14T11:02:04.739091Z","shell.execute_reply.started":"2022-07-14T11:02:04.733611Z","shell.execute_reply":"2022-07-14T11:02:04.737881Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(x=df['BsmtFinType1'])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:04.740985Z","iopub.execute_input":"2022-07-14T11:02:04.741508Z","iopub.status.idle":"2022-07-14T11:02:04.927942Z","shell.execute_reply.started":"2022-07-14T11:02:04.741460Z","shell.execute_reply":"2022-07-14T11:02:04.927111Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['BsmtFinType1'] = df['BsmtFinType1'].fillna('NoBasement')","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:04.929130Z","iopub.execute_input":"2022-07-14T11:02:04.929478Z","iopub.status.idle":"2022-07-14T11:02:04.936120Z","shell.execute_reply.started":"2022-07-14T11:02:04.929446Z","shell.execute_reply":"2022-07-14T11:02:04.934987Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(x=df['BsmtFinType2'])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:04.937627Z","iopub.execute_input":"2022-07-14T11:02:04.937957Z","iopub.status.idle":"2022-07-14T11:02:05.147614Z","shell.execute_reply.started":"2022-07-14T11:02:04.937928Z","shell.execute_reply":"2022-07-14T11:02:05.146304Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['BsmtFinType2'] = df['BsmtFinType2'].fillna('NoBasement')","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:05.152263Z","iopub.execute_input":"2022-07-14T11:02:05.152665Z","iopub.status.idle":"2022-07-14T11:02:05.159548Z","shell.execute_reply.started":"2022-07-14T11:02:05.152629Z","shell.execute_reply":"2022-07-14T11:02:05.158286Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(x=df['Electrical'])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:05.161304Z","iopub.execute_input":"2022-07-14T11:02:05.162313Z","iopub.status.idle":"2022-07-14T11:02:05.353846Z","shell.execute_reply.started":"2022-07-14T11:02:05.162276Z","shell.execute_reply":"2022-07-14T11:02:05.352652Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['Electrical'] = df['Electrical'].fillna('SBrkr')","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:05.355416Z","iopub.execute_input":"2022-07-14T11:02:05.355792Z","iopub.status.idle":"2022-07-14T11:02:05.362660Z","shell.execute_reply.started":"2022-07-14T11:02:05.355759Z","shell.execute_reply":"2022-07-14T11:02:05.361253Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(x=df['FireplaceQu'])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:05.364220Z","iopub.execute_input":"2022-07-14T11:02:05.364599Z","iopub.status.idle":"2022-07-14T11:02:05.552234Z","shell.execute_reply.started":"2022-07-14T11:02:05.364568Z","shell.execute_reply":"2022-07-14T11:02:05.550896Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['FireplaceQu'] = df['FireplaceQu'].fillna('NoFireplace')","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:05.553767Z","iopub.execute_input":"2022-07-14T11:02:05.554160Z","iopub.status.idle":"2022-07-14T11:02:05.561560Z","shell.execute_reply.started":"2022-07-14T11:02:05.554099Z","shell.execute_reply":"2022-07-14T11:02:05.560136Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(x=df['GarageType'])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:05.563022Z","iopub.execute_input":"2022-07-14T11:02:05.563956Z","iopub.status.idle":"2022-07-14T11:02:05.761875Z","shell.execute_reply.started":"2022-07-14T11:02:05.563909Z","shell.execute_reply":"2022-07-14T11:02:05.760484Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['GarageType'] = df['GarageType'].fillna('NoGarage')","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:05.764086Z","iopub.execute_input":"2022-07-14T11:02:05.764583Z","iopub.status.idle":"2022-07-14T11:02:05.771789Z","shell.execute_reply.started":"2022-07-14T11:02:05.764536Z","shell.execute_reply":"2022-07-14T11:02:05.770411Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.distplot(x=df['GarageYrBlt'])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:05.773739Z","iopub.execute_input":"2022-07-14T11:02:05.774807Z","iopub.status.idle":"2022-07-14T11:02:05.990398Z","shell.execute_reply.started":"2022-07-14T11:02:05.774756Z","shell.execute_reply":"2022-07-14T11:02:05.989112Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(x=df['GarageFinish'])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:05.992509Z","iopub.execute_input":"2022-07-14T11:02:05.993414Z","iopub.status.idle":"2022-07-14T11:02:06.124539Z","shell.execute_reply.started":"2022-07-14T11:02:05.993365Z","shell.execute_reply":"2022-07-14T11:02:06.123392Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['GarageFinish'] = df['GarageFinish'].fillna('NoGarage')","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:06.126619Z","iopub.execute_input":"2022-07-14T11:02:06.127547Z","iopub.status.idle":"2022-07-14T11:02:06.135189Z","shell.execute_reply.started":"2022-07-14T11:02:06.127480Z","shell.execute_reply":"2022-07-14T11:02:06.133683Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(x=df['GarageCond'])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:06.138164Z","iopub.execute_input":"2022-07-14T11:02:06.139955Z","iopub.status.idle":"2022-07-14T11:02:06.327313Z","shell.execute_reply.started":"2022-07-14T11:02:06.139915Z","shell.execute_reply":"2022-07-14T11:02:06.325863Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['GarageCond'] = df['GarageCond'].fillna('NoGarage')","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:06.333715Z","iopub.execute_input":"2022-07-14T11:02:06.334089Z","iopub.status.idle":"2022-07-14T11:02:06.340932Z","shell.execute_reply.started":"2022-07-14T11:02:06.334058Z","shell.execute_reply":"2022-07-14T11:02:06.339354Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(x=df['GarageQual'])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:06.343078Z","iopub.execute_input":"2022-07-14T11:02:06.343694Z","iopub.status.idle":"2022-07-14T11:02:06.525591Z","shell.execute_reply.started":"2022-07-14T11:02:06.343657Z","shell.execute_reply":"2022-07-14T11:02:06.524583Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['GarageQual'] = df['GarageQual'].fillna('NoGarage')","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:06.526730Z","iopub.execute_input":"2022-07-14T11:02:06.527567Z","iopub.status.idle":"2022-07-14T11:02:06.533901Z","shell.execute_reply.started":"2022-07-14T11:02:06.527534Z","shell.execute_reply":"2022-07-14T11:02:06.532960Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(x=df['PavedDrive'])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:06.535607Z","iopub.execute_input":"2022-07-14T11:02:06.536432Z","iopub.status.idle":"2022-07-14T11:02:06.714145Z","shell.execute_reply.started":"2022-07-14T11:02:06.536384Z","shell.execute_reply":"2022-07-14T11:02:06.713279Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(x=df['PoolQC'])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:06.715251Z","iopub.execute_input":"2022-07-14T11:02:06.716341Z","iopub.status.idle":"2022-07-14T11:02:07.087465Z","shell.execute_reply.started":"2022-07-14T11:02:06.716304Z","shell.execute_reply":"2022-07-14T11:02:07.086005Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['PoolQC'] = df['PoolQC'].fillna('NoPool')","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:07.089320Z","iopub.execute_input":"2022-07-14T11:02:07.090861Z","iopub.status.idle":"2022-07-14T11:02:07.099343Z","shell.execute_reply.started":"2022-07-14T11:02:07.090808Z","shell.execute_reply":"2022-07-14T11:02:07.097986Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(x=df['Fence'])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:07.101350Z","iopub.execute_input":"2022-07-14T11:02:07.101960Z","iopub.status.idle":"2022-07-14T11:02:07.287431Z","shell.execute_reply.started":"2022-07-14T11:02:07.101898Z","shell.execute_reply":"2022-07-14T11:02:07.286274Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['Fence'] = df['Fence'].fillna('NoFence')","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:07.289130Z","iopub.execute_input":"2022-07-14T11:02:07.289766Z","iopub.status.idle":"2022-07-14T11:02:07.295528Z","shell.execute_reply.started":"2022-07-14T11:02:07.289731Z","shell.execute_reply":"2022-07-14T11:02:07.294341Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(x=df['MiscFeature'])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:07.297347Z","iopub.execute_input":"2022-07-14T11:02:07.297896Z","iopub.status.idle":"2022-07-14T11:02:07.471255Z","shell.execute_reply.started":"2022-07-14T11:02:07.297854Z","shell.execute_reply":"2022-07-14T11:02:07.470190Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['MiscFeature'] = df['MiscFeature'].fillna('None')","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:07.472652Z","iopub.execute_input":"2022-07-14T11:02:07.473663Z","iopub.status.idle":"2022-07-14T11:02:07.479907Z","shell.execute_reply.started":"2022-07-14T11:02:07.473627Z","shell.execute_reply":"2022-07-14T11:02:07.478760Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.info()","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:07.481412Z","iopub.execute_input":"2022-07-14T11:02:07.481763Z","iopub.status.idle":"2022-07-14T11:02:07.515176Z","shell.execute_reply.started":"2022-07-14T11:02:07.481736Z","shell.execute_reply":"2022-07-14T11:02:07.514274Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:07.516412Z","iopub.execute_input":"2022-07-14T11:02:07.517123Z","iopub.status.idle":"2022-07-14T11:02:07.550179Z","shell.execute_reply.started":"2022-07-14T11:02:07.517088Z","shell.execute_reply":"2022-07-14T11:02:07.548919Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.corr()","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:02:07.551816Z","iopub.execute_input":"2022-07-14T11:02:07.552847Z","iopub.status.idle":"2022-07-14T11:02:07.617908Z","shell.execute_reply.started":"2022-07-14T11:02:07.552814Z","shell.execute_reply":"2022-07-14T11:02:07.616407Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Multicollinearity Test","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(35,20))\nsns.heatmap(df.corr(), annot = True)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:05:05.374769Z","iopub.execute_input":"2022-07-14T11:05:05.375161Z","iopub.status.idle":"2022-07-14T11:05:11.083732Z","shell.execute_reply.started":"2022-07-14T11:05:05.375131Z","shell.execute_reply":"2022-07-14T11:05:11.082400Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"We want to know what affect SalePrices, by looking at the heatmap, some candidates are:\n- OverallQual \n- YearBuilt \n- YearRemodAdd\n- TotalBsmtSF\n- 1stFlrSF\n- GrLivArrea\n- FullBath\n- TotRmsAbvGrd\n- GarageCars\n- GarageArea","metadata":{}},{"cell_type":"code","source":"sns.pairplot(df, vars = ['SalePrice', 'OverallQual', 'YearBuilt', 'TotalBsmtSF', '1stFlrSF', \n                         'GrLivArea', 'FullBath', 'TotRmsAbvGrd', 'GarageCars', 'GarageArea']);","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:20:05.464506Z","iopub.execute_input":"2022-07-14T11:20:05.464897Z","iopub.status.idle":"2022-07-14T11:20:25.286663Z","shell.execute_reply.started":"2022-07-14T11:20:05.464864Z","shell.execute_reply":"2022-07-14T11:20:25.285494Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\nfeature = ['SalePrice', 'OverallQual', 'YearBuilt', 'TotalBsmtSF', '1stFlrSF','GrLivArea', 'FullBath', 'TotRmsAbvGrd', 'GarageCars', 'GarageArea']\n\nplt.figure(figsize=(35,20))\nsns.heatmap(df[feature].corr(), annot = True)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:22:32.996005Z","iopub.execute_input":"2022-07-14T11:22:32.997068Z","iopub.status.idle":"2022-07-14T11:22:33.787524Z","shell.execute_reply.started":"2022-07-14T11:22:32.997028Z","shell.execute_reply":"2022-07-14T11:22:33.786487Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"From the pairplot something we can notice:\n- TotalBsmtSF and 1stFlrSF are highly correlated\n- GrLivArea and TotRmsAbvGrd are highly correlated\n- GarageCars and GarageArea are highly correlated\n- We suspect there are a lot of multicolinearity between the numeric variables","metadata":{}},{"cell_type":"markdown","source":"# Preliminary Modelling","metadata":{}},{"cell_type":"code","source":"features = ['OverallQual', 'YearBuilt', 'TotalBsmtSF', '1stFlrSF','GrLivArea', 'FullBath', 'TotRmsAbvGrd', 'GarageCars', 'GarageArea']\n\nX = df[features]\ny = df['SalePrice']\n\n# one hot encoding\nX = pd.get_dummies(X)\n\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)\n\nmodel = GradientBoostingRegressor(random_state=0)\nmodel.fit(X_train,y_train)\n\ncek_akurasi_supervised_regression(model,X_test,y_test)","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:28:59.629777Z","iopub.execute_input":"2022-07-14T11:28:59.630233Z","iopub.status.idle":"2022-07-14T11:28:59.850568Z","shell.execute_reply.started":"2022-07-14T11:28:59.630136Z","shell.execute_reply":"2022-07-14T11:28:59.849398Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"features = ['OverallQual']\n\nX = df[features]\ny = df['SalePrice']\n\n# one hot encoding\nX = pd.get_dummies(X)\n\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)\n\nmodel = GradientBoostingRegressor(random_state=0)\nmodel.fit(X_train,y_train)\n\ncek_akurasi_supervised_regression(model,X_test,y_test)","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:30:04.844789Z","iopub.execute_input":"2022-07-14T11:30:04.845191Z","iopub.status.idle":"2022-07-14T11:30:04.911252Z","shell.execute_reply.started":"2022-07-14T11:30:04.845161Z","shell.execute_reply":"2022-07-14T11:30:04.909999Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"R2 Accuracy at preliminary model is 66.87%\n\nContinue to add another Feature","metadata":{}},{"cell_type":"code","source":"features = ['OverallQual','YearBuilt']\n\nX = df[features]\ny = df['SalePrice']\n\n# one hot encoding\nX = pd.get_dummies(X)\n\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)\n\nmodel = GradientBoostingRegressor(random_state=0)\nmodel.fit(X_train,y_train)\n\ncek_akurasi_supervised_regression(model,X_test,y_test)","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:30:24.617746Z","iopub.execute_input":"2022-07-14T11:30:24.618966Z","iopub.status.idle":"2022-07-14T11:30:24.702701Z","shell.execute_reply.started":"2022-07-14T11:30:24.618914Z","shell.execute_reply":"2022-07-14T11:30:24.701635Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"R2 Accuracy at this model is 72.17%\n\nContinue to add another Feature","metadata":{}},{"cell_type":"code","source":"features = ['OverallQual','YearBuilt','TotalBsmtSF']\n\nX = df[features]\ny = df['SalePrice']\n\n# one hot encoding\nX = pd.get_dummies(X)\n\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)\n\nmodel = GradientBoostingRegressor(random_state=0)\nmodel.fit(X_train,y_train)\n\ncek_akurasi_supervised_regression(model,X_test,y_test)","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:30:51.626698Z","iopub.execute_input":"2022-07-14T11:30:51.627071Z","iopub.status.idle":"2022-07-14T11:30:51.743592Z","shell.execute_reply.started":"2022-07-14T11:30:51.627042Z","shell.execute_reply":"2022-07-14T11:30:51.742287Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"R2 Accuracy at this model is 72.87%\n\nContinue to add another Feature","metadata":{}},{"cell_type":"code","source":"features = ['OverallQual','YearBuilt','TotalBsmtSF','1stFlrSF']\n\nX = df[features]\ny = df['SalePrice']\n\n# one hot encoding\nX = pd.get_dummies(X)\n\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)\n\nmodel = GradientBoostingRegressor(random_state=0)\nmodel.fit(X_train,y_train)\n\ncek_akurasi_supervised_regression(model,X_test,y_test)","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:31:25.617510Z","iopub.execute_input":"2022-07-14T11:31:25.618617Z","iopub.status.idle":"2022-07-14T11:31:25.766173Z","shell.execute_reply.started":"2022-07-14T11:31:25.618577Z","shell.execute_reply":"2022-07-14T11:31:25.765056Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"R2 Accuracy at this model is 74.45%\n\nContinue to add another Feature","metadata":{}},{"cell_type":"code","source":"features = ['OverallQual','YearBuilt','TotalBsmtSF','1stFlrSF','GrLivArea']\n\nX = df[features]\ny = df['SalePrice']\n\n# one hot encoding\nX = pd.get_dummies(X)\n\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)\n\nmodel = GradientBoostingRegressor(random_state=0)\nmodel.fit(X_train,y_train)\n\ncek_akurasi_supervised_regression(model,X_test,y_test)","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:32:03.127013Z","iopub.execute_input":"2022-07-14T11:32:03.127428Z","iopub.status.idle":"2022-07-14T11:32:03.303551Z","shell.execute_reply.started":"2022-07-14T11:32:03.127396Z","shell.execute_reply":"2022-07-14T11:32:03.302219Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"R2 Accuracy at this model is 87.22%\n\nContinue to add another Feature","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:32:15.593613Z","iopub.execute_input":"2022-07-14T11:32:15.594107Z","iopub.status.idle":"2022-07-14T11:32:15.601382Z","shell.execute_reply.started":"2022-07-14T11:32:15.594069Z","shell.execute_reply":"2022-07-14T11:32:15.599880Z"}}},{"cell_type":"code","source":"features = ['OverallQual','YearBuilt','TotalBsmtSF','1stFlrSF','GrLivArea','FullBath']\n\nX = df[features]\ny = df['SalePrice']\n\n# one hot encoding\nX = pd.get_dummies(X)\n\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)\n\nmodel = GradientBoostingRegressor(random_state=0)\nmodel.fit(X_train,y_train)\n\ncek_akurasi_supervised_regression(model,X_test,y_test)","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:32:26.928055Z","iopub.execute_input":"2022-07-14T11:32:26.928482Z","iopub.status.idle":"2022-07-14T11:32:27.112267Z","shell.execute_reply.started":"2022-07-14T11:32:26.928446Z","shell.execute_reply":"2022-07-14T11:32:27.110983Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"R2 Accuracy at this model is 87.46%\n\nContinue to add another Feature","metadata":{}},{"cell_type":"code","source":"features = ['OverallQual', 'YearBuilt', 'TotalBsmtSF', '1stFlrSF','GrLivArea', 'FullBath', 'TotRmsAbvGrd']\n\nX = df[features]\ny = df['SalePrice']\n\n# one hot encoding\nX = pd.get_dummies(X)\n\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)\n\nmodel = GradientBoostingRegressor(random_state=0)\nmodel.fit(X_train,y_train)\n\ncek_akurasi_supervised_regression(model,X_test,y_test)","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:32:54.704509Z","iopub.execute_input":"2022-07-14T11:32:54.704897Z","iopub.status.idle":"2022-07-14T11:32:54.895736Z","shell.execute_reply.started":"2022-07-14T11:32:54.704868Z","shell.execute_reply":"2022-07-14T11:32:54.894421Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"R2 Accuracy at this model is 87.41%\n\nremove the TotRmsAbvGrd and\n\nContinue to add another Feature","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:33:24.221516Z","iopub.execute_input":"2022-07-14T11:33:24.221908Z","iopub.status.idle":"2022-07-14T11:33:24.229503Z","shell.execute_reply.started":"2022-07-14T11:33:24.221878Z","shell.execute_reply":"2022-07-14T11:33:24.227630Z"}}},{"cell_type":"code","source":"features = ['OverallQual', 'YearBuilt', 'TotalBsmtSF', '1stFlrSF','GrLivArea', 'FullBath', 'GarageCars']\n\nX = df[features]\ny = df['SalePrice']\n\n# one hot encoding\nX = pd.get_dummies(X)\n\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)\n\nmodel = GradientBoostingRegressor(random_state=0)\nmodel.fit(X_train,y_train)\n\ncek_akurasi_supervised_regression(model,X_test,y_test)","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:33:39.670840Z","iopub.execute_input":"2022-07-14T11:33:39.671250Z","iopub.status.idle":"2022-07-14T11:33:39.857340Z","shell.execute_reply.started":"2022-07-14T11:33:39.671193Z","shell.execute_reply":"2022-07-14T11:33:39.855960Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"R2 Accuracy at this model is 87.91%\n\nContinue to add another Feature","metadata":{}},{"cell_type":"code","source":"features = ['OverallQual', 'YearBuilt', 'TotalBsmtSF', '1stFlrSF','GrLivArea', 'FullBath', 'GarageCars','GarageArea']\n\nX = df[features]\ny = df['SalePrice']\n\n# one hot encoding\nX = pd.get_dummies(X)\n\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)\n\nmodel = GradientBoostingRegressor(random_state=0)\nmodel.fit(X_train,y_train)\n\ncek_akurasi_supervised_regression(model,X_test,y_test)","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:34:08.645703Z","iopub.execute_input":"2022-07-14T11:34:08.646135Z","iopub.status.idle":"2022-07-14T11:34:08.857845Z","shell.execute_reply.started":"2022-07-14T11:34:08.646104Z","shell.execute_reply":"2022-07-14T11:34:08.856580Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"R2 Accuracy at this model is 88.21%\n\nFinal Model","metadata":{}},{"cell_type":"markdown","source":"# Fit with Test.csv","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:36:08.317476Z","iopub.execute_input":"2022-07-14T11:36:08.317860Z","iopub.status.idle":"2022-07-14T11:36:08.322499Z","shell.execute_reply.started":"2022-07-14T11:36:08.317832Z","shell.execute_reply":"2022-07-14T11:36:08.321535Z"}}},{"cell_type":"code","source":"target = pd.read_csv('/kaggle/input/house-prices-advanced-regression-techniques/test.csv')\ntarget.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:42:14.286131Z","iopub.execute_input":"2022-07-14T11:42:14.286520Z","iopub.status.idle":"2022-07-14T11:42:14.332188Z","shell.execute_reply.started":"2022-07-14T11:42:14.286491Z","shell.execute_reply":"2022-07-14T11:42:14.331074Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"target = target[['Id', 'OverallQual', 'YearBuilt', 'TotalBsmtSF', '1stFlrSF','GrLivArea', 'FullBath', 'GarageCars','GarageArea']]\ntarget.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:42:15.220696Z","iopub.execute_input":"2022-07-14T11:42:15.221362Z","iopub.status.idle":"2022-07-14T11:42:15.237408Z","shell.execute_reply.started":"2022-07-14T11:42:15.221327Z","shell.execute_reply":"2022-07-14T11:42:15.236106Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"target.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:42:15.944521Z","iopub.execute_input":"2022-07-14T11:42:15.945218Z","iopub.status.idle":"2022-07-14T11:42:15.955171Z","shell.execute_reply.started":"2022-07-14T11:42:15.945166Z","shell.execute_reply":"2022-07-14T11:42:15.953899Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"target[(target['TotalBsmtSF'].isna()) | (target['GarageCars'].isna()) | (target['GarageArea'].isna())]","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:42:16.637739Z","iopub.execute_input":"2022-07-14T11:42:16.638840Z","iopub.status.idle":"2022-07-14T11:42:16.656143Z","shell.execute_reply.started":"2022-07-14T11:42:16.638793Z","shell.execute_reply":"2022-07-14T11:42:16.654969Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"target['TotalBsmtSF'] = target['TotalBsmtSF'].fillna(0)","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:42:19.170325Z","iopub.execute_input":"2022-07-14T11:42:19.170711Z","iopub.status.idle":"2022-07-14T11:42:19.176537Z","shell.execute_reply.started":"2022-07-14T11:42:19.170682Z","shell.execute_reply":"2022-07-14T11:42:19.175350Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"target['GarageCars'] = target['GarageCars'].fillna(0)","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:42:19.480896Z","iopub.execute_input":"2022-07-14T11:42:19.481297Z","iopub.status.idle":"2022-07-14T11:42:19.488241Z","shell.execute_reply.started":"2022-07-14T11:42:19.481266Z","shell.execute_reply":"2022-07-14T11:42:19.486927Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"target['GarageArea'] = target['GarageArea'].fillna(0)","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:42:19.861089Z","iopub.execute_input":"2022-07-14T11:42:19.861532Z","iopub.status.idle":"2022-07-14T11:42:19.867617Z","shell.execute_reply.started":"2022-07-14T11:42:19.861495Z","shell.execute_reply":"2022-07-14T11:42:19.866449Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"target.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:42:21.366361Z","iopub.execute_input":"2022-07-14T11:42:21.367075Z","iopub.status.idle":"2022-07-14T11:42:21.376564Z","shell.execute_reply.started":"2022-07-14T11:42:21.367038Z","shell.execute_reply":"2022-07-14T11:42:21.375730Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"features = ['OverallQual', 'YearBuilt', 'TotalBsmtSF', '1stFlrSF','GrLivArea', 'FullBath', 'GarageCars','GarageArea']\n\nX = target[features]\n\n# one hot encoding\nX = pd.get_dummies(X)\n\nmodel.predict(X)","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:42:25.944185Z","iopub.execute_input":"2022-07-14T11:42:25.944575Z","iopub.status.idle":"2022-07-14T11:42:25.963142Z","shell.execute_reply.started":"2022-07-14T11:42:25.944546Z","shell.execute_reply":"2022-07-14T11:42:25.961996Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"target['SalePrice'] = model.predict(X)","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:42:27.701986Z","iopub.execute_input":"2022-07-14T11:42:27.702371Z","iopub.status.idle":"2022-07-14T11:42:27.711633Z","shell.execute_reply.started":"2022-07-14T11:42:27.702340Z","shell.execute_reply":"2022-07-14T11:42:27.710832Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"target.head(20)","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:42:28.336761Z","iopub.execute_input":"2022-07-14T11:42:28.337587Z","iopub.status.idle":"2022-07-14T11:42:28.362286Z","shell.execute_reply.started":"2022-07-14T11:42:28.337551Z","shell.execute_reply":"2022-07-14T11:42:28.361273Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"target[['Id','SalePrice']]","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:42:42.912532Z","iopub.execute_input":"2022-07-14T11:42:42.913360Z","iopub.status.idle":"2022-07-14T11:42:42.931448Z","shell.execute_reply.started":"2022-07-14T11:42:42.913309Z","shell.execute_reply":"2022-07-14T11:42:42.930300Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"target[['Id','SalePrice']].to_csv('submission.csv')","metadata":{"execution":{"iopub.status.busy":"2022-07-14T11:43:02.561681Z","iopub.execute_input":"2022-07-14T11:43:02.562810Z","iopub.status.idle":"2022-07-14T11:43:02.579724Z","shell.execute_reply.started":"2022-07-14T11:43:02.562749Z","shell.execute_reply":"2022-07-14T11:43:02.578543Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}