{"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-27T18:17:27.081972Z","iopub.execute_input":"2022-07-27T18:17:27.082506Z","iopub.status.idle":"2022-07-27T18:17:27.114021Z","shell.execute_reply.started":"2022-07-27T18:17:27.082394Z","shell.execute_reply":"2022-07-27T18:17:27.113129Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nimport seaborn as sns\nfrom sklearn.feature_selection import mutual_info_classif\n\nfrom sklearn.ensemble import RandomForestClassifier\nfrom sklearn.svm import SVC\nfrom sklearn.model_selection import train_test_split\nfrom sklearn import metrics\nfrom sklearn.metrics import confusion_matrix, classification_report\n\nsns.set_style('darkgrid')","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:17:27.170626Z","iopub.execute_input":"2022-07-27T18:17:27.171009Z","iopub.status.idle":"2022-07-27T18:17:27.917211Z","shell.execute_reply.started":"2022-07-27T18:17:27.170971Z","shell.execute_reply":"2022-07-27T18:17:27.916216Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.read_csv(\"/kaggle/input/titanic/train.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:17:27.919522Z","iopub.execute_input":"2022-07-27T18:17:27.920608Z","iopub.status.idle":"2022-07-27T18:17:27.940691Z","shell.execute_reply.started":"2022-07-27T18:17:27.920561Z","shell.execute_reply":"2022-07-27T18:17:27.939792Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:17:27.941926Z","iopub.execute_input":"2022-07-27T18:17:27.942490Z","iopub.status.idle":"2022-07-27T18:17:27.966189Z","shell.execute_reply.started":"2022-07-27T18:17:27.942447Z","shell.execute_reply":"2022-07-27T18:17:27.965324Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:17:27.969220Z","iopub.execute_input":"2022-07-27T18:17:27.970017Z","iopub.status.idle":"2022-07-27T18:17:27.979948Z","shell.execute_reply.started":"2022-07-27T18:17:27.969971Z","shell.execute_reply":"2022-07-27T18:17:27.978701Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.duplicated().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:17:27.981139Z","iopub.execute_input":"2022-07-27T18:17:27.981907Z","iopub.status.idle":"2022-07-27T18:17:28.003593Z","shell.execute_reply.started":"2022-07-27T18:17:27.981870Z","shell.execute_reply":"2022-07-27T18:17:28.002497Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.info()","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:17:28.005035Z","iopub.execute_input":"2022-07-27T18:17:28.005353Z","iopub.status.idle":"2022-07-27T18:17:28.023267Z","shell.execute_reply.started":"2022-07-27T18:17:28.005324Z","shell.execute_reply":"2022-07-27T18:17:28.022255Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig,ax = plt.subplots(1,2, figsize=(12,5))\n\nsns.countplot(x=\"Survived\",hue=\"Sex\", data=df, ax=ax[0])\nax[1].pie(x=df.Sex.value_counts(), explode=[0,0.1], labels=[\"Male\", \"Female\"],autopct=\"%.0f%%\")\nax[1].plot()","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:17:28.024760Z","iopub.execute_input":"2022-07-27T18:17:28.025077Z","iopub.status.idle":"2022-07-27T18:17:28.323894Z","shell.execute_reply.started":"2022-07-27T18:17:28.025049Z","shell.execute_reply":"2022-07-27T18:17:28.322772Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig,ax = plt.subplots(1,2, figsize=(12,5))\n\nsns.barplot(df.Pclass.unique(), df.Pclass.value_counts(), data=df,ax=ax[0])\nsns.countplot(\"Pclass\", hue=\"Sex\", data=df,ax=ax[1])\n# ax[1].plot()","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:17:28.325505Z","iopub.execute_input":"2022-07-27T18:17:28.325895Z","iopub.status.idle":"2022-07-27T18:17:28.652416Z","shell.execute_reply.started":"2022-07-27T18:17:28.325862Z","shell.execute_reply":"2022-07-27T18:17:28.651301Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"correlation = df.corr()\n\nplt.figure(figsize=(10,5))\nsns.heatmap(correlation, annot=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:17:28.653959Z","iopub.execute_input":"2022-07-27T18:17:28.654305Z","iopub.status.idle":"2022-07-27T18:17:29.138055Z","shell.execute_reply.started":"2022-07-27T18:17:28.654273Z","shell.execute_reply":"2022-07-27T18:17:29.137278Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['Salutation'] = df.Name.str.extract('([A-Za-z]+)\\.')","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:17:29.141647Z","iopub.execute_input":"2022-07-27T18:17:29.142419Z","iopub.status.idle":"2022-07-27T18:17:29.150982Z","shell.execute_reply.started":"2022-07-27T18:17:29.142384Z","shell.execute_reply":"2022-07-27T18:17:29.149719Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.head(10)","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:17:29.152609Z","iopub.execute_input":"2022-07-27T18:17:29.152930Z","iopub.status.idle":"2022-07-27T18:17:29.176874Z","shell.execute_reply.started":"2022-07-27T18:17:29.152899Z","shell.execute_reply":"2022-07-27T18:17:29.175700Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.Salutation.unique()","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:17:29.178717Z","iopub.execute_input":"2022-07-27T18:17:29.179135Z","iopub.status.idle":"2022-07-27T18:17:29.187806Z","shell.execute_reply.started":"2022-07-27T18:17:29.179095Z","shell.execute_reply":"2022-07-27T18:17:29.186985Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"_,ax = plt.subplots(1,1,figsize=(15,6))\n\nsns.countplot(df.Salutation, hue=\"Sex\",data=df,ax=ax)","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:17:29.189109Z","iopub.execute_input":"2022-07-27T18:17:29.189810Z","iopub.status.idle":"2022-07-27T18:17:29.590338Z","shell.execute_reply.started":"2022-07-27T18:17:29.189775Z","shell.execute_reply":"2022-07-27T18:17:29.589230Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.crosstab(df.Sex, df.Salutation)","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:17:29.591840Z","iopub.execute_input":"2022-07-27T18:17:29.592211Z","iopub.status.idle":"2022-07-27T18:17:29.626919Z","shell.execute_reply.started":"2022-07-27T18:17:29.592179Z","shell.execute_reply":"2022-07-27T18:17:29.625662Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"to_replace = [\"Don\", \"Rev\", \"Dr\",\"Sir\",\"Capt\",\"Col\",\"Countess\",\"Jonkheer\",\"Major\",\"Mlle\",\"Mme\",\"Ms\"]\n\ndf.loc[(df.Salutation == \"Don\") | (df.Salutation == \"Rev\") | (df.Salutation == \"Dr\") | (df.Salutation == \"Lady\") | (df.Salutation == \"Sir\") | (df.Salutation == \"Capt\") | (df.Salutation == \"Col\") | (df.Salutation == \"Countess\") | (df.Salutation == \"Jonkheer\") | (df.Salutation == \"Major\") | (df.Salutation == \"Mlle\") | (df.Salutation == \"Mme\") | (df.Salutation == \"Ms\"), \"Salutation\"] = \"Others\"","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:17:29.628540Z","iopub.execute_input":"2022-07-27T18:17:29.629611Z","iopub.status.idle":"2022-07-27T18:17:29.642133Z","shell.execute_reply.started":"2022-07-27T18:17:29.629561Z","shell.execute_reply":"2022-07-27T18:17:29.641245Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.Salutation.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:17:29.643364Z","iopub.execute_input":"2022-07-27T18:17:29.643757Z","iopub.status.idle":"2022-07-27T18:17:29.657965Z","shell.execute_reply.started":"2022-07-27T18:17:29.643725Z","shell.execute_reply":"2022-07-27T18:17:29.657097Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mr_age_mean = int(round(df.loc[df.Salutation == \"Mr\"][\"Age\"].mean(),0))\nmrs_age_mean = int(round(df.loc[df.Salutation == \"Mrs\"][\"Age\"].mean(), 0))\nmaster_age_mean = int(round(df.loc[df.Salutation == \"Master\"][\"Age\"].mean(), 0))\nmiss_age_mean = int(round(df.loc[df.Salutation == \"Miss\"][\"Age\"].mean(), 0))\noth_age_mean = int(round(df.loc[df.Salutation == \"Others\"][\"Age\"].mean(), 0))\n\nprint(mr_age_mean, mrs_age_mean, master_age_mean, miss_age_mean, oth_age_mean)","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:17:29.659231Z","iopub.execute_input":"2022-07-27T18:17:29.660115Z","iopub.status.idle":"2022-07-27T18:17:29.675144Z","shell.execute_reply.started":"2022-07-27T18:17:29.660070Z","shell.execute_reply":"2022-07-27T18:17:29.673761Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.loc[(df[\"Age\"].isna()) & (df.Salutation == \"Mr\"), \"Age\"] = mr_age_mean\ndf.loc[(df[\"Age\"].isna()) & (df.Salutation == \"Mrs\"), \"Age\"] = mrs_age_mean\ndf.loc[(df[\"Age\"].isna()) & (df.Salutation == \"Master\"), \"Age\"] = master_age_mean\ndf.loc[(df[\"Age\"].isna()) & (df.Salutation == \"Miss\"), \"Age\"] = miss_age_mean\ndf.loc[(df[\"Age\"].isna()) & (df.Salutation == \"Others\"), \"Age\"] = oth_age_mean","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:17:29.677273Z","iopub.execute_input":"2022-07-27T18:17:29.677758Z","iopub.status.idle":"2022-07-27T18:17:29.691969Z","shell.execute_reply.started":"2022-07-27T18:17:29.677717Z","shell.execute_reply":"2022-07-27T18:17:29.690839Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"max_occ = max(df.Embarked.value_counts())\ndf.loc[df[\"Embarked\"].isna(), \"Embarked\"] = max_occ","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:17:29.693180Z","iopub.execute_input":"2022-07-27T18:17:29.694099Z","iopub.status.idle":"2022-07-27T18:17:29.703988Z","shell.execute_reply.started":"2022-07-27T18:17:29.694064Z","shell.execute_reply":"2022-07-27T18:17:29.703033Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df[\"Sex\"].replace([\"male\",\"female\"],[0,1],inplace=True)\ndf['Embarked'].replace(['S','C','Q'],[0,1,2],inplace=True)\ndf['Salutation'].replace(['Mr','Mrs','Miss','Master','Other'],[0,1,2,3,4],inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:17:29.705342Z","iopub.execute_input":"2022-07-27T18:17:29.705906Z","iopub.status.idle":"2022-07-27T18:17:29.717836Z","shell.execute_reply.started":"2022-07-27T18:17:29.705872Z","shell.execute_reply":"2022-07-27T18:17:29.716839Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df[\"FamilyCount\"] = df[\"SibSp\"] + df[\"Parch\"] + 1","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:17:29.719263Z","iopub.execute_input":"2022-07-27T18:17:29.720062Z","iopub.status.idle":"2022-07-27T18:17:29.726680Z","shell.execute_reply.started":"2022-07-27T18:17:29.720027Z","shell.execute_reply":"2022-07-27T18:17:29.725669Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.columns","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:17:29.728130Z","iopub.execute_input":"2022-07-27T18:17:29.728495Z","iopub.status.idle":"2022-07-27T18:17:29.739313Z","shell.execute_reply.started":"2022-07-27T18:17:29.728458Z","shell.execute_reply":"2022-07-27T18:17:29.738175Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Y = df['Survived']\ndf.drop(columns=[\"PassengerId\",\"Name\",\"SibSp\",\"Parch\",\"Ticket\",\"Cabin\",\"Salutation\",\"Survived\"],axis=1, inplace=True)\nX = df","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:17:29.741263Z","iopub.execute_input":"2022-07-27T18:17:29.741896Z","iopub.status.idle":"2022-07-27T18:17:29.749131Z","shell.execute_reply.started":"2022-07-27T18:17:29.741852Z","shell.execute_reply":"2022-07-27T18:17:29.748344Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X.shape, Y.shape","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:17:29.750458Z","iopub.execute_input":"2022-07-27T18:17:29.750988Z","iopub.status.idle":"2022-07-27T18:17:29.763711Z","shell.execute_reply.started":"2022-07-27T18:17:29.750957Z","shell.execute_reply":"2022-07-27T18:17:29.762607Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train, X_test, y_train, y_test = train_test_split(X, Y, test_size=0.2)\n\nprint(X_train.shape, X_test.shape, y_train.shape, y_test.shape)","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:17:29.764926Z","iopub.execute_input":"2022-07-27T18:17:29.765546Z","iopub.status.idle":"2022-07-27T18:17:29.775408Z","shell.execute_reply.started":"2022-07-27T18:17:29.765501Z","shell.execute_reply":"2022-07-27T18:17:29.774234Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# svm_model = SVC(kernel='rbf', random_state=1, gamma=0.1, C=0.02,verbose=True)\n# svm_model.fit(X_train,y_train)\n# y_pred = svm_model.predict(X_test)\n# print(classification_report(y_test,y_pred))","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:17:29.777046Z","iopub.execute_input":"2022-07-27T18:17:29.777746Z","iopub.status.idle":"2022-07-27T18:17:29.783346Z","shell.execute_reply.started":"2022-07-27T18:17:29.777702Z","shell.execute_reply":"2022-07-27T18:17:29.782570Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rnd_forest_model = RandomForestClassifier(n_estimators=200)\nrnd_forest_model.fit(X_train,y_train)\ny_pred_rndforest = rnd_forest_model.predict(X_test)\nprint(classification_report(y_test,y_pred_rndforest))","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:17:29.784646Z","iopub.execute_input":"2022-07-27T18:17:29.785037Z","iopub.status.idle":"2022-07-27T18:17:30.193322Z","shell.execute_reply.started":"2022-07-27T18:17:29.785008Z","shell.execute_reply":"2022-07-27T18:17:30.192400Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Test data\ndf_test = pd.read_csv('../input/titanic/test.csv')","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:39:13.906213Z","iopub.execute_input":"2022-07-27T18:39:13.906649Z","iopub.status.idle":"2022-07-27T18:39:13.916684Z","shell.execute_reply.started":"2022-07-27T18:39:13.906613Z","shell.execute_reply":"2022-07-27T18:39:13.915473Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_test.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:39:14.445865Z","iopub.execute_input":"2022-07-27T18:39:14.446464Z","iopub.status.idle":"2022-07-27T18:39:14.461059Z","shell.execute_reply.started":"2022-07-27T18:39:14.446417Z","shell.execute_reply":"2022-07-27T18:39:14.460159Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mean_fare = round(df_test[\"Fare\"].mean(), 0)\nmean_fare","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:39:15.135765Z","iopub.execute_input":"2022-07-27T18:39:15.136352Z","iopub.status.idle":"2022-07-27T18:39:15.143252Z","shell.execute_reply.started":"2022-07-27T18:39:15.136319Z","shell.execute_reply":"2022-07-27T18:39:15.142381Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_test['Salutation'] = df_test.Name.str.extract('([A-Za-z]+)\\.')\n\nto_replace = [\"Don\", \"Rev\", \"Dr\",\"Sir\",\"Capt\",\"Col\",\"Countess\",\"Jonkheer\",\"Major\",\"Mlle\",\"Mme\",\"Ms\"]\n\ndf_test.loc[(df_test.Salutation == \"Don\") | (df_test.Salutation == \"Rev\") | (df_test.Salutation == \"Dr\") | (df_test.Salutation == \"Lady\") | (df_test.Salutation == \"Sir\") | (df_test.Salutation == \"Capt\") | (df_test.Salutation == \"Col\") | (df_test.Salutation == \"Countess\") | (df_test.Salutation == \"Jonkheer\") | (df_test.Salutation == \"Major\") | (df_test.Salutation == \"Mlle\") | (df_test.Salutation == \"Mme\") | (df_test.Salutation == \"Ms\"), \"Salutation\"] = \"Others\"\n\nmr_age_mean = int(round(df_test.loc[df_test.Salutation == \"Mr\"][\"Age\"].mean(),0))\nmrs_age_mean = int(round(df_test.loc[df_test.Salutation == \"Mrs\"][\"Age\"].mean(), 0))\nmaster_age_mean = int(round(df_test.loc[df_test.Salutation == \"Master\"][\"Age\"].mean(), 0))\nmiss_age_mean = int(round(df_test.loc[df_test.Salutation == \"Miss\"][\"Age\"].mean(), 0))\noth_age_mean = int(round(df_test.loc[df_test.Salutation == \"Others\"][\"Age\"].mean(), 0))\n\nprint(mr_age_mean, mrs_age_mean, master_age_mean, miss_age_mean, oth_age_mean)\n\ndf_test.loc[(df_test[\"Age\"].isna()) & (df_test.Salutation == \"Mr\"), \"Age\"] = mr_age_mean\ndf_test.loc[(df_test[\"Age\"].isna()) & (df_test.Salutation == \"Mrs\"), \"Age\"] = mrs_age_mean\ndf_test.loc[(df_test[\"Age\"].isna()) & (df_test.Salutation == \"Master\"), \"Age\"] = master_age_mean\ndf_test.loc[(df_test[\"Age\"].isna()) & (df_test.Salutation == \"Miss\"), \"Age\"] = miss_age_mean\ndf_test.loc[(df_test[\"Age\"].isna()) & (df_test.Salutation == \"Others\"), \"Age\"] = oth_age_mean\n\nmax_occ = max(df_test.Embarked.value_counts())\ndf_test.loc[df_test[\"Embarked\"].isna(), \"Embarked\"] = max_occ\n\ndf_test.loc[(df_test[\"Fare\"].isna()), \"Fare\"] = mean_fare\n\ndf_test[\"Sex\"].replace([\"male\",\"female\"],[0,1],inplace=True)\ndf_test['Embarked'].replace(['S','C','Q'],[0,1,2],inplace=True)\ndf_test['Salutation'].replace(['Mr','Mrs','Miss','Master','Other'],[0,1,2,3,4],inplace=True)\n\ndf_test[\"FamilyCount\"] = df_test[\"SibSp\"] + df_test[\"Parch\"] + 1\n\npassenger_ids = df_test[\"PassengerId\"]\n\ndf_test.drop(columns=[\"PassengerId\",\"Name\",\"SibSp\",\"Parch\",\"Ticket\",\"Cabin\",\"Salutation\"],axis=1, inplace=True)\n\nX_sub = df_test","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:39:18.370574Z","iopub.execute_input":"2022-07-27T18:39:18.371771Z","iopub.status.idle":"2022-07-27T18:39:18.421758Z","shell.execute_reply.started":"2022-07-27T18:39:18.371717Z","shell.execute_reply":"2022-07-27T18:39:18.420873Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_sub.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:39:21.287879Z","iopub.execute_input":"2022-07-27T18:39:21.288591Z","iopub.status.idle":"2022-07-27T18:39:21.297015Z","shell.execute_reply.started":"2022-07-27T18:39:21.288555Z","shell.execute_reply":"2022-07-27T18:39:21.296045Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_sub = rnd_forest_model.predict(X_sub)","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:34:08.631812Z","iopub.execute_input":"2022-07-27T18:34:08.632210Z","iopub.status.idle":"2022-07-27T18:34:08.677019Z","shell.execute_reply.started":"2022-07-27T18:34:08.632177Z","shell.execute_reply":"2022-07-27T18:34:08.676058Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission = pd.DataFrame(data=y_sub, columns=[\"Survived\"])","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:40:35.450553Z","iopub.execute_input":"2022-07-27T18:40:35.450959Z","iopub.status.idle":"2022-07-27T18:40:35.456383Z","shell.execute_reply.started":"2022-07-27T18:40:35.450924Z","shell.execute_reply":"2022-07-27T18:40:35.455256Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission[\"PassengerId\"] = passenger_ids","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:40:59.403964Z","iopub.execute_input":"2022-07-27T18:40:59.405086Z","iopub.status.idle":"2022-07-27T18:40:59.410716Z","shell.execute_reply.started":"2022-07-27T18:40:59.405031Z","shell.execute_reply":"2022-07-27T18:40:59.409899Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.to_csv(\"submission.csv\", index=False)","metadata":{"execution":{"iopub.status.busy":"2022-07-27T18:41:55.086927Z","iopub.execute_input":"2022-07-27T18:41:55.087305Z","iopub.status.idle":"2022-07-27T18:41:55.097315Z","shell.execute_reply.started":"2022-07-27T18:41:55.087276Z","shell.execute_reply":"2022-07-27T18:41:55.096256Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}