{"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","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-07-22T08:40:19.694751Z","iopub.execute_input":"2022-07-22T08:40:19.695200Z","iopub.status.idle":"2022-07-22T08:40:19.707486Z","shell.execute_reply.started":"2022-07-22T08:40:19.695142Z","shell.execute_reply":"2022-07-22T08:40:19.705927Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## トレーニングCSV読み込み","metadata":{}},{"cell_type":"code","source":"train = pd.read_csv('../input/spaceship-titanic/train.csv')","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:19.711653Z","iopub.execute_input":"2022-07-22T08:40:19.712919Z","iopub.status.idle":"2022-07-22T08:40:19.747455Z","shell.execute_reply.started":"2022-07-22T08:40:19.712866Z","shell.execute_reply":"2022-07-22T08:40:19.746211Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## 相関係数を求める","metadata":{}},{"cell_type":"code","source":"train.corr()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:19.753128Z","iopub.execute_input":"2022-07-22T08:40:19.753915Z","iopub.status.idle":"2022-07-22T08:40:19.773286Z","shell.execute_reply.started":"2022-07-22T08:40:19.753829Z","shell.execute_reply":"2022-07-22T08:40:19.772239Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.describe","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:19.792518Z","iopub.execute_input":"2022-07-22T08:40:19.793370Z","iopub.status.idle":"2022-07-22T08:40:19.814527Z","shell.execute_reply.started":"2022-07-22T08:40:19.793335Z","shell.execute_reply":"2022-07-22T08:40:19.812913Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train=train.drop([\"Name\"],axis=1)\ntrain=train.drop([\"PassengerId\"],axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:19.823614Z","iopub.execute_input":"2022-07-22T08:40:19.824348Z","iopub.status.idle":"2022-07-22T08:40:19.833601Z","shell.execute_reply.started":"2022-07-22T08:40:19.824311Z","shell.execute_reply":"2022-07-22T08:40:19.832068Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## 欠損値の処理","metadata":{}},{"cell_type":"code","source":"train.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:19.862589Z","iopub.execute_input":"2022-07-22T08:40:19.863486Z","iopub.status.idle":"2022-07-22T08:40:19.879279Z","shell.execute_reply.started":"2022-07-22T08:40:19.863450Z","shell.execute_reply":"2022-07-22T08:40:19.877922Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Cabinを3つに分割\ndeck/num/sideの形式<br>\ndeck:キャビンの区画？<br>\nnum:??<br>\nside:PortのPとStarboardのSのどちらか","metadata":{}},{"cell_type":"code","source":"train[\"deck\"]=train[\"Cabin\"].str.split(\"/\",expand=True)[0]\ntrain[\"num\"]=train[\"Cabin\"].str.split(\"/\",expand=True)[1]\ntrain[\"side\"]=train[\"Cabin\"].str.split(\"/\",expand=True)[2]\ntrain=train.drop([\"Cabin\"],axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:19.896588Z","iopub.execute_input":"2022-07-22T08:40:19.899213Z","iopub.status.idle":"2022-07-22T08:40:20.572704Z","shell.execute_reply.started":"2022-07-22T08:40:19.899151Z","shell.execute_reply":"2022-07-22T08:40:20.571591Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### 各列の最頻値を表示\n一番上の値が最頻値","metadata":{}},{"cell_type":"code","source":"train.mode()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:20.574776Z","iopub.execute_input":"2022-07-22T08:40:20.575142Z","iopub.status.idle":"2022-07-22T08:40:20.609443Z","shell.execute_reply.started":"2022-07-22T08:40:20.575111Z","shell.execute_reply":"2022-07-22T08:40:20.608469Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### 最頻値もしくは中央値で欠損値を補完\nBoolean型の時は型変換も行う","metadata":{}},{"cell_type":"code","source":"train[\"HomePlanet\"].fillna(\"Earth\",inplace=True)\ntrain[\"CryoSleep\"].fillna(\"False\",inplace=True)\ntrain[\"CryoSleep\"]=train[\"CryoSleep\"].astype(bool)\ntrain[\"Destination\"].fillna(\"TRAPPIST-1e\",inplace=True)\ntrain[\"VIP\"].fillna(\"False\",inplace=True)\ntrain[\"VIP\"]=train[\"VIP\"].astype(bool)\ntrain[\"RoomService\"].fillna(train[\"RoomService\"].median(),inplace=True)\ntrain[\"FoodCourt\"].fillna(train[\"FoodCourt\"].median(),inplace=True)\ntrain[\"ShoppingMall\"].fillna(train[\"ShoppingMall\"].median(),inplace=True)\ntrain[\"Spa\"].fillna(train[\"Spa\"].median(),inplace=True)\ntrain[\"VRDeck\"].fillna(train[\"VRDeck\"].median(),inplace=True)\ntrain[\"deck\"].fillna(\"F\",inplace=True)\ntrain[\"side\"].fillna(\"S\",inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:20.611038Z","iopub.execute_input":"2022-07-22T08:40:20.612258Z","iopub.status.idle":"2022-07-22T08:40:20.639087Z","shell.execute_reply.started":"2022-07-22T08:40:20.612218Z","shell.execute_reply":"2022-07-22T08:40:20.637790Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train[\"Age\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:20.641579Z","iopub.execute_input":"2022-07-22T08:40:20.642385Z","iopub.status.idle":"2022-07-22T08:40:20.652542Z","shell.execute_reply.started":"2022-07-22T08:40:20.642301Z","shell.execute_reply":"2022-07-22T08:40:20.651047Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train[\"Age\"].fillna(100,inplace=True)\ntrain[\"Age\"]=train[\"Age\"].astype(int)","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:20.653764Z","iopub.execute_input":"2022-07-22T08:40:20.654114Z","iopub.status.idle":"2022-07-22T08:40:20.665629Z","shell.execute_reply.started":"2022-07-22T08:40:20.654083Z","shell.execute_reply":"2022-07-22T08:40:20.664299Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nplt.figure(figsize=(16,9))\nplt.hist(train[\"Age\"],bins=350,color=\"blue\")","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:20.667178Z","iopub.execute_input":"2022-07-22T08:40:20.667829Z","iopub.status.idle":"2022-07-22T08:40:21.660776Z","shell.execute_reply.started":"2022-07-22T08:40:20.667795Z","shell.execute_reply":"2022-07-22T08:40:21.659366Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train[\"num\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:21.662587Z","iopub.execute_input":"2022-07-22T08:40:21.663411Z","iopub.status.idle":"2022-07-22T08:40:21.677333Z","shell.execute_reply.started":"2022-07-22T08:40:21.663358Z","shell.execute_reply":"2022-07-22T08:40:21.676070Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train[\"num\"].fillna(2000,inplace=True)\ntrain[\"num\"]=train[\"num\"].astype(int)","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:21.678952Z","iopub.execute_input":"2022-07-22T08:40:21.679499Z","iopub.status.idle":"2022-07-22T08:40:21.688828Z","shell.execute_reply.started":"2022-07-22T08:40:21.679433Z","shell.execute_reply":"2022-07-22T08:40:21.687742Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(16,9))\nplt.hist(train[\"num\"],bins=350,color=\"blue\")","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:21.690351Z","iopub.execute_input":"2022-07-22T08:40:21.691310Z","iopub.status.idle":"2022-07-22T08:40:22.765780Z","shell.execute_reply.started":"2022-07-22T08:40:21.691275Z","shell.execute_reply":"2022-07-22T08:40:22.764299Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.loc[(0<=train[\"num\"])&(train[\"num\"]<350),\"num\"]=1\ntrain.loc[(350<=train[\"num\"])&(train[\"num\"]<600),\"num\"]=2\ntrain.loc[(600<=train[\"num\"])&(train[\"num\"]<1500),\"num\"]=3\ntrain.loc[(1500<=train[\"num\"])&(train[\"num\"]<2000),\"num\"]=4","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:22.770353Z","iopub.execute_input":"2022-07-22T08:40:22.770780Z","iopub.status.idle":"2022-07-22T08:40:22.785941Z","shell.execute_reply.started":"2022-07-22T08:40:22.770737Z","shell.execute_reply":"2022-07-22T08:40:22.784264Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train[\"num\"].mode()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:22.787509Z","iopub.execute_input":"2022-07-22T08:40:22.787827Z","iopub.status.idle":"2022-07-22T08:40:22.797892Z","shell.execute_reply.started":"2022-07-22T08:40:22.787795Z","shell.execute_reply":"2022-07-22T08:40:22.796734Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.loc[train[\"num\"]==2000,\"num\"]=1","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:22.799011Z","iopub.execute_input":"2022-07-22T08:40:22.799400Z","iopub.status.idle":"2022-07-22T08:40:22.809265Z","shell.execute_reply.started":"2022-07-22T08:40:22.799359Z","shell.execute_reply":"2022-07-22T08:40:22.808181Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:22.810499Z","iopub.execute_input":"2022-07-22T08:40:22.811294Z","iopub.status.idle":"2022-07-22T08:40:22.830973Z","shell.execute_reply.started":"2022-07-22T08:40:22.811251Z","shell.execute_reply":"2022-07-22T08:40:22.829907Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import seaborn as sns\n\nsns.set()\n\n# subplots(行, 列, figsize=(幅, 高さ))\nfig, axes = plt.subplots(3, 3, figsize=(18, 15))\n\nsns.countplot(x=train[\"HomePlanet\"],hue=train[\"Transported\"],ax=axes[0,0])\nsns.countplot(x=train[\"CryoSleep\"],hue=train[\"Transported\"],ax=axes[0,1])\nsns.countplot(x=train[\"Destination\"],hue=train[\"Transported\"],ax=axes[0,2])\nsns.countplot(x=train[\"VIP\"],hue=train[\"Transported\"],ax=axes[1,0])\nsns.countplot(x=train[\"deck\"],hue=train[\"Transported\"],ax=axes[1,1])\nsns.countplot(x=train[\"num\"],hue=train[\"Transported\"],ax=axes[1,2])\nsns.countplot(x=train[\"side\"],hue=train[\"Transported\"],ax=axes[2,0])","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:22.834107Z","iopub.execute_input":"2022-07-22T08:40:22.835025Z","iopub.status.idle":"2022-07-22T08:40:24.629541Z","shell.execute_reply.started":"2022-07-22T08:40:22.834973Z","shell.execute_reply":"2022-07-22T08:40:24.628371Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:24.631265Z","iopub.execute_input":"2022-07-22T08:40:24.631589Z","iopub.status.idle":"2022-07-22T08:40:24.655937Z","shell.execute_reply.started":"2022-07-22T08:40:24.631557Z","shell.execute_reply":"2022-07-22T08:40:24.654589Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train=train.drop([\"VIP\"],axis=1)\ntrain=train.drop([\"num\"],axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:24.657428Z","iopub.execute_input":"2022-07-22T08:40:24.658291Z","iopub.status.idle":"2022-07-22T08:40:24.667786Z","shell.execute_reply.started":"2022-07-22T08:40:24.658256Z","shell.execute_reply":"2022-07-22T08:40:24.666905Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train = pd.get_dummies(train, columns=['HomePlanet', 'CryoSleep', 'Destination','deck','side'], drop_first=True)\ntrain","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:24.669319Z","iopub.execute_input":"2022-07-22T08:40:24.670557Z","iopub.status.idle":"2022-07-22T08:40:24.713745Z","shell.execute_reply.started":"2022-07-22T08:40:24.670496Z","shell.execute_reply":"2022-07-22T08:40:24.712863Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.preprocessing import StandardScaler\ntrain_standard = StandardScaler()\ntrain_copied = train.copy()\ntrain_standard.fit(train_copied[['Age','RoomService','FoodCourt','ShoppingMall','Spa','VRDeck']])\ntrain_std = pd.DataFrame(train_standard.transform(train_copied[['Age','RoomService','FoodCourt','ShoppingMall','Spa','VRDeck']]))\ntrain_std","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:24.715124Z","iopub.execute_input":"2022-07-22T08:40:24.716027Z","iopub.status.idle":"2022-07-22T08:40:24.742724Z","shell.execute_reply.started":"2022-07-22T08:40:24.715984Z","shell.execute_reply":"2022-07-22T08:40:24.741487Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train[['Age','RoomService','FoodCourt','ShoppingMall','Spa','VRDeck'] ] = train_std\ntrain","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:24.744365Z","iopub.execute_input":"2022-07-22T08:40:24.744747Z","iopub.status.idle":"2022-07-22T08:40:24.775826Z","shell.execute_reply.started":"2022-07-22T08:40:24.744713Z","shell.execute_reply":"2022-07-22T08:40:24.774851Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"ロジスティクス回帰","metadata":{}},{"cell_type":"code","source":"from sklearn.linear_model import LogisticRegression\n\n#cols = ['Age','RoomService','FoodCourt','ShoppingMall','Spa','VRDeck','deck_B','deck_F','deck_E','deck_C','CryoSleep_True'] \ncols = ['RoomService','Spa','VRDeck','HomePlanet_Europa','CryoSleep_True','deck_B','deck_C','deck_E']\nX =train[cols]\ny = train['Transported']\n# Build a logreg and compute the feature importances\nmodel = LogisticRegression()\n# create the RFE model and select 8 attributes\nmodel.fit(X,y)","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:24.777578Z","iopub.execute_input":"2022-07-22T08:40:24.778259Z","iopub.status.idle":"2022-07-22T08:40:24.830816Z","shell.execute_reply.started":"2022-07-22T08:40:24.778222Z","shell.execute_reply":"2022-07-22T08:40:24.829353Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"学習させたモデルの精度","metadata":{}},{"cell_type":"code","source":"from sklearn.metrics import accuracy_score\ntrain_predicted = model.predict(X)\naccuracy_score(train_predicted, y)","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:24.832575Z","iopub.execute_input":"2022-07-22T08:40:24.833239Z","iopub.status.idle":"2022-07-22T08:40:24.850655Z","shell.execute_reply.started":"2022-07-22T08:40:24.833191Z","shell.execute_reply":"2022-07-22T08:40:24.848978Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### テストデータの読み込み","metadata":{}},{"cell_type":"code","source":"test = pd.read_csv('../input/spaceship-titanic/test.csv')\ntest.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:24.852727Z","iopub.execute_input":"2022-07-22T08:40:24.853478Z","iopub.status.idle":"2022-07-22T08:40:24.916258Z","shell.execute_reply.started":"2022-07-22T08:40:24.853429Z","shell.execute_reply":"2022-07-22T08:40:24.914748Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:24.918083Z","iopub.execute_input":"2022-07-22T08:40:24.918681Z","iopub.status.idle":"2022-07-22T08:40:24.941327Z","shell.execute_reply.started":"2022-07-22T08:40:24.918632Z","shell.execute_reply":"2022-07-22T08:40:24.939434Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test=test.drop([\"Name\"],axis=1)\n\ntest[\"deck\"]=test[\"Cabin\"].str.split(\"/\",expand=True)[0]\ntest[\"num\"]=test[\"Cabin\"].str.split(\"/\",expand=True)[1]\ntest[\"side\"]=test[\"Cabin\"].str.split(\"/\",expand=True)[2]\ntest=test.drop([\"Cabin\"],axis=1)\n\ntest[\"HomePlanet\"].fillna(\"Earth\",inplace=True)\ntest[\"CryoSleep\"].fillna(\"False\",inplace=True)\ntest[\"CryoSleep\"]=test[\"CryoSleep\"].astype(bool)\ntest[\"Destination\"].fillna(\"TRAPPIST-1e\",inplace=True)\ntest[\"VIP\"].fillna(\"False\",inplace=True)\ntest[\"VIP\"]=test[\"VIP\"].astype(bool)\ntest[\"RoomService\"].fillna(test[\"RoomService\"].median(),inplace=True)\ntest[\"FoodCourt\"].fillna(test[\"FoodCourt\"].median(),inplace=True)\ntest[\"ShoppingMall\"].fillna(test[\"ShoppingMall\"].median(),inplace=True)\ntest[\"Spa\"].fillna(test[\"Spa\"].median(),inplace=True)\ntest[\"VRDeck\"].fillna(test[\"VRDeck\"].median(),inplace=True)\ntest[\"deck\"].fillna(\"F\",inplace=True)\ntest[\"side\"].fillna(\"S\",inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:24.948424Z","iopub.execute_input":"2022-07-22T08:40:24.952188Z","iopub.status.idle":"2022-07-22T08:40:25.010045Z","shell.execute_reply.started":"2022-07-22T08:40:24.952123Z","shell.execute_reply":"2022-07-22T08:40:25.008604Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"testing=pd.get_dummies(test, columns=['HomePlanet', 'CryoSleep', 'Destination','deck','side'], drop_first=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:25.011794Z","iopub.execute_input":"2022-07-22T08:40:25.012273Z","iopub.status.idle":"2022-07-22T08:40:25.030477Z","shell.execute_reply.started":"2022-07-22T08:40:25.012226Z","shell.execute_reply":"2022-07-22T08:40:25.029293Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_standard\ntest_copied = testing.copy()\ntest_std = train_standard.transform(test_copied[['Age','RoomService','FoodCourt','ShoppingMall','Spa','VRDeck']])\ntest_std\ntesting[['Age','RoomService','FoodCourt','ShoppingMall','Spa','VRDeck']] = test_std\ntesting","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:25.031760Z","iopub.execute_input":"2022-07-22T08:40:25.032092Z","iopub.status.idle":"2022-07-22T08:40:25.073747Z","shell.execute_reply.started":"2022-07-22T08:40:25.032061Z","shell.execute_reply":"2022-07-22T08:40:25.072272Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_test=testing[cols]\nX_test.dtypes\ntest_predicted = model.predict(X_test)","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:25.075660Z","iopub.execute_input":"2022-07-22T08:40:25.077038Z","iopub.status.idle":"2022-07-22T08:40:25.090963Z","shell.execute_reply.started":"2022-07-22T08:40:25.076982Z","shell.execute_reply":"2022-07-22T08:40:25.089189Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_predicted","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:25.100608Z","iopub.execute_input":"2022-07-22T08:40:25.101812Z","iopub.status.idle":"2022-07-22T08:40:25.111695Z","shell.execute_reply.started":"2022-07-22T08:40:25.101752Z","shell.execute_reply":"2022-07-22T08:40:25.109167Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub = pd.read_csv('../input/spaceship-titanic/sample_submission.csv')\nsub['Transported'] = list(map(int, test_predicted))\nsub['Transported'] = sub['Transported'].astype(bool)\nsub","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:25.114192Z","iopub.execute_input":"2022-07-22T08:40:25.115201Z","iopub.status.idle":"2022-07-22T08:40:25.165447Z","shell.execute_reply.started":"2022-07-22T08:40:25.115139Z","shell.execute_reply":"2022-07-22T08:40:25.163945Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub.to_csv('submission.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2022-07-22T08:40:25.172462Z","iopub.execute_input":"2022-07-22T08:40:25.176208Z","iopub.status.idle":"2022-07-22T08:40:25.203164Z","shell.execute_reply.started":"2022-07-22T08:40:25.176144Z","shell.execute_reply":"2022-07-22T08:40:25.201560Z"},"trusted":true},"execution_count":null,"outputs":[]}]}