{"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-08-10T13:56:16.400573Z","iopub.execute_input":"2022-08-10T13:56:16.401301Z","iopub.status.idle":"2022-08-10T13:56:16.435711Z","shell.execute_reply.started":"2022-08-10T13:56:16.401212Z","shell.execute_reply":"2022-08-10T13:56:16.434610Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nfrom scipy import stats\nfrom math import sqrt\nfrom sklearn.model_selection import cross_val_score,train_test_split,cross_val_predict,cross_validate,KFold\nfrom sklearn.metrics import accuracy_score,f1_score,precision_score,recall_score,make_scorer\nfrom sklearn.inspection import permutation_importance\nfrom sklearn.base import clone\nfrom sklearn.model_selection import StratifiedKFold\nfrom sklearn.model_selection import GridSearchCV\nfrom sklearn.feature_selection import SelectFromModel\nfrom sklearn.linear_model import LogisticRegression\nfrom sklearn.tree import DecisionTreeClassifier\nfrom sklearn.ensemble import RandomForestClassifier\nfrom sklearn.neighbors import NearestNeighbors\nfrom sklearn.naive_bayes import GaussianNB\nfrom sklearn.impute import KNNImputer\nfrom sklearn import svm\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nimport warnings\nwarnings.filterwarnings('ignore')","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:57:45.281067Z","iopub.execute_input":"2022-08-10T13:57:45.281595Z","iopub.status.idle":"2022-08-10T13:57:45.291850Z","shell.execute_reply.started":"2022-08-10T13:57:45.281534Z","shell.execute_reply":"2022-08-10T13:57:45.290564Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train = pd.read_csv(\"../input/titanic/train.csv\")\ntest =  pd.read_csv(\"../input/titanic/test.csv\")\ngender= pd.read_csv(\"../input/titanic/train.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:58:14.036252Z","iopub.execute_input":"2022-08-10T13:58:14.036637Z","iopub.status.idle":"2022-08-10T13:58:14.060232Z","shell.execute_reply.started":"2022-08-10T13:58:14.036603Z","shell.execute_reply":"2022-08-10T13:58:14.058955Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:58:14.279751Z","iopub.execute_input":"2022-08-10T13:58:14.281879Z","iopub.status.idle":"2022-08-10T13:58:14.291193Z","shell.execute_reply.started":"2022-08-10T13:58:14.281836Z","shell.execute_reply":"2022-08-10T13:58:14.290056Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.describe()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:58:14.516700Z","iopub.execute_input":"2022-08-10T13:58:14.517268Z","iopub.status.idle":"2022-08-10T13:58:14.549751Z","shell.execute_reply.started":"2022-08-10T13:58:14.517234Z","shell.execute_reply":"2022-08-10T13:58:14.548436Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train['Embarked'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:58:14.710908Z","iopub.execute_input":"2022-08-10T13:58:14.711953Z","iopub.status.idle":"2022-08-10T13:58:14.722989Z","shell.execute_reply.started":"2022-08-10T13:58:14.711904Z","shell.execute_reply":"2022-08-10T13:58:14.721608Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cat_variables = train[['Sex', 'Embarked']]\ncat_dummies = pd.get_dummies(cat_variables, drop_first=True)\ncat_dummies.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:58:14.944103Z","iopub.execute_input":"2022-08-10T13:58:14.944847Z","iopub.status.idle":"2022-08-10T13:58:14.960986Z","shell.execute_reply.started":"2022-08-10T13:58:14.944808Z","shell.execute_reply":"2022-08-10T13:58:14.959600Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train = train.drop(['Sex', 'Embarked'], axis=1)\ntrain = pd.concat([train, cat_dummies], axis=1)\ntrain.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:58:15.160706Z","iopub.execute_input":"2022-08-10T13:58:15.161102Z","iopub.status.idle":"2022-08-10T13:58:15.181997Z","shell.execute_reply.started":"2022-08-10T13:58:15.161067Z","shell.execute_reply":"2022-08-10T13:58:15.180883Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cat_variables = test[['Sex', 'Embarked']]\ncat_dummies = pd.get_dummies(cat_variables, drop_first=True)\ncat_dummies.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:58:15.406022Z","iopub.execute_input":"2022-08-10T13:58:15.406430Z","iopub.status.idle":"2022-08-10T13:58:15.422359Z","shell.execute_reply.started":"2022-08-10T13:58:15.406394Z","shell.execute_reply":"2022-08-10T13:58:15.421289Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test = test.drop(['Sex', 'Embarked'], axis=1)\ntest = pd.concat([test, cat_dummies], axis=1)\ntest.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:58:15.656953Z","iopub.execute_input":"2022-08-10T13:58:15.657654Z","iopub.status.idle":"2022-08-10T13:58:15.676661Z","shell.execute_reply.started":"2022-08-10T13:58:15.657615Z","shell.execute_reply":"2022-08-10T13:58:15.675794Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.info()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:58:15.906367Z","iopub.execute_input":"2022-08-10T13:58:15.907234Z","iopub.status.idle":"2022-08-10T13:58:15.925840Z","shell.execute_reply.started":"2022-08-10T13:58:15.907195Z","shell.execute_reply":"2022-08-10T13:58:15.924533Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test.info()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:58:16.153802Z","iopub.execute_input":"2022-08-10T13:58:16.154460Z","iopub.status.idle":"2022-08-10T13:58:16.172067Z","shell.execute_reply.started":"2022-08-10T13:58:16.154422Z","shell.execute_reply":"2022-08-10T13:58:16.171175Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train['Embarked_Q']=train['Embarked_Q'].astype(\"int64\")\ntrain['Embarked_S']=train['Embarked_S'].astype(\"int64\")\ntrain['Sex_male']=train['Sex_male'].astype(\"int64\")\ntest['Embarked_Q']=test['Embarked_Q'].astype(\"int64\")\ntest['Embarked_S']=test['Embarked_S'].astype(\"int64\")\ntest['Sex_male']=test['Sex_male'].astype(\"int64\")","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:58:16.407383Z","iopub.execute_input":"2022-08-10T13:58:16.408568Z","iopub.status.idle":"2022-08-10T13:58:16.419801Z","shell.execute_reply.started":"2022-08-10T13:58:16.408486Z","shell.execute_reply":"2022-08-10T13:58:16.418788Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"numerics = ['int16', 'int32', 'int64', 'float16', 'float32', 'float64']\n\ntrain = train.select_dtypes(include=numerics)\n\ntest = test.select_dtypes(include=numerics)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:58:16.846452Z","iopub.execute_input":"2022-08-10T13:58:16.847183Z","iopub.status.idle":"2022-08-10T13:58:16.856955Z","shell.execute_reply.started":"2022-08-10T13:58:16.847142Z","shell.execute_reply":"2022-08-10T13:58:16.855874Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"imputer = KNNImputer(n_neighbors=5)\ndf_train = pd.DataFrame(imputer.fit_transform(train),columns = train.columns)\n","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:58:21.912941Z","iopub.execute_input":"2022-08-10T13:58:21.913476Z","iopub.status.idle":"2022-08-10T13:58:21.948292Z","shell.execute_reply.started":"2022-08-10T13:58:21.913428Z","shell.execute_reply":"2022-08-10T13:58:21.946244Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"imputer = KNNImputer(n_neighbors=5)\ndf_test = pd.DataFrame(imputer.fit_transform(test),columns = test.columns)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:58:19.210683Z","iopub.execute_input":"2022-08-10T13:58:19.211620Z","iopub.status.idle":"2022-08-10T13:58:19.232486Z","shell.execute_reply.started":"2022-08-10T13:58:19.211583Z","shell.execute_reply":"2022-08-10T13:58:19.230896Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.pairplot(df_train,hue='Survived')","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:56:18.691960Z","iopub.execute_input":"2022-08-10T13:56:18.693118Z","iopub.status.idle":"2022-08-10T13:56:42.539591Z","shell.execute_reply.started":"2022-08-10T13:56:18.693051Z","shell.execute_reply":"2022-08-10T13:56:42.538252Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"corr = df_train.corr()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:56:42.541108Z","iopub.execute_input":"2022-08-10T13:56:42.541468Z","iopub.status.idle":"2022-08-10T13:56:42.547559Z","shell.execute_reply.started":"2022-08-10T13:56:42.541434Z","shell.execute_reply":"2022-08-10T13:56:42.546484Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"corr","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:56:42.548969Z","iopub.execute_input":"2022-08-10T13:56:42.550006Z","iopub.status.idle":"2022-08-10T13:56:42.577574Z","shell.execute_reply.started":"2022-08-10T13:56:42.549960Z","shell.execute_reply":"2022-08-10T13:56:42.576308Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(10,10))\nax =sns.heatmap(corr)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:56:42.579477Z","iopub.execute_input":"2022-08-10T13:56:42.579860Z","iopub.status.idle":"2022-08-10T13:56:42.896495Z","shell.execute_reply.started":"2022-08-10T13:56:42.579818Z","shell.execute_reply":"2022-08-10T13:56:42.895288Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.histplot(data =train,x= train[\"Age\"],hue='Survived')\nsns.despine()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:56:42.898163Z","iopub.execute_input":"2022-08-10T13:56:42.898621Z","iopub.status.idle":"2022-08-10T13:56:43.209782Z","shell.execute_reply.started":"2022-08-10T13:56:42.898588Z","shell.execute_reply":"2022-08-10T13:56:43.208677Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:56:43.211302Z","iopub.execute_input":"2022-08-10T13:56:43.211669Z","iopub.status.idle":"2022-08-10T13:56:43.240750Z","shell.execute_reply.started":"2022-08-10T13:56:43.211636Z","shell.execute_reply":"2022-08-10T13:56:43.239646Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X=df_train.iloc[:,2:]\ny=df_train.iloc[:,1:2]","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:56:43.242143Z","iopub.execute_input":"2022-08-10T13:56:43.242477Z","iopub.status.idle":"2022-08-10T13:56:43.247927Z","shell.execute_reply.started":"2022-08-10T13:56:43.242445Z","shell.execute_reply":"2022-08-10T13:56:43.246914Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:56:43.253102Z","iopub.execute_input":"2022-08-10T13:56:43.253455Z","iopub.status.idle":"2022-08-10T13:56:43.277563Z","shell.execute_reply.started":"2022-08-10T13:56:43.253416Z","shell.execute_reply":"2022-08-10T13:56:43.276343Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:56:43.278816Z","iopub.execute_input":"2022-08-10T13:56:43.279164Z","iopub.status.idle":"2022-08-10T13:56:43.292949Z","shell.execute_reply.started":"2022-08-10T13:56:43.279133Z","shell.execute_reply":"2022-08-10T13:56:43.291747Z"},"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, random_state=42)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:56:43.294462Z","iopub.execute_input":"2022-08-10T13:56:43.294850Z","iopub.status.idle":"2022-08-10T13:56:43.304750Z","shell.execute_reply.started":"2022-08-10T13:56:43.294816Z","shell.execute_reply":"2022-08-10T13:56:43.303649Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"regr=LogisticRegression()\nregr.fit(x_train,y_train)\ny_pred = regr.predict(x_test)\nprint(f\"Accuracy on CV data: {accuracy_score(y_test,y_pred)}\\n Precision on CV data: {precision_score(y_test,y_pred)} \\n Recall on CV data: {recall_score(y_test,y_pred)} \\n F1 on CV data:{f1_score(y_test,y_pred)} \")\n","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:56:43.305829Z","iopub.execute_input":"2022-08-10T13:56:43.306153Z","iopub.status.idle":"2022-08-10T13:56:43.355066Z","shell.execute_reply.started":"2022-08-10T13:56:43.306113Z","shell.execute_reply":"2022-08-10T13:56:43.353161Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"regr= svm.SVC()\nregr.fit(x_train,y_train)\ny_pred = regr.predict(x_test)\nprint(f\"Accuracy on CV data: {accuracy_score(y_test,y_pred)}\\n Precision on CV data: {precision_score(y_test,y_pred)} \\n Recall on CV data: {recall_score(y_test,y_pred)} \\n F1 on CV data:{f1_score(y_test,y_pred)} \")\n","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:56:43.356340Z","iopub.execute_input":"2022-08-10T13:56:43.356824Z","iopub.status.idle":"2022-08-10T13:56:43.399148Z","shell.execute_reply.started":"2022-08-10T13:56:43.356775Z","shell.execute_reply":"2022-08-10T13:56:43.397712Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"regr= DecisionTreeClassifier()\nregr.fit(x_train,y_train)\ny_pred = regr.predict(x_test)\nprint(f\"Accuracy on CV data: {accuracy_score(y_test,y_pred)}\\n Precision on CV data: {precision_score(y_test,y_pred)} \\n Recall on CV data: {recall_score(y_test,y_pred)} \\n F1 on CV data:{f1_score(y_test,y_pred)} \")\n","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:56:43.400905Z","iopub.execute_input":"2022-08-10T13:56:43.401253Z","iopub.status.idle":"2022-08-10T13:56:43.421795Z","shell.execute_reply.started":"2022-08-10T13:56:43.401221Z","shell.execute_reply":"2022-08-10T13:56:43.420581Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"regr= RandomForestClassifier()\nregr.fit(x_train,y_train)\ny_pred = regr.predict(x_test)\nprint(f\"Accuracy on CV data: {accuracy_score(y_test,y_pred)}\\n Precision on CV data: {precision_score(y_test,y_pred)} \\n Recall on CV data: {recall_score(y_test,y_pred)} \\n F1 on CV data:{f1_score(y_test,y_pred)} \")\n","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:56:43.423508Z","iopub.execute_input":"2022-08-10T13:56:43.424267Z","iopub.status.idle":"2022-08-10T13:56:43.664232Z","shell.execute_reply.started":"2022-08-10T13:56:43.424220Z","shell.execute_reply":"2022-08-10T13:56:43.662920Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"param_grid = { \n    'n_estimators': range(200,500,100),\n    'max_features': ['auto', 'sqrt', 'log2'],\n    'max_depth' : range(2,10,1),\n    'criterion' :['gini', 'entropy']\n}","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:56:43.665867Z","iopub.execute_input":"2022-08-10T13:56:43.667059Z","iopub.status.idle":"2022-08-10T13:56:43.675331Z","shell.execute_reply.started":"2022-08-10T13:56:43.666997Z","shell.execute_reply":"2022-08-10T13:56:43.674033Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# CV_rfc = GridSearchCV(estimator=regr, param_grid=param_grid, cv= 5)\n# CV_rfc.fit(x_train, y_train)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:56:43.677130Z","iopub.execute_input":"2022-08-10T13:56:43.677940Z","iopub.status.idle":"2022-08-10T13:56:57.609877Z","shell.execute_reply.started":"2022-08-10T13:56:43.677883Z","shell.execute_reply":"2022-08-10T13:56:57.607116Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# CV_rfc.best_params_","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:56:57.611535Z","iopub.status.idle":"2022-08-10T13:56:57.612479Z","shell.execute_reply.started":"2022-08-10T13:56:57.612143Z","shell.execute_reply":"2022-08-10T13:56:57.612175Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rf=RandomForestClassifier(random_state=42, max_features='auto', n_estimators= 200, max_depth=3, criterion='entropy')","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:57:51.554525Z","iopub.execute_input":"2022-08-10T13:57:51.554949Z","iopub.status.idle":"2022-08-10T13:57:51.560515Z","shell.execute_reply.started":"2022-08-10T13:57:51.554916Z","shell.execute_reply":"2022-08-10T13:57:51.559471Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# rf.fit(x_train,y_train)\n# y_pred = regr.predict(x_test)\n# print(f\"Accuracy on CV data: {accuracy_score(y_test,y_pred)}\\n Precision on CV data: {precision_score(y_test,y_pred)} \\n Recall on CV data: {recall_score(y_test,y_pred)} \\n F1 on CV data:{f1_score(y_test,y_pred)} \")\n","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:56:57.616687Z","iopub.status.idle":"2022-08-10T13:56:57.617595Z","shell.execute_reply.started":"2022-08-10T13:56:57.617227Z","shell.execute_reply":"2022-08-10T13:56:57.617256Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"kf =  KFold(n_splits=5, random_state=None)\nf1score=[]\nfor train_index, test_index in kf.split(X):\n    X_train , X_test = X.iloc[train_index,:],X.iloc[test_index,:]\n    y_train , y_test = y.iloc[train_index] , y.iloc[test_index]\n    rf.fit(X_train,y_train)\n    pred_values = rf.predict(X_test)\n    f1 = f1_score(pred_values , y_test)\n    f1score.append(f1)\navg_f1_score = sum(f1score)/5","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:58:28.486660Z","iopub.execute_input":"2022-08-10T13:58:28.487044Z","iopub.status.idle":"2022-08-10T13:58:30.287776Z","shell.execute_reply.started":"2022-08-10T13:58:28.487011Z","shell.execute_reply":"2022-08-10T13:58:30.286485Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print('F1 of each fold - {}'.format(f1score))\nprint('F1 accuracy : {}'.format(avg_f1_score))","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:58:30.289660Z","iopub.execute_input":"2022-08-10T13:58:30.290525Z","iopub.status.idle":"2022-08-10T13:58:30.296248Z","shell.execute_reply.started":"2022-08-10T13:58:30.290488Z","shell.execute_reply":"2022-08-10T13:58:30.294736Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_test = df_test.iloc[:,1:]","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:58:32.235992Z","iopub.execute_input":"2022-08-10T13:58:32.237110Z","iopub.status.idle":"2022-08-10T13:58:32.241794Z","shell.execute_reply.started":"2022-08-10T13:58:32.237072Z","shell.execute_reply":"2022-08-10T13:58:32.240969Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_pred=rf.predict(df_test)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:58:32.605983Z","iopub.execute_input":"2022-08-10T13:58:32.606775Z","iopub.status.idle":"2022-08-10T13:58:32.646742Z","shell.execute_reply.started":"2022-08-10T13:58:32.606730Z","shell.execute_reply":"2022-08-10T13:58:32.645452Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_pred = test_pred.astype(\"int64\")","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:58:33.331856Z","iopub.execute_input":"2022-08-10T13:58:33.332616Z","iopub.status.idle":"2022-08-10T13:58:33.337253Z","shell.execute_reply.started":"2022-08-10T13:58:33.332572Z","shell.execute_reply":"2022-08-10T13:58:33.336429Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"op=pd.DataFrame(test['PassengerId'])\nop['Survived']=test_pred","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:58:35.914279Z","iopub.execute_input":"2022-08-10T13:58:35.914696Z","iopub.status.idle":"2022-08-10T13:58:35.922181Z","shell.execute_reply.started":"2022-08-10T13:58:35.914661Z","shell.execute_reply":"2022-08-10T13:58:35.920509Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"op.to_csv(\"test_pred.csv\", index=False)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:58:36.698177Z","iopub.execute_input":"2022-08-10T13:58:36.699181Z","iopub.status.idle":"2022-08-10T13:58:36.706453Z","shell.execute_reply.started":"2022-08-10T13:58:36.699143Z","shell.execute_reply":"2022-08-10T13:58:36.705616Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}