{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nfrom catboost import CatBoostRegressor\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-28T18:39:16.923849Z","iopub.execute_input":"2022-07-28T18:39:16.924480Z","iopub.status.idle":"2022-07-28T18:39:16.938525Z","shell.execute_reply.started":"2022-07-28T18:39:16.924447Z","shell.execute_reply":"2022-07-28T18:39:16.937584Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data = pd.read_csv(\"../input/house-prices-advanced-regression-techniques/train.csv\")\ntest_data = pd.read_csv(\"../input/house-prices-advanced-regression-techniques/test.csv\")\ntrain_data.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-28T18:39:17.013492Z","iopub.execute_input":"2022-07-28T18:39:17.013922Z","iopub.status.idle":"2022-07-28T18:39:17.084549Z","shell.execute_reply.started":"2022-07-28T18:39:17.013885Z","shell.execute_reply":"2022-07-28T18:39:17.083334Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"all_data = pd.concat([train_data, test_data], axis='rows')\nall_data.shape[0] == train_data.shape[0] + test_data.shape[0]","metadata":{"execution":{"iopub.status.busy":"2022-07-28T18:39:17.113049Z","iopub.execute_input":"2022-07-28T18:39:17.113449Z","iopub.status.idle":"2022-07-28T18:39:17.138666Z","shell.execute_reply.started":"2022-07-28T18:39:17.113417Z","shell.execute_reply":"2022-07-28T18:39:17.137851Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"all_data.set_index(\"Id\", inplace=True)\nall_data.info()","metadata":{"execution":{"iopub.status.busy":"2022-07-28T18:39:17.193535Z","iopub.execute_input":"2022-07-28T18:39:17.194600Z","iopub.status.idle":"2022-07-28T18:39:17.226427Z","shell.execute_reply.started":"2022-07-28T18:39:17.194561Z","shell.execute_reply":"2022-07-28T18:39:17.225255Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.get_dummies(data=all_data,)","metadata":{"execution":{"iopub.status.busy":"2022-07-28T18:39:17.276010Z","iopub.execute_input":"2022-07-28T18:39:17.276439Z","iopub.status.idle":"2022-07-28T18:39:17.721221Z","shell.execute_reply.started":"2022-07-28T18:39:17.276404Z","shell.execute_reply":"2022-07-28T18:39:17.719982Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dummy_data = pd.get_dummies(all_data, columns=all_data.select_dtypes(include='object').columns)\ndummy_data.shape","metadata":{"execution":{"iopub.status.busy":"2022-07-28T18:39:17.723005Z","iopub.execute_input":"2022-07-28T18:39:17.723348Z","iopub.status.idle":"2022-07-28T18:39:17.784996Z","shell.execute_reply.started":"2022-07-28T18:39:17.723318Z","shell.execute_reply":"2022-07-28T18:39:17.784071Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_count = train_data.shape[0]\ntrain_data.tail()","metadata":{"execution":{"iopub.status.busy":"2022-07-28T18:39:17.786077Z","iopub.execute_input":"2022-07-28T18:39:17.786914Z","iopub.status.idle":"2022-07-28T18:39:17.811941Z","shell.execute_reply.started":"2022-07-28T18:39:17.786876Z","shell.execute_reply":"2022-07-28T18:39:17.810807Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model = CatBoostRegressor()\ntrain_data = dummy_data.iloc[:train_count]\ntest_data = dummy_data.iloc[train_count:].drop([\"SalePrice\"], axis='columns')\ntrain_data.tail()","metadata":{"execution":{"iopub.status.busy":"2022-07-28T18:40:35.192044Z","iopub.execute_input":"2022-07-28T18:40:35.192431Z","iopub.status.idle":"2022-07-28T18:40:35.222476Z","shell.execute_reply.started":"2022-07-28T18:40:35.192398Z","shell.execute_reply":"2022-07-28T18:40:35.221088Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_data.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-28T18:40:50.194259Z","iopub.execute_input":"2022-07-28T18:40:50.195215Z","iopub.status.idle":"2022-07-28T18:40:50.218351Z","shell.execute_reply.started":"2022-07-28T18:40:50.195169Z","shell.execute_reply":"2022-07-28T18:40:50.217163Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train = train_data.drop(['SalePrice'], axis='columns')\ny_train = train_data.SalePrice","metadata":{"execution":{"iopub.status.busy":"2022-07-28T18:43:24.644664Z","iopub.execute_input":"2022-07-28T18:43:24.645739Z","iopub.status.idle":"2022-07-28T18:43:24.652685Z","shell.execute_reply.started":"2022-07-28T18:43:24.645700Z","shell.execute_reply":"2022-07-28T18:43:24.651467Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.fit(X_train, y_train)","metadata":{"execution":{"iopub.status.busy":"2022-07-28T18:49:34.448918Z","iopub.execute_input":"2022-07-28T18:49:34.449369Z","iopub.status.idle":"2022-07-28T18:49:38.544794Z","shell.execute_reply.started":"2022-07-28T18:49:34.449334Z","shell.execute_reply":"2022-07-28T18:49:38.543704Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"prediction = pd.read_csv(\"../input/house-prices-advanced-regression-techniques/sample_submission.csv\")\nprediction.SalePrice = model.predict(test_data)\nprediction.to_csv(\"sample_submission.csv\", index=False)","metadata":{"execution":{"iopub.status.busy":"2022-07-28T19:02:05.731206Z","iopub.execute_input":"2022-07-28T19:02:05.731956Z","iopub.status.idle":"2022-07-28T19:02:05.756829Z","shell.execute_reply.started":"2022-07-28T19:02:05.731916Z","shell.execute_reply":"2022-07-28T19:02:05.755490Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.predict(test_data)","metadata":{"execution":{"iopub.status.busy":"2022-07-28T19:01:21.194121Z","iopub.execute_input":"2022-07-28T19:01:21.194709Z","iopub.status.idle":"2022-07-28T19:01:21.212895Z","shell.execute_reply.started":"2022-07-28T19:01:21.194674Z","shell.execute_reply":"2022-07-28T19:01:21.211832Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"prediction.head()  ","metadata":{"execution":{"iopub.status.busy":"2022-07-28T19:02:07.426379Z","iopub.execute_input":"2022-07-28T19:02:07.429240Z","iopub.status.idle":"2022-07-28T19:02:07.439256Z","shell.execute_reply.started":"2022-07-28T19:02:07.429197Z","shell.execute_reply":"2022-07-28T19:02:07.438005Z"},"trusted":true},"execution_count":null,"outputs":[]}]}