{"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/titanic'):\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-15T15:18:07.195202Z","iopub.execute_input":"2022-07-15T15:18:07.195648Z","iopub.status.idle":"2022-07-15T15:18:07.204817Z","shell.execute_reply.started":"2022-07-15T15:18:07.195611Z","shell.execute_reply":"2022-07-15T15:18:07.203266Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train = pd.read_csv('/kaggle/input/titanic/train.csv')\ntest = pd.read_csv('/kaggle/input/titanic/test.csv')","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:18:07.210336Z","iopub.execute_input":"2022-07-15T15:18:07.211468Z","iopub.status.idle":"2022-07-15T15:18:07.228074Z","shell.execute_reply.started":"2022-07-15T15:18:07.211425Z","shell.execute_reply":"2022-07-15T15:18:07.227078Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.describe()","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:27:29.462232Z","iopub.execute_input":"2022-07-15T15:27:29.462644Z","iopub.status.idle":"2022-07-15T15:27:29.503101Z","shell.execute_reply.started":"2022-07-15T15:27:29.462608Z","shell.execute_reply":"2022-07-15T15:27:29.501957Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"real_train = train.drop(columns=['PassengerId', 'Fare', 'Cabin', 'Ticket', 'Name']).dropna(subset=['Embarked', 'Age']).reset_index(drop=True)\nreal_test = test.drop(columns=['PassengerId', 'Fare', 'Cabin', 'Ticket', 'Name']).dropna(subset=['Embarked', 'Age']).reset_index(drop=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:18:07.250275Z","iopub.execute_input":"2022-07-15T15:18:07.251388Z","iopub.status.idle":"2022-07-15T15:18:07.266388Z","shell.execute_reply.started":"2022-07-15T15:18:07.251338Z","shell.execute_reply":"2022-07-15T15:18:07.265098Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"real_train.tail()","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:18:07.268149Z","iopub.execute_input":"2022-07-15T15:18:07.268901Z","iopub.status.idle":"2022-07-15T15:18:07.282802Z","shell.execute_reply.started":"2022-07-15T15:18:07.268866Z","shell.execute_reply":"2022-07-15T15:18:07.281451Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"male_surv = real_train.apply(lambda x : True if x['Sex'] == \"male\" and x['Survived'] == 1 else False, axis = 1)\nfemale_surv = real_train.apply(lambda x : True if x['Sex'] == \"female\" and x['Survived'] == 1 else False, axis = 1)","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:18:07.284161Z","iopub.execute_input":"2022-07-15T15:18:07.284668Z","iopub.status.idle":"2022-07-15T15:18:07.319129Z","shell.execute_reply.started":"2022-07-15T15:18:07.284638Z","shell.execute_reply":"2022-07-15T15:18:07.317796Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class1_surv = real_train.apply(lambda x : True if x['Pclass'] == 1 and x['Survived'] == 1 else False, axis = 1)\nclass2_surv = real_train.apply(lambda x : True if x['Pclass'] == 2 and x['Survived'] == 1 else False, axis = 1)\nclass3_surv = real_train.apply(lambda x : True if x['Pclass'] == 3 and x['Survived'] == 1 else False, axis = 1)","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:18:07.320938Z","iopub.execute_input":"2022-07-15T15:18:07.321991Z","iopub.status.idle":"2022-07-15T15:18:07.372237Z","shell.execute_reply.started":"2022-07-15T15:18:07.321954Z","shell.execute_reply":"2022-07-15T15:18:07.371000Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"surv_mean = round(real_train['Survived'].mean(), 2)\naval_male = real_train['Sex'].value_counts()['male']\naval_female = real_train['Sex'].value_counts()['female']\n\nsurv_male = male_surv.value_counts()[True]\nsurv_female = female_surv.value_counts()[True]\n\naval_class1 = real_train['Pclass'].value_counts()[1]\naval_class2 = real_train['Pclass'].value_counts()[2]\naval_class3 = real_train['Pclass'].value_counts()[3]\n\nsurv_class1 = class1_surv.value_counts()[True]\nsurv_class2 = class2_surv.value_counts()[True]\nsurv_class3 = class3_surv.value_counts()[True]","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:18:07.373884Z","iopub.execute_input":"2022-07-15T15:18:07.374215Z","iopub.status.idle":"2022-07-15T15:18:07.390357Z","shell.execute_reply.started":"2022-07-15T15:18:07.374185Z","shell.execute_reply":"2022-07-15T15:18:07.389180Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"lbk = '_____________________________________________________________'","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:18:07.448837Z","iopub.execute_input":"2022-07-15T15:18:07.450031Z","iopub.status.idle":"2022-07-15T15:18:07.454807Z","shell.execute_reply.started":"2022-07-15T15:18:07.449990Z","shell.execute_reply":"2022-07-15T15:18:07.453466Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Data Summary","metadata":{}},{"cell_type":"code","source":"print('Survived Mean :{}'.format(surv_mean))\nprint('Male :{}'.format(aval_male))\nprint('Female :{}'.format(aval_female))\nprint(lbk)\nprint('male surv: {}'.format(surv_male))\nprint('female surv: {}'.format(surv_female))\nprint('----surv ratio---')\nprint(' male surv: {}'.format(round(surv_male/aval_male, 2)))\nprint(' female surv: {}'.format(round(surv_female/aval_female, 2)))\nprint(lbk)\nprint('---count by classes---')\nprint(' class1: {}'.format(aval_class1))\nprint(' class2: {}'.format(aval_class2))\nprint(' class3: {}'.format(aval_class3))\nprint('---surv ratio---')\nprint(' class1: {}'.format(round(surv_class1/aval_class1, 2)))\nprint(' class2: {}'.format(round(surv_class2/aval_class2, 2)))\nprint(' class3: {}'.format(round(surv_class3/aval_class3, 2)))","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:18:07.456830Z","iopub.execute_input":"2022-07-15T15:18:07.457600Z","iopub.status.idle":"2022-07-15T15:18:07.471144Z","shell.execute_reply.started":"2022-07-15T15:18:07.457504Z","shell.execute_reply":"2022-07-15T15:18:07.470246Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Data Prep","metadata":{}},{"cell_type":"code","source":"from sklearn.preprocessing import OneHotEncoder","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:18:07.472225Z","iopub.execute_input":"2022-07-15T15:18:07.473169Z","iopub.status.idle":"2022-07-15T15:18:07.483647Z","shell.execute_reply.started":"2022-07-15T15:18:07.473136Z","shell.execute_reply":"2022-07-15T15:18:07.482458Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"real_train.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:18:07.485035Z","iopub.execute_input":"2022-07-15T15:18:07.486215Z","iopub.status.idle":"2022-07-15T15:18:07.507393Z","shell.execute_reply.started":"2022-07-15T15:18:07.486174Z","shell.execute_reply":"2022-07-15T15:18:07.506148Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_label = real_train['Survived']\ntrain_data = real_train.drop(columns=['Survived'])","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:18:07.510137Z","iopub.execute_input":"2022-07-15T15:18:07.511191Z","iopub.status.idle":"2022-07-15T15:18:07.528245Z","shell.execute_reply.started":"2022-07-15T15:18:07.511156Z","shell.execute_reply":"2022-07-15T15:18:07.526808Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:18:07.529683Z","iopub.execute_input":"2022-07-15T15:18:07.530082Z","iopub.status.idle":"2022-07-15T15:18:07.544203Z","shell.execute_reply.started":"2022-07-15T15:18:07.530046Z","shell.execute_reply":"2022-07-15T15:18:07.542967Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.iloc[200:]","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:18:07.545818Z","iopub.execute_input":"2022-07-15T15:18:07.547052Z","iopub.status.idle":"2022-07-15T15:18:07.567857Z","shell.execute_reply.started":"2022-07-15T15:18:07.547003Z","shell.execute_reply":"2022-07-15T15:18:07.566604Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"encd = OneHotEncoder()\nencode = encd.fit_transform(train_data[['Pclass']])\ntrain_data[encd.categories_[0]] = encode.toarray()\n\nencd = OneHotEncoder()\nencode = encd.fit_transform(train_data[['Sex']])\ntrain_data[encd.categories_[0]] = encode.toarray()\n\nencd = OneHotEncoder()\nencode = encd.fit_transform(train_data[['Embarked']])\ntrain_data[encd.categories_[0]] = encode.toarray()","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:18:07.569079Z","iopub.execute_input":"2022-07-15T15:18:07.569775Z","iopub.status.idle":"2022-07-15T15:18:07.588351Z","shell.execute_reply.started":"2022-07-15T15:18:07.569740Z","shell.execute_reply":"2022-07-15T15:18:07.587231Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.head(1)","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:18:07.590563Z","iopub.execute_input":"2022-07-15T15:18:07.591911Z","iopub.status.idle":"2022-07-15T15:18:07.612316Z","shell.execute_reply.started":"2022-07-15T15:18:07.591863Z","shell.execute_reply":"2022-07-15T15:18:07.611006Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"one_hot_train = train_data.drop(columns=['Pclass', 'Sex', 'Embarked'])\none_hot_train.index = one_hot_train.index.map(str)","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:18:07.615631Z","iopub.execute_input":"2022-07-15T15:18:07.615998Z","iopub.status.idle":"2022-07-15T15:18:07.624767Z","shell.execute_reply.started":"2022-07-15T15:18:07.615968Z","shell.execute_reply":"2022-07-15T15:18:07.623114Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print('Valid')\nprint(True if one_hot_train.shape[0] == train_label.shape[0] else False)","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:18:07.626002Z","iopub.execute_input":"2022-07-15T15:18:07.627298Z","iopub.status.idle":"2022-07-15T15:18:07.639615Z","shell.execute_reply.started":"2022-07-15T15:18:07.627259Z","shell.execute_reply":"2022-07-15T15:18:07.638094Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"one_hot_train.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:18:07.641675Z","iopub.execute_input":"2022-07-15T15:18:07.642020Z","iopub.status.idle":"2022-07-15T15:18:07.668224Z","shell.execute_reply.started":"2022-07-15T15:18:07.641989Z","shell.execute_reply":"2022-07-15T15:18:07.667338Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"one_hot_train.columns = ['Age', 'SibSp', 'Parch', 'Tier1', 'Tier2', 'Tier3', 'female', 'male', 'embarkC', 'embarkQ', 'embarkS']\none_hot_train.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:18:07.669433Z","iopub.execute_input":"2022-07-15T15:18:07.670038Z","iopub.status.idle":"2022-07-15T15:18:07.697538Z","shell.execute_reply.started":"2022-07-15T15:18:07.670001Z","shell.execute_reply":"2022-07-15T15:18:07.696655Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Modelling","metadata":{}},{"cell_type":"code","source":"from sklearn.model_selection import train_test_split\nfrom sklearn.ensemble import RandomForestClassifier","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:18:07.701926Z","iopub.execute_input":"2022-07-15T15:18:07.702946Z","iopub.status.idle":"2022-07-15T15:18:07.708029Z","shell.execute_reply.started":"2022-07-15T15:18:07.702896Z","shell.execute_reply":"2022-07-15T15:18:07.706952Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"label = train_label\ntrain_set = one_hot_train","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:18:07.709290Z","iopub.execute_input":"2022-07-15T15:18:07.709789Z","iopub.status.idle":"2022-07-15T15:18:07.722793Z","shell.execute_reply.started":"2022-07-15T15:18:07.709757Z","shell.execute_reply":"2022-07-15T15:18:07.721516Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_train, x_test, y_train, y_test = train_test_split(train_set, label, stratify=label, test_size=0.3, random_state=100)","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:18:07.724078Z","iopub.execute_input":"2022-07-15T15:18:07.724838Z","iopub.status.idle":"2022-07-15T15:18:07.740200Z","shell.execute_reply.started":"2022-07-15T15:18:07.724798Z","shell.execute_reply":"2022-07-15T15:18:07.738988Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_train = x_train.reset_index(drop=True)\nx_train.columns = x_train.columns.map(str)\n\nx_test = x_test.reset_index(drop=True)\nx_test.columns = x_test.columns.map(str)\n\ny_train = y_train.reset_index(drop=True)\n\ny_test = y_test.reset_index(drop=True)\n\nprint(x_train, y_train)","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:18:07.741512Z","iopub.execute_input":"2022-07-15T15:18:07.742507Z","iopub.status.idle":"2022-07-15T15:18:07.763752Z","shell.execute_reply.started":"2022-07-15T15:18:07.742470Z","shell.execute_reply":"2022-07-15T15:18:07.762566Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_train.columns = ['Survived']\ny_train","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:18:07.765335Z","iopub.execute_input":"2022-07-15T15:18:07.766133Z","iopub.status.idle":"2022-07-15T15:18:07.778874Z","shell.execute_reply.started":"2022-07-15T15:18:07.766088Z","shell.execute_reply":"2022-07-15T15:18:07.777941Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Trainning","metadata":{}},{"cell_type":"code","source":"model = RandomForestClassifier(n_estimators=100, random_state=100)","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:18:07.779976Z","iopub.execute_input":"2022-07-15T15:18:07.780502Z","iopub.status.idle":"2022-07-15T15:18:07.790730Z","shell.execute_reply.started":"2022-07-15T15:18:07.780468Z","shell.execute_reply":"2022-07-15T15:18:07.789766Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.fit(x_train,y_train)","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:18:07.791851Z","iopub.execute_input":"2022-07-15T15:18:07.792432Z","iopub.status.idle":"2022-07-15T15:18:08.014847Z","shell.execute_reply.started":"2022-07-15T15:18:07.792400Z","shell.execute_reply":"2022-07-15T15:18:08.013638Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predictions = model.predict(x_test)","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:18:08.016280Z","iopub.execute_input":"2022-07-15T15:18:08.016694Z","iopub.status.idle":"2022-07-15T15:18:08.040394Z","shell.execute_reply.started":"2022-07-15T15:18:08.016661Z","shell.execute_reply":"2022-07-15T15:18:08.039330Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Eval","metadata":{}},{"cell_type":"code","source":"from sklearn import metrics\nprint(\"Accuracy:\",metrics.accuracy_score(y_test, predictions))","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:18:08.042308Z","iopub.execute_input":"2022-07-15T15:18:08.042673Z","iopub.status.idle":"2022-07-15T15:18:08.049977Z","shell.execute_reply.started":"2022-07-15T15:18:08.042640Z","shell.execute_reply":"2022-07-15T15:18:08.048786Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Visualize","metadata":{}},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nfrom sklearn.tree import plot_tree\n\nfig = plt.figure(figsize=(15, 10))\nplot_tree(model.estimators_[0], \n          feature_names=x_train.columns,\n          class_names=y_train.unique().astype(str), \n          filled=True, rounded=True)\n\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:18:08.051687Z","iopub.execute_input":"2022-07-15T15:18:08.052006Z","iopub.status.idle":"2022-07-15T15:18:18.433139Z","shell.execute_reply.started":"2022-07-15T15:18:08.051976Z","shell.execute_reply":"2022-07-15T15:18:18.432001Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Pred","metadata":{}},{"cell_type":"code","source":"test = pd.read_csv('/kaggle/input/titanic/test.csv')\nsubmit = test['PassengerId']\nsubmit = pd.DataFrame(submit)\nreal_test = test.drop(columns=['PassengerId', 'Fare', 'Cabin', 'Ticket', 'Name']).reset_index(drop=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:28:44.395863Z","iopub.execute_input":"2022-07-15T15:28:44.396300Z","iopub.status.idle":"2022-07-15T15:28:44.407630Z","shell.execute_reply.started":"2022-07-15T15:28:44.396263Z","shell.execute_reply":"2022-07-15T15:28:44.406730Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(real_test.isnull().sum())\nreal_test['Age'] = real_test['Age'].fillna(30) # Fill with mean from train data\nprint('--------------')\nprint(real_test.isnull().sum())","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:28:44.836614Z","iopub.execute_input":"2022-07-15T15:28:44.837634Z","iopub.status.idle":"2022-07-15T15:28:44.849648Z","shell.execute_reply.started":"2022-07-15T15:28:44.837593Z","shell.execute_reply":"2022-07-15T15:28:44.848341Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"real_test.head(1)","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:28:48.033107Z","iopub.execute_input":"2022-07-15T15:28:48.033533Z","iopub.status.idle":"2022-07-15T15:28:48.046765Z","shell.execute_reply.started":"2022-07-15T15:28:48.033493Z","shell.execute_reply":"2022-07-15T15:28:48.045381Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"encd = OneHotEncoder()\nencode = encd.fit_transform(real_test[['Pclass']])\nreal_test[encd.categories_[0]] = encode.toarray()\n\nencd = OneHotEncoder()\nencode = encd.fit_transform(real_test[['Sex']])\nreal_test[encd.categories_[0]] = encode.toarray()\n\nencd = OneHotEncoder()\nencode = encd.fit_transform(real_test[['Embarked']])\nreal_test[encd.categories_[0]] = encode.toarray()","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:28:48.537915Z","iopub.execute_input":"2022-07-15T15:28:48.538594Z","iopub.status.idle":"2022-07-15T15:28:48.555382Z","shell.execute_reply.started":"2022-07-15T15:28:48.538555Z","shell.execute_reply":"2022-07-15T15:28:48.554114Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"real_test.head(1)","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:28:49.311888Z","iopub.execute_input":"2022-07-15T15:28:49.312597Z","iopub.status.idle":"2022-07-15T15:28:49.331754Z","shell.execute_reply.started":"2022-07-15T15:28:49.312527Z","shell.execute_reply":"2022-07-15T15:28:49.330479Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"real_test = real_test.drop(columns=['Pclass', 'Sex', 'Embarked'])\nreal_test.columns = ['Age', 'SibSp', 'Parch', 'Tier1', 'Tier2', 'Tier3', 'female', 'male', 'embarkC', 'embarkQ', 'embarkS']","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:28:50.139385Z","iopub.execute_input":"2022-07-15T15:28:50.140195Z","iopub.status.idle":"2022-07-15T15:28:50.148808Z","shell.execute_reply.started":"2022-07-15T15:28:50.140155Z","shell.execute_reply":"2022-07-15T15:28:50.147615Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"real_test.head(1)","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:28:51.117102Z","iopub.execute_input":"2022-07-15T15:28:51.117985Z","iopub.status.idle":"2022-07-15T15:28:51.133930Z","shell.execute_reply.started":"2022-07-15T15:28:51.117945Z","shell.execute_reply":"2022-07-15T15:28:51.132829Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predict = model.predict(real_test)","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:28:51.740744Z","iopub.execute_input":"2022-07-15T15:28:51.741317Z","iopub.status.idle":"2022-07-15T15:28:51.768217Z","shell.execute_reply.started":"2022-07-15T15:28:51.741283Z","shell.execute_reply":"2022-07-15T15:28:51.766849Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submit['Survived'] = predict","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:28:54.314858Z","iopub.execute_input":"2022-07-15T15:28:54.315868Z","iopub.status.idle":"2022-07-15T15:28:54.322235Z","shell.execute_reply.started":"2022-07-15T15:28:54.315818Z","shell.execute_reply":"2022-07-15T15:28:54.321114Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submit.to_csv('./submission.csv')","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:32:07.625682Z","iopub.execute_input":"2022-07-15T15:32:07.626223Z","iopub.status.idle":"2022-07-15T15:32:07.635493Z","shell.execute_reply.started":"2022-07-15T15:32:07.626176Z","shell.execute_reply":"2022-07-15T15:32:07.634674Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!kaggle competitions submit -c titanic -f submission.csv -m \":D\"","metadata":{"execution":{"iopub.status.busy":"2022-07-15T15:33:35.507309Z","iopub.execute_input":"2022-07-15T15:33:35.507780Z","iopub.status.idle":"2022-07-15T15:33:36.711724Z","shell.execute_reply.started":"2022-07-15T15:33:35.507741Z","shell.execute_reply":"2022-07-15T15:33:36.710472Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}