{"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)\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\n","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:16:26.829461Z","iopub.execute_input":"2022-08-09T08:16:26.830002Z","iopub.status.idle":"2022-08-09T08:16:26.865789Z","shell.execute_reply.started":"2022-08-09T08:16:26.829882Z","shell.execute_reply":"2022-08-09T08:16:26.864775Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_test = pd.read_csv(\"/kaggle/input/spaceship-titanic/test.csv\")\ndf_train = pd.read_csv(\"/kaggle/input/spaceship-titanic/train.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:17:07.291321Z","iopub.execute_input":"2022-08-09T08:17:07.291948Z","iopub.status.idle":"2022-08-09T08:17:07.371774Z","shell.execute_reply.started":"2022-08-09T08:17:07.291895Z","shell.execute_reply":"2022-08-09T08:17:07.370810Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_ids = df_test[\"PassengerId\"]","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:17:11.018332Z","iopub.execute_input":"2022-08-09T08:17:11.018930Z","iopub.status.idle":"2022-08-09T08:17:11.032644Z","shell.execute_reply.started":"2022-08-09T08:17:11.018878Z","shell.execute_reply":"2022-08-09T08:17:11.031080Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.head(5)","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:17:14.435401Z","iopub.execute_input":"2022-08-09T08:17:14.436020Z","iopub.status.idle":"2022-08-09T08:17:14.468353Z","shell.execute_reply.started":"2022-08-09T08:17:14.435968Z","shell.execute_reply":"2022-08-09T08:17:14.467292Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.info()","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:17:17.010280Z","iopub.execute_input":"2022-08-09T08:17:17.010689Z","iopub.status.idle":"2022-08-09T08:17:17.042235Z","shell.execute_reply.started":"2022-08-09T08:17:17.010656Z","shell.execute_reply":"2022-08-09T08:17:17.040881Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train = df_train.drop([\"Cabin\", \"Name\"], axis = 1)","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:17:22.435084Z","iopub.execute_input":"2022-08-09T08:17:22.435510Z","iopub.status.idle":"2022-08-09T08:17:22.444950Z","shell.execute_reply.started":"2022-08-09T08:17:22.435473Z","shell.execute_reply":"2022-08-09T08:17:22.443807Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:17:24.501927Z","iopub.execute_input":"2022-08-09T08:17:24.502679Z","iopub.status.idle":"2022-08-09T08:17:24.533680Z","shell.execute_reply.started":"2022-08-09T08:17:24.502624Z","shell.execute_reply":"2022-08-09T08:17:24.532478Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train[\"Total expenses\"] = df_train[\"RoomService\"] + df_train[\"FoodCourt\"] + df_train[\"ShoppingMall\"] + df_train[\"Spa\"]","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:17:31.445413Z","iopub.execute_input":"2022-08-09T08:17:31.445848Z","iopub.status.idle":"2022-08-09T08:17:31.454306Z","shell.execute_reply.started":"2022-08-09T08:17:31.445810Z","shell.execute_reply":"2022-08-09T08:17:31.452841Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train[\"Total expenses\"] = df_train[\"Total expenses\"] + df_train[\"VRDeck\"]","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:17:33.555781Z","iopub.execute_input":"2022-08-09T08:17:33.556693Z","iopub.status.idle":"2022-08-09T08:17:33.562966Z","shell.execute_reply.started":"2022-08-09T08:17:33.556652Z","shell.execute_reply":"2022-08-09T08:17:33.561750Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:17:35.423420Z","iopub.execute_input":"2022-08-09T08:17:35.424614Z","iopub.status.idle":"2022-08-09T08:17:35.465913Z","shell.execute_reply.started":"2022-08-09T08:17:35.424545Z","shell.execute_reply":"2022-08-09T08:17:35.464627Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train = df_train.drop([\"RoomService\", \"FoodCourt\", \"ShoppingMall\", \"Spa\", \"VRDeck\"], axis = 1)","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:17:41.631853Z","iopub.execute_input":"2022-08-09T08:17:41.632282Z","iopub.status.idle":"2022-08-09T08:17:41.640811Z","shell.execute_reply.started":"2022-08-09T08:17:41.632249Z","shell.execute_reply":"2022-08-09T08:17:41.639676Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:17:43.252516Z","iopub.execute_input":"2022-08-09T08:17:43.252954Z","iopub.status.idle":"2022-08-09T08:17:43.277145Z","shell.execute_reply.started":"2022-08-09T08:17:43.252918Z","shell.execute_reply":"2022-08-09T08:17:43.275954Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x = df_train[\"Total expenses\"].mean()\n\nmask1 = df_train[\"Total expenses\"] >= x\ndf_train.loc[mask1, \"Total expenses\"] = 1\nmask2 = df_train[\"Total expenses\"] != 1\ndf_train.loc[mask2, \"Total expenses\"] = 0","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:17:51.719302Z","iopub.execute_input":"2022-08-09T08:17:51.719773Z","iopub.status.idle":"2022-08-09T08:17:51.730009Z","shell.execute_reply.started":"2022-08-09T08:17:51.719715Z","shell.execute_reply":"2022-08-09T08:17:51.728653Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:17:54.183994Z","iopub.execute_input":"2022-08-09T08:17:54.184579Z","iopub.status.idle":"2022-08-09T08:17:54.216822Z","shell.execute_reply.started":"2022-08-09T08:17:54.184530Z","shell.execute_reply":"2022-08-09T08:17:54.215475Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.info()","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:17:57.092855Z","iopub.execute_input":"2022-08-09T08:17:57.094199Z","iopub.status.idle":"2022-08-09T08:17:57.111141Z","shell.execute_reply.started":"2022-08-09T08:17:57.094145Z","shell.execute_reply":"2022-08-09T08:17:57.110187Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train = df_train.dropna()","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:18:04.602535Z","iopub.execute_input":"2022-08-09T08:18:04.602991Z","iopub.status.idle":"2022-08-09T08:18:04.617623Z","shell.execute_reply.started":"2022-08-09T08:18:04.602953Z","shell.execute_reply":"2022-08-09T08:18:04.616359Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.info()","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:18:06.873235Z","iopub.execute_input":"2022-08-09T08:18:06.874137Z","iopub.status.idle":"2022-08-09T08:18:06.894557Z","shell.execute_reply.started":"2022-08-09T08:18:06.874095Z","shell.execute_reply":"2022-08-09T08:18:06.893552Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:18:09.495067Z","iopub.execute_input":"2022-08-09T08:18:09.495511Z","iopub.status.idle":"2022-08-09T08:18:09.519150Z","shell.execute_reply.started":"2022-08-09T08:18:09.495474Z","shell.execute_reply":"2022-08-09T08:18:09.518208Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train = df_train.reset_index()","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:18:13.176855Z","iopub.execute_input":"2022-08-09T08:18:13.177483Z","iopub.status.idle":"2022-08-09T08:18:13.184791Z","shell.execute_reply.started":"2022-08-09T08:18:13.177439Z","shell.execute_reply":"2022-08-09T08:18:13.183813Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train = df_train.drop(\"index\", axis = 1)","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:18:15.968295Z","iopub.execute_input":"2022-08-09T08:18:15.969287Z","iopub.status.idle":"2022-08-09T08:18:15.976804Z","shell.execute_reply.started":"2022-08-09T08:18:15.969241Z","shell.execute_reply":"2022-08-09T08:18:15.975555Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:18:18.539378Z","iopub.execute_input":"2022-08-09T08:18:18.540562Z","iopub.status.idle":"2022-08-09T08:18:18.563555Z","shell.execute_reply.started":"2022-08-09T08:18:18.540505Z","shell.execute_reply":"2022-08-09T08:18:18.562255Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train[\"Transported\"] = df_train[\"Transported\"].astype(\"int\")\ndf_train[\"CryoSleep\"] = df_train[\"CryoSleep\"].astype(\"int\")\ndf_train[\"VIP\"] = df_train[\"VIP\"].astype(\"int\")","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:18:21.864690Z","iopub.execute_input":"2022-08-09T08:18:21.865434Z","iopub.status.idle":"2022-08-09T08:18:21.875334Z","shell.execute_reply.started":"2022-08-09T08:18:21.865381Z","shell.execute_reply":"2022-08-09T08:18:21.874110Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:18:25.458215Z","iopub.execute_input":"2022-08-09T08:18:25.459057Z","iopub.status.idle":"2022-08-09T08:18:25.480912Z","shell.execute_reply.started":"2022-08-09T08:18:25.459015Z","shell.execute_reply":"2022-08-09T08:18:25.480023Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train[\"Total expenses\"] = df_train[\"Total expenses\"].astype(\"int\")","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:18:28.943791Z","iopub.execute_input":"2022-08-09T08:18:28.944612Z","iopub.status.idle":"2022-08-09T08:18:28.950766Z","shell.execute_reply.started":"2022-08-09T08:18:28.944568Z","shell.execute_reply":"2022-08-09T08:18:28.949365Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:18:31.318566Z","iopub.execute_input":"2022-08-09T08:18:31.318982Z","iopub.status.idle":"2022-08-09T08:18:31.339869Z","shell.execute_reply.started":"2022-08-09T08:18:31.318949Z","shell.execute_reply":"2022-08-09T08:18:31.338517Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train[\"HomePlanet\"].value_counts()\nHomePlanet_is_Earth = df_train[\"HomePlanet\"] == \"Earth\"\nHomePlanet_is_Europa = df_train[\"HomePlanet\"] == \"Europa\"\nHomePlanet_is_Mars = df_train[\"HomePlanet\"] == \"Mars\"\ndf_train.loc[HomePlanet_is_Earth, \"HomePlanet\"] = 0\ndf_train.loc[HomePlanet_is_Europa, \"HomePlanet\"] = 1\ndf_train.loc[HomePlanet_is_Mars, \"HomePlanet\"] = 2","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:18:35.028045Z","iopub.execute_input":"2022-08-09T08:18:35.028517Z","iopub.status.idle":"2022-08-09T08:18:35.048946Z","shell.execute_reply.started":"2022-08-09T08:18:35.028480Z","shell.execute_reply":"2022-08-09T08:18:35.047647Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train[\"Destination\"].value_counts()\nDestination_is_TRAPPIST = df_train[\"Destination\"] == \"TRAPPIST-1e\"\nDestination_is_Cancri = df_train[\"Destination\"] == \"55 Cancri e\"\nDestination_is_PSO = df_train[\"Destination\"] == \"PSO J318.5-22\"\ndf_train.loc[Destination_is_TRAPPIST, \"Destination\"] = 0\ndf_train.loc[Destination_is_Cancri, \"Destination\"] = 1\ndf_train.loc[Destination_is_PSO, \"Destination\"] = 2\ndf_train.info()","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:18:39.001218Z","iopub.execute_input":"2022-08-09T08:18:39.001619Z","iopub.status.idle":"2022-08-09T08:18:39.026373Z","shell.execute_reply.started":"2022-08-09T08:18:39.001585Z","shell.execute_reply":"2022-08-09T08:18:39.025107Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train[\"HomePlanet\"] = df_train[\"HomePlanet\"].astype(\"int\")\ndf_train[\"Destination\"] = df_train[\"Destination\"].astype(\"int\")\ndf_train[\"Age\"] = df_train[\"Age\"].astype(\"int\")","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:18:42.807068Z","iopub.execute_input":"2022-08-09T08:18:42.807494Z","iopub.status.idle":"2022-08-09T08:18:42.817305Z","shell.execute_reply.started":"2022-08-09T08:18:42.807460Z","shell.execute_reply":"2022-08-09T08:18:42.816331Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.info()","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:18:45.427234Z","iopub.execute_input":"2022-08-09T08:18:45.427687Z","iopub.status.idle":"2022-08-09T08:18:45.445800Z","shell.execute_reply.started":"2022-08-09T08:18:45.427649Z","shell.execute_reply":"2022-08-09T08:18:45.444280Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_test","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:18:54.226695Z","iopub.execute_input":"2022-08-09T08:18:54.227124Z","iopub.status.idle":"2022-08-09T08:18:54.260630Z","shell.execute_reply.started":"2022-08-09T08:18:54.227088Z","shell.execute_reply":"2022-08-09T08:18:54.259608Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_test.info()","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:18:58.214091Z","iopub.execute_input":"2022-08-09T08:18:58.214816Z","iopub.status.idle":"2022-08-09T08:18:58.231014Z","shell.execute_reply.started":"2022-08-09T08:18:58.214747Z","shell.execute_reply":"2022-08-09T08:18:58.229804Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_test = df_test.drop([\"Cabin\", \"Name\"], axis = 1)\ndf_test[\"Total expenses\"] = df_test[\"RoomService\"] + df_test[\"FoodCourt\"] + df_test[\"ShoppingMall\"] + df_test[\"Spa\"]\ndf_test[\"Total expenses\"] = df_test[\"Total expenses\"] + df_test[\"VRDeck\"]\ndf_test = df_test.drop([\"RoomService\", \"FoodCourt\", \"ShoppingMall\", \"Spa\", \"VRDeck\"], axis = 1)\nx = df_test[\"Total expenses\"].mean()\nmask1 = df_test[\"Total expenses\"] >= x\ndf_test.loc[mask1, \"Total expenses\"] = 1\nmask2 = df_test[\"Total expenses\"] != 1\ndf_test.loc[mask2, \"Total expenses\"] = 0","metadata":{"scrolled":true,"execution":{"iopub.status.busy":"2022-08-09T08:19:06.807815Z","iopub.execute_input":"2022-08-09T08:19:06.808311Z","iopub.status.idle":"2022-08-09T08:19:06.829027Z","shell.execute_reply.started":"2022-08-09T08:19:06.808268Z","shell.execute_reply":"2022-08-09T08:19:06.827824Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"HomePlanet_is_Earth = df_test[\"HomePlanet\"] == \"Earth\"\nHomePlanet_is_Europa = df_test[\"HomePlanet\"] == \"Europa\"\nHomePlanet_is_Mars = df_test[\"HomePlanet\"] == \"Mars\"\ndf_test.loc[HomePlanet_is_Earth, \"HomePlanet\"] = 0\ndf_test.loc[HomePlanet_is_Europa, \"HomePlanet\"] = 1\ndf_test.loc[HomePlanet_is_Mars, \"HomePlanet\"] = 2","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:19:09.981163Z","iopub.execute_input":"2022-08-09T08:19:09.981596Z","iopub.status.idle":"2022-08-09T08:19:09.993544Z","shell.execute_reply.started":"2022-08-09T08:19:09.981561Z","shell.execute_reply":"2022-08-09T08:19:09.992152Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Destination_is_TRAPPIST = df_test[\"Destination\"] == \"TRAPPIST-1e\"\nDestination_is_Cancri = df_test[\"Destination\"] == \"55 Cancri e\"\nDestination_is_PSO = df_test[\"Destination\"] == \"PSO J318.5-22\"\ndf_test.loc[Destination_is_TRAPPIST, \"Destination\"] = 0\ndf_test.loc[Destination_is_Cancri, \"Destination\"] = 1\ndf_test.loc[Destination_is_PSO, \"Destination\"] = 2","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:19:13.406884Z","iopub.execute_input":"2022-08-09T08:19:13.407538Z","iopub.status.idle":"2022-08-09T08:19:13.417420Z","shell.execute_reply.started":"2022-08-09T08:19:13.407501Z","shell.execute_reply":"2022-08-09T08:19:13.416281Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_test[\"Age\"] = df_test[\"Age\"].fillna(df_test[\"Age\"].mean())","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:19:19.714052Z","iopub.execute_input":"2022-08-09T08:19:19.714496Z","iopub.status.idle":"2022-08-09T08:19:19.722950Z","shell.execute_reply.started":"2022-08-09T08:19:19.714460Z","shell.execute_reply":"2022-08-09T08:19:19.720952Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_test[\"Destination\"] = df_test[\"Destination\"].fillna(0)","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:19:22.551654Z","iopub.execute_input":"2022-08-09T08:19:22.552202Z","iopub.status.idle":"2022-08-09T08:19:22.561290Z","shell.execute_reply.started":"2022-08-09T08:19:22.552158Z","shell.execute_reply":"2022-08-09T08:19:22.559903Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_test[\"CryoSleep\"] = df_test[\"CryoSleep\"].fillna(0)\ndf_test[\"VIP\"] = df_test[\"VIP\"].fillna(0)","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:19:26.149339Z","iopub.execute_input":"2022-08-09T08:19:26.149804Z","iopub.status.idle":"2022-08-09T08:19:26.158654Z","shell.execute_reply.started":"2022-08-09T08:19:26.149768Z","shell.execute_reply":"2022-08-09T08:19:26.157439Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_test.info()","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:19:28.994429Z","iopub.execute_input":"2022-08-09T08:19:28.994913Z","iopub.status.idle":"2022-08-09T08:19:29.011062Z","shell.execute_reply.started":"2022-08-09T08:19:28.994871Z","shell.execute_reply":"2022-08-09T08:19:29.010039Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_test[\"HomePlanet\"] = df_test[\"HomePlanet\"].fillna(0)","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:19:33.063364Z","iopub.execute_input":"2022-08-09T08:19:33.063795Z","iopub.status.idle":"2022-08-09T08:19:33.072308Z","shell.execute_reply.started":"2022-08-09T08:19:33.063742Z","shell.execute_reply":"2022-08-09T08:19:33.070888Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_test = df_test.reset_index()\ndf_test = df_test.drop(\"index\", axis = 1)\ndf_test[\"CryoSleep\"] = df_test[\"CryoSleep\"].astype(\"int\")\ndf_test[\"VIP\"] = df_test[\"VIP\"].astype(\"int\")\ndf_test[\"Total expenses\"] = df_test[\"Total expenses\"].astype(\"int\")","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:19:41.285087Z","iopub.execute_input":"2022-08-09T08:19:41.285512Z","iopub.status.idle":"2022-08-09T08:19:41.299424Z","shell.execute_reply.started":"2022-08-09T08:19:41.285478Z","shell.execute_reply":"2022-08-09T08:19:41.298060Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_test[\"HomePlanet\"] = df_test[\"HomePlanet\"].astype(\"int\")\ndf_test[\"Destination\"] = df_test[\"Destination\"].astype(\"int\")\ndf_test[\"Age\"] = df_test[\"Age\"].astype(\"int\")","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:19:44.144818Z","iopub.execute_input":"2022-08-09T08:19:44.145379Z","iopub.status.idle":"2022-08-09T08:19:44.153836Z","shell.execute_reply.started":"2022-08-09T08:19:44.145337Z","shell.execute_reply":"2022-08-09T08:19:44.152509Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_test = df_test.drop([\"PassengerId\"], axis = 1)","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:19:48.449853Z","iopub.execute_input":"2022-08-09T08:19:48.450270Z","iopub.status.idle":"2022-08-09T08:19:48.457566Z","shell.execute_reply.started":"2022-08-09T08:19:48.450236Z","shell.execute_reply":"2022-08-09T08:19:48.456208Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_test","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:19:51.159658Z","iopub.execute_input":"2022-08-09T08:19:51.160532Z","iopub.status.idle":"2022-08-09T08:19:51.175607Z","shell.execute_reply.started":"2022-08-09T08:19:51.160487Z","shell.execute_reply":"2022-08-09T08:19:51.173831Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:19:56.090170Z","iopub.execute_input":"2022-08-09T08:19:56.090635Z","iopub.status.idle":"2022-08-09T08:19:56.113269Z","shell.execute_reply.started":"2022-08-09T08:19:56.090594Z","shell.execute_reply":"2022-08-09T08:19:56.112371Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.linear_model import LogisticRegression\nfrom sklearn.model_selection import train_test_split","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:20:09.795722Z","iopub.execute_input":"2022-08-09T08:20:09.796214Z","iopub.status.idle":"2022-08-09T08:20:09.802398Z","shell.execute_reply.started":"2022-08-09T08:20:09.796175Z","shell.execute_reply":"2022-08-09T08:20:09.800547Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y = df_train[\"Transported\"]","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:20:12.278076Z","iopub.execute_input":"2022-08-09T08:20:12.278976Z","iopub.status.idle":"2022-08-09T08:20:12.285614Z","shell.execute_reply.started":"2022-08-09T08:20:12.278919Z","shell.execute_reply":"2022-08-09T08:20:12.284298Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x = df_train.drop([\"Transported\", \"PassengerId\"], axis = 1)","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:20:15.113045Z","iopub.execute_input":"2022-08-09T08:20:15.113433Z","iopub.status.idle":"2022-08-09T08:20:15.121836Z","shell.execute_reply.started":"2022-08-09T08:20:15.113402Z","shell.execute_reply":"2022-08-09T08:20:15.120446Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_train, x_val, y_train, y_val = train_test_split(x, y, test_size=0.2, random_state=42)","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:20:17.650319Z","iopub.execute_input":"2022-08-09T08:20:17.650739Z","iopub.status.idle":"2022-08-09T08:20:17.660021Z","shell.execute_reply.started":"2022-08-09T08:20:17.650706Z","shell.execute_reply":"2022-08-09T08:20:17.658928Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"clf = LogisticRegression(random_state=0, max_iter=1000).fit(x_train, y_train)","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:20:20.718561Z","iopub.execute_input":"2022-08-09T08:20:20.719024Z","iopub.status.idle":"2022-08-09T08:20:20.778176Z","shell.execute_reply.started":"2022-08-09T08:20:20.718985Z","shell.execute_reply":"2022-08-09T08:20:20.776825Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predictions = clf.predict(x_val)","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:20:31.326701Z","iopub.execute_input":"2022-08-09T08:20:31.327118Z","iopub.status.idle":"2022-08-09T08:20:31.340155Z","shell.execute_reply.started":"2022-08-09T08:20:31.327077Z","shell.execute_reply":"2022-08-09T08:20:31.338532Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import accuracy_score\naccuracy_score(y_val, predictions)","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:20:36.691510Z","iopub.execute_input":"2022-08-09T08:20:36.692110Z","iopub.status.idle":"2022-08-09T08:20:36.700269Z","shell.execute_reply.started":"2022-08-09T08:20:36.692064Z","shell.execute_reply":"2022-08-09T08:20:36.699098Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission_pred = clf.predict(df_test)","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:20:39.898387Z","iopub.execute_input":"2022-08-09T08:20:39.898912Z","iopub.status.idle":"2022-08-09T08:20:39.912234Z","shell.execute_reply.started":"2022-08-09T08:20:39.898853Z","shell.execute_reply":"2022-08-09T08:20:39.910717Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dfinal = pd.DataFrame({\"PassengerId\": test_ids.values, \"Transported\":submission_pred})","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:20:42.846232Z","iopub.execute_input":"2022-08-09T08:20:42.847359Z","iopub.status.idle":"2022-08-09T08:20:42.853353Z","shell.execute_reply.started":"2022-08-09T08:20:42.847311Z","shell.execute_reply":"2022-08-09T08:20:42.852263Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dfinal[\"Transported\"] = dfinal[\"Transported\"].astype(\"bool\")","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:20:45.233971Z","iopub.execute_input":"2022-08-09T08:20:45.234487Z","iopub.status.idle":"2022-08-09T08:20:45.243631Z","shell.execute_reply.started":"2022-08-09T08:20:45.234449Z","shell.execute_reply":"2022-08-09T08:20:45.242705Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dfinal.to_csv(\"submission.csv\", index = False)","metadata":{"execution":{"iopub.status.busy":"2022-08-09T08:20:48.250031Z","iopub.execute_input":"2022-08-09T08:20:48.250437Z","iopub.status.idle":"2022-08-09T08:20:48.264802Z","shell.execute_reply.started":"2022-08-09T08:20:48.250403Z","shell.execute_reply":"2022-08-09T08:20:48.263696Z"},"trusted":true},"execution_count":null,"outputs":[]}]}