{"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","trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Import Libraries","metadata":{}},{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport seaborn as sns","metadata":{"execution":{"iopub.status.busy":"2022-07-22T02:59:09.465755Z","iopub.execute_input":"2022-07-22T02:59:09.466209Z","iopub.status.idle":"2022-07-22T02:59:10.629550Z","shell.execute_reply.started":"2022-07-22T02:59:09.466117Z","shell.execute_reply":"2022-07-22T02:59:10.628368Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Read Data","metadata":{}},{"cell_type":"code","source":"train = pd.read_csv(\"../input/spaceship-titanic/train.csv\")\ntest = pd.read_csv(\"../input/spaceship-titanic/test.csv\")\nsubmission = pd.read_csv(\"../input/spaceship-titanic/sample_submission.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:04:04.311846Z","iopub.execute_input":"2022-07-22T03:04:04.313196Z","iopub.status.idle":"2022-07-22T03:04:04.400824Z","shell.execute_reply.started":"2022-07-22T03:04:04.313115Z","shell.execute_reply":"2022-07-22T03:04:04.399723Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# EDA","metadata":{}},{"cell_type":"code","source":"train.info()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:06:27.973190Z","iopub.execute_input":"2022-07-22T03:06:27.973662Z","iopub.status.idle":"2022-07-22T03:06:28.012174Z","shell.execute_reply.started":"2022-07-22T03:06:27.973630Z","shell.execute_reply":"2022-07-22T03:06:28.010852Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test.info()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:06:40.484415Z","iopub.execute_input":"2022-07-22T03:06:40.484833Z","iopub.status.idle":"2022-07-22T03:06:40.501559Z","shell.execute_reply.started":"2022-07-22T03:06:40.484804Z","shell.execute_reply":"2022-07-22T03:06:40.499158Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.describe()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:06:48.260460Z","iopub.execute_input":"2022-07-22T03:06:48.260877Z","iopub.status.idle":"2022-07-22T03:06:48.310587Z","shell.execute_reply.started":"2022-07-22T03:06:48.260846Z","shell.execute_reply":"2022-07-22T03:06:48.309352Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:07:03.162488Z","iopub.execute_input":"2022-07-22T03:07:03.162878Z","iopub.status.idle":"2022-07-22T03:07:03.185893Z","shell.execute_reply.started":"2022-07-22T03:07:03.162847Z","shell.execute_reply":"2022-07-22T03:07:03.184618Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**결측치 확인**","metadata":{}},{"cell_type":"code","source":"train.isna().sum()\ntest.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:09:08.409850Z","iopub.execute_input":"2022-07-22T03:09:08.410289Z","iopub.status.idle":"2022-07-22T03:09:08.428659Z","shell.execute_reply.started":"2022-07-22T03:09:08.410256Z","shell.execute_reply":"2022-07-22T03:09:08.427358Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**상관관계 히트맵**","metadata":{}},{"cell_type":"code","source":"corr = train.drop(columns=[\"PassengerId\"]).corr()\nplt.figure(figsize=(15, 10))\nsns.heatmap(corr, annot=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:14:37.404751Z","iopub.execute_input":"2022-07-22T03:14:37.405126Z","iopub.status.idle":"2022-07-22T03:14:38.123535Z","shell.execute_reply.started":"2022-07-22T03:14:37.405096Z","shell.execute_reply":"2022-07-22T03:14:38.122235Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Figure size\nplt.figure(figsize=(20,4))\n\n# Histogram\nsns.histplot(data=train, x='Age', hue='Transported', binwidth=1.5, kde=True)\n\n# Aesthetics\nplt.title('Age distribution')\nplt.xlabel('Age (years)')","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:22:24.287370Z","iopub.execute_input":"2022-07-22T03:22:24.287776Z","iopub.status.idle":"2022-07-22T03:22:24.749054Z","shell.execute_reply.started":"2022-07-22T03:22:24.287743Z","shell.execute_reply":"2022-07-22T03:22:24.747579Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.info()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:16:43.118181Z","iopub.execute_input":"2022-07-22T03:16:43.118615Z","iopub.status.idle":"2022-07-22T03:16:43.136110Z","shell.execute_reply.started":"2022-07-22T03:16:43.118578Z","shell.execute_reply":"2022-07-22T03:16:43.135315Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"\n**Categorical features**","metadata":{}},{"cell_type":"code","source":"cat_features=['HomePlanet', 'CryoSleep', 'Destination', 'VIP']\n\n# Plot categorical features\nfig=plt.figure(figsize=(8,13))\nfor i, var_name in enumerate(cat_features):\n    ax=fig.add_subplot(4,1,i+1)\n    sns.countplot(data=train, x=var_name, axes=ax, hue='Transported')\n    ax.set_title(var_name)\nfig.tight_layout()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:22:38.485360Z","iopub.execute_input":"2022-07-22T03:22:38.485801Z","iopub.status.idle":"2022-07-22T03:22:39.067289Z","shell.execute_reply.started":"2022-07-22T03:22:38.485765Z","shell.execute_reply":"2022-07-22T03:22:39.066097Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Delete Unnecessary Columns**","metadata":{}},{"cell_type":"code","source":"train = train.drop(columns=[\"Name\", \"PassengerId\", \"VIP\", \"Cabin\"])\ntest = test.drop(columns=[\"Name\",\"PassengerId\", \"VIP\",\"Cabin\"])","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:24:44.200979Z","iopub.execute_input":"2022-07-22T03:24:44.201513Z","iopub.status.idle":"2022-07-22T03:24:44.210967Z","shell.execute_reply.started":"2022-07-22T03:24:44.201466Z","shell.execute_reply":"2022-07-22T03:24:44.209761Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train = train.drop(columns=[\"Destination\"])\ntest = test.drop(columns=[\"Destination\"])","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:26:18.931976Z","iopub.execute_input":"2022-07-22T03:26:18.932420Z","iopub.status.idle":"2022-07-22T03:26:18.941089Z","shell.execute_reply.started":"2022-07-22T03:26:18.932383Z","shell.execute_reply":"2022-07-22T03:26:18.940174Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**결측치 확인**","metadata":{}},{"cell_type":"code","source":"print(train.columns[train.isna().any()])  ","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:26:49.237791Z","iopub.execute_input":"2022-07-22T03:26:49.238731Z","iopub.status.idle":"2022-07-22T03:26:49.247343Z","shell.execute_reply.started":"2022-07-22T03:26:49.238685Z","shell.execute_reply":"2022-07-22T03:26:49.245921Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**결측치 채우기(최빈값으로 대체)**","metadata":{}},{"cell_type":"code","source":"for col in train.columns:\n    if train[col].dtype == 'object':\n        train[col] = train[col].fillna(train[col].mode()[0])   \n        test[col] = test[col].fillna(train[col].mode()[0])     \n    elif train[col].dtype == 'float64':\n        train[col] = train[col].fillna(train[col].mode()[0])  \n        test[col] = test[col].fillna(train[col].mode()[0])     ","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:28:17.327611Z","iopub.execute_input":"2022-07-22T03:28:17.328877Z","iopub.status.idle":"2022-07-22T03:28:17.355066Z","shell.execute_reply.started":"2022-07-22T03:28:17.328822Z","shell.execute_reply":"2022-07-22T03:28:17.354256Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(train.columns[train.isna().any()])","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:28:37.495317Z","iopub.execute_input":"2022-07-22T03:28:37.495756Z","iopub.status.idle":"2022-07-22T03:28:37.504864Z","shell.execute_reply.started":"2022-07-22T03:28:37.495720Z","shell.execute_reply":"2022-07-22T03:28:37.503525Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.info()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:28:55.883608Z","iopub.execute_input":"2022-07-22T03:28:55.884024Z","iopub.status.idle":"2022-07-22T03:28:55.900516Z","shell.execute_reply.started":"2022-07-22T03:28:55.883991Z","shell.execute_reply":"2022-07-22T03:28:55.899410Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cat_features = ['HomePlanet']\ntrain = pd.get_dummies(data=train, columns=cat_features)\ntrain","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:31:32.677303Z","iopub.execute_input":"2022-07-22T03:31:32.677748Z","iopub.status.idle":"2022-07-22T03:31:32.709763Z","shell.execute_reply.started":"2022-07-22T03:31:32.677711Z","shell.execute_reply":"2022-07-22T03:31:32.708380Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Feature Engineering","metadata":{}},{"cell_type":"code","source":"# New features - training set\ntrain['Age_group']=np.nan\ntrain.loc[train['Age']<=12,'Age_group']='Age_0-12'\ntrain.loc[(train['Age']>12) & (train['Age']<18),'Age_group']='Age_13-17'\ntrain.loc[(train['Age']>=18) & (train['Age']<=25),'Age_group']='Age_18-25'\ntrain.loc[(train['Age']>25) & (train['Age']<=30),'Age_group']='Age_26-30'\ntrain.loc[(train['Age']>30) & (train['Age']<=50),'Age_group']='Age_31-50'\ntrain.loc[train['Age']>50,'Age_group']='Age_51+'\n\n# New features - test set\ntest['Age_group']=np.nan\ntest.loc[test['Age']<=12,'Age_group']='Age_0-12'\ntest.loc[(test['Age']>12) & (test['Age']<18),'Age_group']='Age_13-17'\ntest.loc[(test['Age']>=18) & (test['Age']<=50),'Age_group']='Age_18-50'\ntest.loc[test['Age']>50,'Age_group']='Age_51+'\n\n# Plot distribution of new features\nplt.figure(figsize=(10,4))\ng=sns.countplot(data=train, x='Age_group', hue='Transported', order=['Age_0-12','Age_13-17','Age_18-25','Age_26-30','Age_31-50','Age_51+'])\nplt.title('Age group distribution')","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:40:54.772866Z","iopub.execute_input":"2022-07-22T03:40:54.773326Z","iopub.status.idle":"2022-07-22T03:40:55.056676Z","shell.execute_reply.started":"2022-07-22T03:40:54.773290Z","shell.execute_reply":"2022-07-22T03:40:55.055267Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"exp_feats=['RoomService', 'FoodCourt', 'ShoppingMall', 'Spa', 'VRDeck']\n\n# New features - training set\ntrain['Expenditure']=train[exp_feats].sum(axis=1)\ntrain['No_spending']=(train['Expenditure']==0).astype(int)\n\n# New features - test set\ntest['Expenditure']=test[exp_feats].sum(axis=1)\ntest['No_spending']=(test['Expenditure']==0).astype(int)\n\n# Plot distribution of new features\nfig=plt.figure(figsize=(12,4))\nplt.subplot(1,2,1)\nsns.histplot(data=train, x='Expenditure', hue='Transported', bins=200)\nplt.title('Total expenditure')\nplt.ylim([0,200])\nplt.xlim([0,20000])\n\nplt.subplot(1,2,2)\nsns.countplot(data=train, x='No_spending', hue='Transported')\nplt.title('No spending')\nfig.tight_layout()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:37:26.612713Z","iopub.execute_input":"2022-07-22T03:37:26.613116Z","iopub.status.idle":"2022-07-22T03:37:28.158658Z","shell.execute_reply.started":"2022-07-22T03:37:26.613082Z","shell.execute_reply":"2022-07-22T03:37:28.157767Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test = pd.get_dummies(data=test, columns=cat_features)\ntrain.shape , test.shape","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:38:12.460227Z","iopub.execute_input":"2022-07-22T03:38:12.460877Z","iopub.status.idle":"2022-07-22T03:38:12.476483Z","shell.execute_reply.started":"2022-07-22T03:38:12.460818Z","shell.execute_reply":"2022-07-22T03:38:12.475542Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:38:25.485578Z","iopub.execute_input":"2022-07-22T03:38:25.486045Z","iopub.status.idle":"2022-07-22T03:38:25.512865Z","shell.execute_reply.started":"2022-07-22T03:38:25.486006Z","shell.execute_reply":"2022-07-22T03:38:25.511805Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test.info()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:41:33.655908Z","iopub.execute_input":"2022-07-22T03:41:33.656347Z","iopub.status.idle":"2022-07-22T03:41:33.676400Z","shell.execute_reply.started":"2022-07-22T03:41:33.656309Z","shell.execute_reply":"2022-07-22T03:41:33.674052Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train = train.drop(columns=[\"Age_group\"])\ntest = test.drop(columns=[\"Age_group\"])","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:43:25.240350Z","iopub.execute_input":"2022-07-22T03:43:25.240823Z","iopub.status.idle":"2022-07-22T03:43:25.249565Z","shell.execute_reply.started":"2022-07-22T03:43:25.240786Z","shell.execute_reply":"2022-07-22T03:43:25.248500Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test.info()","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:43:56.819575Z","iopub.execute_input":"2022-07-22T03:43:56.820002Z","iopub.status.idle":"2022-07-22T03:43:56.835817Z","shell.execute_reply.started":"2022-07-22T03:43:56.819966Z","shell.execute_reply":"2022-07-22T03:43:56.834540Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# 데이터 분할","metadata":{}},{"cell_type":"code","source":"#2. Data Split \nfrom sklearn.model_selection import train_test_split\n\nX = train.drop(columns=\"Transported\")\ny = train.Transported\n\nX_train, X_val, y_train, y_val = train_test_split(X, y, test_size=0.2, random_state=44)\nprint(X_train.shape, X_val.shape, y_train.shape, y_val.shape)","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:44:02.667592Z","iopub.execute_input":"2022-07-22T03:44:02.668018Z","iopub.status.idle":"2022-07-22T03:44:02.680377Z","shell.execute_reply.started":"2022-07-22T03:44:02.667984Z","shell.execute_reply":"2022-07-22T03:44:02.679324Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# 모델 학습","metadata":{}},{"cell_type":"code","source":"from sklearn.ensemble import RandomForestClassifier\n\nclf = RandomForestClassifier(max_depth=5, random_state=42)\nclf.fit(X_train, y_train)","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:44:26.986565Z","iopub.execute_input":"2022-07-22T03:44:26.987936Z","iopub.status.idle":"2022-07-22T03:44:27.485992Z","shell.execute_reply.started":"2022-07-22T03:44:26.987884Z","shell.execute_reply":"2022-07-22T03:44:27.484529Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import accuracy_score\n\npred = clf.predict(X_train)\npred2 = clf.predict(X_val)\n\nprint(\"Training Acc : %.4f\" % accuracy_score(y_train, pred))\nprint(\"Validation Acc : %.4f\" % accuracy_score(y_val, pred2))","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:44:52.729353Z","iopub.execute_input":"2022-07-22T03:44:52.729790Z","iopub.status.idle":"2022-07-22T03:44:52.840818Z","shell.execute_reply.started":"2022-07-22T03:44:52.729753Z","shell.execute_reply":"2022-07-22T03:44:52.839492Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# 하이퍼파라미터","metadata":{}},{"cell_type":"code","source":"import optuna","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:47:38.629860Z","iopub.execute_input":"2022-07-22T03:47:38.630331Z","iopub.status.idle":"2022-07-22T03:47:39.460721Z","shell.execute_reply.started":"2022-07-22T03:47:38.630292Z","shell.execute_reply":"2022-07-22T03:47:39.459423Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def objective2(trial):\n\n    # tuning을 할 Hyper-parameter를 정의합니다.\n    n_estimators = trial.suggest_int('n_estimators', 50, 200)\n    max_depth = trial.suggest_int('max_depth', 3, 11)  # rules of thumb : sqrt(# of features)\n    max_features = trial.suggest_float('max_features', 0.7, 0.9)\n    # 정의된 Hyper-parameter를 돌릴 모델을 정의합니다.\n    clf2 = RandomForestClassifier(n_estimators=n_estimators,\n                                max_depth=max_depth,\n                                max_features=max_features)\n    \n    # 학습\n    clf2.fit(X_train, y_train)\n    pred3 = clf2.predict(X_val)\n    \n    # 성능 평가\n    ACC = accuracy_score(y_train, pred)\n\n    return ACC\n\nstudy = optuna.create_study(direction='maximize')\nstudy.optimize(objective2, n_trials=100)","metadata":{"execution":{"iopub.status.busy":"2022-07-22T04:23:01.607068Z","iopub.execute_input":"2022-07-22T04:23:01.607488Z","iopub.status.idle":"2022-07-22T04:25:13.974795Z","shell.execute_reply.started":"2022-07-22T04:23:01.607451Z","shell.execute_reply":"2022-07-22T04:25:13.973310Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"optuna.visualization.plot_optimization_history(study)","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:49:36.109327Z","iopub.execute_input":"2022-07-22T03:49:36.109896Z","iopub.status.idle":"2022-07-22T03:49:36.276205Z","shell.execute_reply.started":"2022-07-22T03:49:36.109848Z","shell.execute_reply":"2022-07-22T03:49:36.275373Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"optuna.visualization.plot_param_importances(study)","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:49:49.955494Z","iopub.execute_input":"2022-07-22T03:49:49.955891Z","iopub.status.idle":"2022-07-22T03:49:50.276446Z","shell.execute_reply.started":"2022-07-22T03:49:49.955858Z","shell.execute_reply":"2022-07-22T03:49:50.275008Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"final_rf = RandomForestClassifier(**study.best_params)\nfinal_rf.fit(X, y)\n\nprint(\"\\n\\nBest params for RandomForestClassifier\" , final_rf.get_params())","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:50:28.245708Z","iopub.execute_input":"2022-07-22T03:50:28.246267Z","iopub.status.idle":"2022-07-22T03:50:28.668161Z","shell.execute_reply.started":"2022-07-22T03:50:28.246220Z","shell.execute_reply":"2022-07-22T03:50:28.667033Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pred3 = final_rf.predict(X_train)\npred4 = final_rf.predict(X_val)\n\nprint(\"Training Acc : %.4f\" % accuracy_score(y_train, pred3))\nprint(\"Training Acc : %.4f\" % accuracy_score(y_val, pred4))","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:50:43.540209Z","iopub.execute_input":"2022-07-22T03:50:43.540599Z","iopub.status.idle":"2022-07-22T03:50:43.611818Z","shell.execute_reply.started":"2022-07-22T03:50:43.540568Z","shell.execute_reply":"2022-07-22T03:50:43.610543Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Submisson","metadata":{}},{"cell_type":"code","source":"X_test = test\nresult = final_rf.predict(X_test)\nresult","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:51:27.050516Z","iopub.execute_input":"2022-07-22T03:51:27.050912Z","iopub.status.idle":"2022-07-22T03:51:27.088691Z","shell.execute_reply.started":"2022-07-22T03:51:27.050879Z","shell.execute_reply":"2022-07-22T03:51:27.087266Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission[\"Transported\"] = result \nsubmission","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:51:59.609732Z","iopub.execute_input":"2022-07-22T03:51:59.610175Z","iopub.status.idle":"2022-07-22T03:51:59.628736Z","shell.execute_reply.started":"2022-07-22T03:51:59.610135Z","shell.execute_reply":"2022-07-22T03:51:59.627635Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.reset_index(drop=True).to_csv(\"submission.csv\", index=False)","metadata":{"execution":{"iopub.status.busy":"2022-07-22T03:52:14.098568Z","iopub.execute_input":"2022-07-22T03:52:14.098985Z","iopub.status.idle":"2022-07-22T03:52:14.112829Z","shell.execute_reply.started":"2022-07-22T03:52:14.098951Z","shell.execute_reply":"2022-07-22T03:52:14.111775Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}