{"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-29T04:07:19.427357Z","iopub.execute_input":"2022-07-29T04:07:19.428029Z","iopub.status.idle":"2022-07-29T04:07:19.445286Z","shell.execute_reply.started":"2022-07-29T04:07:19.427993Z","shell.execute_reply":"2022-07-29T04:07:19.444281Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train = pd.read_csv('/kaggle/input/spaceship-titanic/train.csv')","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:19.447029Z","iopub.execute_input":"2022-07-29T04:07:19.447404Z","iopub.status.idle":"2022-07-29T04:07:19.491700Z","shell.execute_reply.started":"2022-07-29T04:07:19.447370Z","shell.execute_reply":"2022-07-29T04:07:19.490464Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:19.494092Z","iopub.execute_input":"2022-07-29T04:07:19.494904Z","iopub.status.idle":"2022-07-29T04:07:19.521524Z","shell.execute_reply.started":"2022-07-29T04:07:19.494855Z","shell.execute_reply":"2022-07-29T04:07:19.520365Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test = pd.read_csv('/kaggle/input/spaceship-titanic/test.csv')","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:19.523137Z","iopub.execute_input":"2022-07-29T04:07:19.523748Z","iopub.status.idle":"2022-07-29T04:07:19.551265Z","shell.execute_reply.started":"2022-07-29T04:07:19.523712Z","shell.execute_reply":"2022-07-29T04:07:19.549534Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:19.555618Z","iopub.execute_input":"2022-07-29T04:07:19.556313Z","iopub.status.idle":"2022-07-29T04:07:19.578329Z","shell.execute_reply.started":"2022-07-29T04:07:19.556275Z","shell.execute_reply":"2022-07-29T04:07:19.577283Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(train.shape)\nprint(test.shape)","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:19.580176Z","iopub.execute_input":"2022-07-29T04:07:19.580775Z","iopub.status.idle":"2022-07-29T04:07:19.588522Z","shell.execute_reply.started":"2022-07-29T04:07:19.580722Z","shell.execute_reply":"2022-07-29T04:07:19.587179Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train['Transported'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:19.590332Z","iopub.execute_input":"2022-07-29T04:07:19.591054Z","iopub.status.idle":"2022-07-29T04:07:19.603047Z","shell.execute_reply.started":"2022-07-29T04:07:19.591003Z","shell.execute_reply":"2022-07-29T04:07:19.602172Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.describe()","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:19.604357Z","iopub.execute_input":"2022-07-29T04:07:19.604844Z","iopub.status.idle":"2022-07-29T04:07:19.647298Z","shell.execute_reply.started":"2022-07-29T04:07:19.604814Z","shell.execute_reply":"2022-07-29T04:07:19.645925Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.get_dummies(train).corrwith(train[\"Transported\"])","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:19.648843Z","iopub.execute_input":"2022-07-29T04:07:19.649219Z","iopub.status.idle":"2022-07-29T04:07:30.259245Z","shell.execute_reply.started":"2022-07-29T04:07:19.649187Z","shell.execute_reply":"2022-07-29T04:07:30.258019Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.drop(['Name'],axis=1,inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:30.263935Z","iopub.execute_input":"2022-07-29T04:07:30.264517Z","iopub.status.idle":"2022-07-29T04:07:30.271690Z","shell.execute_reply.started":"2022-07-29T04:07:30.264482Z","shell.execute_reply":"2022-07-29T04:07:30.270514Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.get_dummies(train).corrwith(train[\"Transported\"])","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:30.273278Z","iopub.execute_input":"2022-07-29T04:07:30.273849Z","iopub.status.idle":"2022-07-29T04:07:37.163097Z","shell.execute_reply.started":"2022-07-29T04:07:30.273811Z","shell.execute_reply":"2022-07-29T04:07:37.161719Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train[['Destination', 'Transported']].groupby(['Destination']).mean()","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:37.166017Z","iopub.execute_input":"2022-07-29T04:07:37.166481Z","iopub.status.idle":"2022-07-29T04:07:37.184188Z","shell.execute_reply.started":"2022-07-29T04:07:37.166436Z","shell.execute_reply":"2022-07-29T04:07:37.183188Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.drop(['Destination'],axis=1,inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:37.186260Z","iopub.execute_input":"2022-07-29T04:07:37.186722Z","iopub.status.idle":"2022-07-29T04:07:37.194275Z","shell.execute_reply.started":"2022-07-29T04:07:37.186681Z","shell.execute_reply":"2022-07-29T04:07:37.193249Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.get_dummies(train).corrwith(train[\"Transported\"])","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:37.196697Z","iopub.execute_input":"2022-07-29T04:07:37.197967Z","iopub.status.idle":"2022-07-29T04:07:43.930661Z","shell.execute_reply.started":"2022-07-29T04:07:37.197911Z","shell.execute_reply":"2022-07-29T04:07:43.929297Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.drop(['PassengerId','HomePlanet'],axis=1,inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:43.932171Z","iopub.execute_input":"2022-07-29T04:07:43.932531Z","iopub.status.idle":"2022-07-29T04:07:43.940414Z","shell.execute_reply.started":"2022-07-29T04:07:43.932500Z","shell.execute_reply":"2022-07-29T04:07:43.939005Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_corr = train.corr()\ntrain_corr","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:43.942170Z","iopub.execute_input":"2022-07-29T04:07:43.942668Z","iopub.status.idle":"2022-07-29T04:07:43.966708Z","shell.execute_reply.started":"2022-07-29T04:07:43.942618Z","shell.execute_reply":"2022-07-29T04:07:43.965413Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nimport seaborn as sns\n\nsns.set_context(\"talk\")\nfig = plt.subplots(figsize=(8, 8))\n \nsns.heatmap(train_corr, annot=True,fmt='.2f',cmap='Blues',square=True)\n","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:43.968499Z","iopub.execute_input":"2022-07-29T04:07:43.968968Z","iopub.status.idle":"2022-07-29T04:07:44.475362Z","shell.execute_reply.started":"2022-07-29T04:07:43.968907Z","shell.execute_reply":"2022-07-29T04:07:44.474032Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.get_dummies(train).corrwith(train[\"Transported\"])","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:44.477187Z","iopub.execute_input":"2022-07-29T04:07:44.477678Z","iopub.status.idle":"2022-07-29T04:07:47.443761Z","shell.execute_reply.started":"2022-07-29T04:07:44.477640Z","shell.execute_reply":"2022-07-29T04:07:47.441806Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train[['CryoSleep', 'Transported']].groupby(['CryoSleep']).mean()","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:47.445597Z","iopub.execute_input":"2022-07-29T04:07:47.447142Z","iopub.status.idle":"2022-07-29T04:07:47.468244Z","shell.execute_reply.started":"2022-07-29T04:07:47.447085Z","shell.execute_reply":"2022-07-29T04:07:47.467328Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:47.469553Z","iopub.execute_input":"2022-07-29T04:07:47.470310Z","iopub.status.idle":"2022-07-29T04:07:47.486208Z","shell.execute_reply.started":"2022-07-29T04:07:47.470277Z","shell.execute_reply":"2022-07-29T04:07:47.484162Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"##外れ値はすべて中央値にする\ntrain['RoomService'].fillna(train['RoomService'].median(skipna=True), inplace=True)\ntrain['FoodCourt'].fillna(train['FoodCourt'].median(skipna=True), inplace=True)\ntrain['ShoppingMall'].fillna(train['ShoppingMall'].median(skipna=True), inplace=True)\ntrain['Spa'].fillna(train['Spa'].median(skipna=True), inplace=True)\ntrain['VRDeck'].fillna(train['VRDeck'].median(skipna=True), inplace=True)\ntrain['Age'].fillna(train['Age'].median(skipna=True), inplace=True)\ntrain.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:47.488100Z","iopub.execute_input":"2022-07-29T04:07:47.488978Z","iopub.status.idle":"2022-07-29T04:07:47.514653Z","shell.execute_reply.started":"2022-07-29T04:07:47.488914Z","shell.execute_reply":"2022-07-29T04:07:47.513495Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.dropna(how='any')","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:47.516783Z","iopub.execute_input":"2022-07-29T04:07:47.517237Z","iopub.status.idle":"2022-07-29T04:07:47.551129Z","shell.execute_reply.started":"2022-07-29T04:07:47.517197Z","shell.execute_reply":"2022-07-29T04:07:47.550179Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:47.552697Z","iopub.execute_input":"2022-07-29T04:07:47.553016Z","iopub.status.idle":"2022-07-29T04:07:47.566513Z","shell.execute_reply.started":"2022-07-29T04:07:47.552988Z","shell.execute_reply":"2022-07-29T04:07:47.565040Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.corr()","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:47.572759Z","iopub.execute_input":"2022-07-29T04:07:47.573174Z","iopub.status.idle":"2022-07-29T04:07:47.593230Z","shell.execute_reply.started":"2022-07-29T04:07:47.573140Z","shell.execute_reply":"2022-07-29T04:07:47.592032Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train[['VIP', 'Transported']].groupby(['VIP']).mean()","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:47.595146Z","iopub.execute_input":"2022-07-29T04:07:47.596359Z","iopub.status.idle":"2022-07-29T04:07:47.612878Z","shell.execute_reply.started":"2022-07-29T04:07:47.596310Z","shell.execute_reply":"2022-07-29T04:07:47.611582Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train[['Age', 'Spa']].groupby(['Spa']).mean()","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:47.614226Z","iopub.execute_input":"2022-07-29T04:07:47.614658Z","iopub.status.idle":"2022-07-29T04:07:47.634602Z","shell.execute_reply.started":"2022-07-29T04:07:47.614629Z","shell.execute_reply":"2022-07-29T04:07:47.633428Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.drop(['Age','ShoppingMall'],axis=1,inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:47.636635Z","iopub.execute_input":"2022-07-29T04:07:47.637426Z","iopub.status.idle":"2022-07-29T04:07:47.645428Z","shell.execute_reply.started":"2022-07-29T04:07:47.637381Z","shell.execute_reply":"2022-07-29T04:07:47.644402Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.describe","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:47.646758Z","iopub.execute_input":"2022-07-29T04:07:47.647301Z","iopub.status.idle":"2022-07-29T04:07:47.665368Z","shell.execute_reply.started":"2022-07-29T04:07:47.647270Z","shell.execute_reply":"2022-07-29T04:07:47.664243Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.tree import DecisionTreeClassifier, export_graphviz","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:47.668467Z","iopub.execute_input":"2022-07-29T04:07:47.668800Z","iopub.status.idle":"2022-07-29T04:07:47.673558Z","shell.execute_reply.started":"2022-07-29T04:07:47.668772Z","shell.execute_reply":"2022-07-29T04:07:47.672557Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn import tree","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:47.674861Z","iopub.execute_input":"2022-07-29T04:07:47.675426Z","iopub.status.idle":"2022-07-29T04:07:47.684139Z","shell.execute_reply.started":"2022-07-29T04:07:47.675391Z","shell.execute_reply":"2022-07-29T04:07:47.683180Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"category = ['CryoSleep']\ntraining = pd.get_dummies(train, columns=category,drop_first=True)\ntraining","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:47.686883Z","iopub.execute_input":"2022-07-29T04:07:47.688095Z","iopub.status.idle":"2022-07-29T04:07:47.719679Z","shell.execute_reply.started":"2022-07-29T04:07:47.688053Z","shell.execute_reply":"2022-07-29T04:07:47.718354Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y = train.loc[:,['Transported']]\nX = training.loc[:,['CryoSleep_True','RoomService','VRDeck','Spa']]","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:47.721094Z","iopub.execute_input":"2022-07-29T04:07:47.722231Z","iopub.status.idle":"2022-07-29T04:07:47.729100Z","shell.execute_reply.started":"2022-07-29T04:07:47.722195Z","shell.execute_reply":"2022-07-29T04:07:47.727824Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"clf = tree.DecisionTreeClassifier(max_depth=10)","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:47.730384Z","iopub.execute_input":"2022-07-29T04:07:47.731023Z","iopub.status.idle":"2022-07-29T04:07:47.740881Z","shell.execute_reply.started":"2022-07-29T04:07:47.730934Z","shell.execute_reply":"2022-07-29T04:07:47.740015Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"clf = clf.fit(X, y)","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:47.742240Z","iopub.execute_input":"2022-07-29T04:07:47.743667Z","iopub.status.idle":"2022-07-29T04:07:47.766824Z","shell.execute_reply.started":"2022-07-29T04:07:47.743614Z","shell.execute_reply":"2022-07-29T04:07:47.764740Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import accuracy_score\ntrain_predicted = clf.predict(X)\naccuracy_score(train_predicted, y)","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:47.768445Z","iopub.execute_input":"2022-07-29T04:07:47.769544Z","iopub.status.idle":"2022-07-29T04:07:47.783080Z","shell.execute_reply.started":"2022-07-29T04:07:47.769490Z","shell.execute_reply":"2022-07-29T04:07:47.781753Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.datasets import make_moons\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.tree import DecisionTreeClassifier\nfrom sklearn.tree import export_graphviz\nfrom matplotlib.colors import ListedColormap\nimport graphviz\n\ndot_data = export_graphviz(clf)\ngraph = graphviz.Source(dot_data)\ngraph.render('moon-tree')","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:47.784601Z","iopub.execute_input":"2022-07-29T04:07:47.785911Z","iopub.status.idle":"2022-07-29T04:07:47.992268Z","shell.execute_reply.started":"2022-07-29T04:07:47.785852Z","shell.execute_reply":"2022-07-29T04:07:47.990640Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test = pd.read_csv('/kaggle/input/spaceship-titanic/test.csv')\ntest.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:47.994692Z","iopub.execute_input":"2022-07-29T04:07:47.995102Z","iopub.status.idle":"2022-07-29T04:07:48.031837Z","shell.execute_reply.started":"2022-07-29T04:07:47.995065Z","shell.execute_reply":"2022-07-29T04:07:48.030888Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test.drop(['PassengerId','HomePlanet','Cabin','Destination','Age','VIP','ShoppingMall','Name'],axis=1,inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:48.033398Z","iopub.execute_input":"2022-07-29T04:07:48.033722Z","iopub.status.idle":"2022-07-29T04:07:48.042631Z","shell.execute_reply.started":"2022-07-29T04:07:48.033694Z","shell.execute_reply":"2022-07-29T04:07:48.041430Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:48.046272Z","iopub.execute_input":"2022-07-29T04:07:48.046669Z","iopub.status.idle":"2022-07-29T04:07:48.067976Z","shell.execute_reply.started":"2022-07-29T04:07:48.046632Z","shell.execute_reply":"2022-07-29T04:07:48.066984Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test['RoomService'].fillna(train['RoomService'].median(skipna=True), inplace=True)\n#test['FoodCourt'].fillna(train['FoodCourt'].median(skipna=True), inplace=True)\ntest['VRDeck'].fillna(train['VRDeck'].median(skipna=True), inplace=True)\ntest['Spa'].fillna(train['Spa'].median(skipna=True), inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:48.069438Z","iopub.execute_input":"2022-07-29T04:07:48.070102Z","iopub.status.idle":"2022-07-29T04:07:48.081524Z","shell.execute_reply.started":"2022-07-29T04:07:48.070058Z","shell.execute_reply":"2022-07-29T04:07:48.080414Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:48.083091Z","iopub.execute_input":"2022-07-29T04:07:48.085267Z","iopub.status.idle":"2022-07-29T04:07:48.097793Z","shell.execute_reply.started":"2022-07-29T04:07:48.085215Z","shell.execute_reply":"2022-07-29T04:07:48.096718Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test.dropna(how='any')","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:48.099410Z","iopub.execute_input":"2022-07-29T04:07:48.100237Z","iopub.status.idle":"2022-07-29T04:07:48.125158Z","shell.execute_reply.started":"2022-07-29T04:07:48.100189Z","shell.execute_reply":"2022-07-29T04:07:48.124008Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"category = ['CryoSleep']\ntesting = pd.get_dummies(test, columns=category,drop_first=True)\ntesting","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:48.126714Z","iopub.execute_input":"2022-07-29T04:07:48.127537Z","iopub.status.idle":"2022-07-29T04:07:48.154114Z","shell.execute_reply.started":"2022-07-29T04:07:48.127491Z","shell.execute_reply":"2022-07-29T04:07:48.152938Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cols = ['CryoSleep_True','RoomService','VRDeck','Spa'] \nX_test=testing[cols]\nprint(X_test.dtypes)\ntest_predicted = clf.predict(X_test)","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:48.155749Z","iopub.execute_input":"2022-07-29T04:07:48.156690Z","iopub.status.idle":"2022-07-29T04:07:48.170101Z","shell.execute_reply.started":"2022-07-29T04:07:48.156651Z","shell.execute_reply":"2022-07-29T04:07:48.168633Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub = pd.read_csv('/kaggle/input/spaceship-titanic/sample_submission.csv')\nsub","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:48.171403Z","iopub.execute_input":"2022-07-29T04:07:48.171909Z","iopub.status.idle":"2022-07-29T04:07:48.194139Z","shell.execute_reply.started":"2022-07-29T04:07:48.171876Z","shell.execute_reply":"2022-07-29T04:07:48.193116Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub['Transported'] = list(map(bool, test_predicted))\nsub.to_csv('submission.csv', index=False)\nsub","metadata":{"execution":{"iopub.status.busy":"2022-07-29T04:07:48.195607Z","iopub.execute_input":"2022-07-29T04:07:48.196606Z","iopub.status.idle":"2022-07-29T04:07:48.222753Z","shell.execute_reply.started":"2022-07-29T04:07:48.196569Z","shell.execute_reply":"2022-07-29T04:07:48.221558Z"},"trusted":true},"execution_count":null,"outputs":[]}]}