{"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":"code","source":"import pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport seaborn as sns","metadata":{"execution":{"iopub.status.busy":"2022-08-11T14:56:27.315961Z","iopub.execute_input":"2022-08-11T14:56:27.316346Z","iopub.status.idle":"2022-08-11T14:56:28.309930Z","shell.execute_reply.started":"2022-08-11T14:56:27.316268Z","shell.execute_reply":"2022-08-11T14:56:28.309096Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data =pd.read_csv(\"../input/titanic/train.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-08-11T14:57:59.460038Z","iopub.execute_input":"2022-08-11T14:57:59.460366Z","iopub.status.idle":"2022-08-11T14:57:59.480574Z","shell.execute_reply.started":"2022-08-11T14:57:59.460341Z","shell.execute_reply":"2022-08-11T14:57:59.479075Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_data =pd.read_csv(\"../input/titanic/test.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-08-11T14:59:29.803362Z","iopub.execute_input":"2022-08-11T14:59:29.803695Z","iopub.status.idle":"2022-08-11T14:59:29.815542Z","shell.execute_reply.started":"2022-08-11T14:59:29.803669Z","shell.execute_reply":"2022-08-11T14:59:29.814566Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_data.head(5)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T14:59:43.908958Z","iopub.execute_input":"2022-08-11T14:59:43.909284Z","iopub.status.idle":"2022-08-11T14:59:43.931156Z","shell.execute_reply.started":"2022-08-11T14:59:43.909259Z","shell.execute_reply":"2022-08-11T14:59:43.930561Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.info()","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:00:35.566641Z","iopub.execute_input":"2022-08-11T15:00:35.566952Z","iopub.status.idle":"2022-08-11T15:00:35.593433Z","shell.execute_reply.started":"2022-08-11T15:00:35.566929Z","shell.execute_reply":"2022-08-11T15:00:35.592668Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:00:50.330822Z","iopub.execute_input":"2022-08-11T15:00:50.331137Z","iopub.status.idle":"2022-08-11T15:00:50.341025Z","shell.execute_reply.started":"2022-08-11T15:00:50.331113Z","shell.execute_reply":"2022-08-11T15:00:50.339869Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.drop(['PassengerId','Cabin','Name'],axis=1, inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:02:14.633387Z","iopub.execute_input":"2022-08-11T15:02:14.633711Z","iopub.status.idle":"2022-08-11T15:02:14.640453Z","shell.execute_reply.started":"2022-08-11T15:02:14.633687Z","shell.execute_reply":"2022-08-11T15:02:14.639556Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data['Embarked'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:02:46.775367Z","iopub.execute_input":"2022-08-11T15:02:46.775681Z","iopub.status.idle":"2022-08-11T15:02:46.783488Z","shell.execute_reply.started":"2022-08-11T15:02:46.775658Z","shell.execute_reply":"2022-08-11T15:02:46.782573Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data[train_data['Survived']==1]['Sex'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:03:02.898343Z","iopub.execute_input":"2022-08-11T15:03:02.898685Z","iopub.status.idle":"2022-08-11T15:03:02.906421Z","shell.execute_reply.started":"2022-08-11T15:03:02.898661Z","shell.execute_reply":"2022-08-11T15:03:02.905747Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.shape","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:03:27.236829Z","iopub.execute_input":"2022-08-11T15:03:27.237148Z","iopub.status.idle":"2022-08-11T15:03:27.243159Z","shell.execute_reply.started":"2022-08-11T15:03:27.237125Z","shell.execute_reply":"2022-08-11T15:03:27.242483Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.kdeplot(train_data['Age'])","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:03:41.478806Z","iopub.execute_input":"2022-08-11T15:03:41.479157Z","iopub.status.idle":"2022-08-11T15:03:41.642989Z","shell.execute_reply.started":"2022-08-11T15:03:41.479132Z","shell.execute_reply":"2022-08-11T15:03:41.642055Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.boxplot(train_data['Age'])","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:04:04.365668Z","iopub.execute_input":"2022-08-11T15:04:04.366295Z","iopub.status.idle":"2022-08-11T15:04:04.474183Z","shell.execute_reply.started":"2022-08-11T15:04:04.366268Z","shell.execute_reply":"2022-08-11T15:04:04.473379Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data['Age'].skew()","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:04:19.961924Z","iopub.execute_input":"2022-08-11T15:04:19.962269Z","iopub.status.idle":"2022-08-11T15:04:19.969393Z","shell.execute_reply.started":"2022-08-11T15:04:19.962245Z","shell.execute_reply":"2022-08-11T15:04:19.968498Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ub = train_data['Age'].mean() + 2*train_data['Age'].std()\nlb = train_data['Age'].mean() - 2*train_data['Age'].std()","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:04:41.219191Z","iopub.execute_input":"2022-08-11T15:04:41.219529Z","iopub.status.idle":"2022-08-11T15:04:41.226015Z","shell.execute_reply.started":"2022-08-11T15:04:41.219488Z","shell.execute_reply":"2022-08-11T15:04:41.224445Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sum(train_data['Age'] > ub) ","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:05:02.273324Z","iopub.execute_input":"2022-08-11T15:05:02.273646Z","iopub.status.idle":"2022-08-11T15:05:02.280538Z","shell.execute_reply.started":"2022-08-11T15:05:02.273621Z","shell.execute_reply":"2022-08-11T15:05:02.279878Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Outliers Treatment","metadata":{}},{"cell_type":"code","source":"train_data['Age'][train_data['Age']>ub]=ub\ntrain_data['Age'][train_data['Age']<lb]=lb","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:06:17.293486Z","iopub.execute_input":"2022-08-11T15:06:17.293807Z","iopub.status.idle":"2022-08-11T15:06:17.304415Z","shell.execute_reply.started":"2022-08-11T15:06:17.293784Z","shell.execute_reply":"2022-08-11T15:06:17.303735Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data['Fare'].describe()","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:06:47.731269Z","iopub.execute_input":"2022-08-11T15:06:47.731598Z","iopub.status.idle":"2022-08-11T15:06:47.741046Z","shell.execute_reply.started":"2022-08-11T15:06:47.731575Z","shell.execute_reply":"2022-08-11T15:06:47.740486Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.dropna(axis=0,inplace=True)\ntrain_data.drop('Ticket',axis=1,inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:07:44.713143Z","iopub.execute_input":"2022-08-11T15:07:44.713445Z","iopub.status.idle":"2022-08-11T15:07:44.721195Z","shell.execute_reply.started":"2022-08-11T15:07:44.713421Z","shell.execute_reply":"2022-08-11T15:07:44.720073Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df =pd.get_dummies(data=train_data, columns=['Sex', 'Embarked'])","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:08:03.278270Z","iopub.execute_input":"2022-08-11T15:08:03.278637Z","iopub.status.idle":"2022-08-11T15:08:03.289594Z","shell.execute_reply.started":"2022-08-11T15:08:03.278611Z","shell.execute_reply":"2022-08-11T15:08:03.288538Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X = df.drop(\"Survived\", axis=1)\ny = df[\"Survived\"]","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:08:34.264819Z","iopub.execute_input":"2022-08-11T15:08:34.265180Z","iopub.status.idle":"2022-08-11T15:08:34.271641Z","shell.execute_reply.started":"2022-08-11T15:08:34.265152Z","shell.execute_reply":"2022-08-11T15:08:34.270791Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X.head(10)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:08:57.011152Z","iopub.execute_input":"2022-08-11T15:08:57.011488Z","iopub.status.idle":"2022-08-11T15:08:57.026086Z","shell.execute_reply.started":"2022-08-11T15:08:57.011462Z","shell.execute_reply":"2022-08-11T15:08:57.025397Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import accuracy_score, confusion_matrix, classification_report\nfrom sklearn.model_selection import train_test_split\n\nX_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-11T15:09:35.380416Z","iopub.execute_input":"2022-08-11T15:09:35.380746Z","iopub.status.idle":"2022-08-11T15:09:35.493674Z","shell.execute_reply.started":"2022-08-11T15:09:35.380722Z","shell.execute_reply":"2022-08-11T15:09:35.492555Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.ensemble import RandomForestClassifier","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:09:48.213046Z","iopub.execute_input":"2022-08-11T15:09:48.213487Z","iopub.status.idle":"2022-08-11T15:09:48.427142Z","shell.execute_reply.started":"2022-08-11T15:09:48.213455Z","shell.execute_reply":"2022-08-11T15:09:48.425983Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rf = RandomForestClassifier()\nrf.fit(X_train, y_train)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:10:01.477935Z","iopub.execute_input":"2022-08-11T15:10:01.478237Z","iopub.status.idle":"2022-08-11T15:10:01.632448Z","shell.execute_reply.started":"2022-08-11T15:10:01.478213Z","shell.execute_reply":"2022-08-11T15:10:01.631892Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pred = rf.predict(X_test)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:10:12.197445Z","iopub.execute_input":"2022-08-11T15:10:12.197751Z","iopub.status.idle":"2022-08-11T15:10:12.219371Z","shell.execute_reply.started":"2022-08-11T15:10:12.197725Z","shell.execute_reply":"2022-08-11T15:10:12.218729Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"accuracy_score(y_test, pred)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:10:23.136528Z","iopub.execute_input":"2022-08-11T15:10:23.136857Z","iopub.status.idle":"2022-08-11T15:10:23.144075Z","shell.execute_reply.started":"2022-08-11T15:10:23.136834Z","shell.execute_reply":"2022-08-11T15:10:23.143253Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"accuracy_score(y_train, rf.predict(X_train))","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:10:40.482397Z","iopub.execute_input":"2022-08-11T15:10:40.482715Z","iopub.status.idle":"2022-08-11T15:10:40.511391Z","shell.execute_reply.started":"2022-08-11T15:10:40.482691Z","shell.execute_reply":"2022-08-11T15:10:40.510454Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(classification_report(y_test, pred))","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:11:01.002367Z","iopub.execute_input":"2022-08-11T15:11:01.002694Z","iopub.status.idle":"2022-08-11T15:11:01.012704Z","shell.execute_reply.started":"2022-08-11T15:11:01.002671Z","shell.execute_reply":"2022-08-11T15:11:01.011573Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.model_selection import cross_validate\ncv_rf = cross_validate(rf,X,y, cv=5, return_train_score=True)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:12:01.648441Z","iopub.execute_input":"2022-08-11T15:12:01.648774Z","iopub.status.idle":"2022-08-11T15:12:02.517747Z","shell.execute_reply.started":"2022-08-11T15:12:01.648750Z","shell.execute_reply":"2022-08-11T15:12:02.516560Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_rf = np.average(cv_rf[\"test_score\"])\nprint(test_rf)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:12:31.238623Z","iopub.execute_input":"2022-08-11T15:12:31.238974Z","iopub.status.idle":"2022-08-11T15:12:31.244312Z","shell.execute_reply.started":"2022-08-11T15:12:31.238947Z","shell.execute_reply":"2022-08-11T15:12:31.243738Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.model_selection import GridSearchCV","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:12:46.721436Z","iopub.execute_input":"2022-08-11T15:12:46.721876Z","iopub.status.idle":"2022-08-11T15:12:46.726742Z","shell.execute_reply.started":"2022-08-11T15:12:46.721850Z","shell.execute_reply":"2022-08-11T15:12:46.725427Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"param_grid_rf = { \n    'n_estimators': [200, 500],\n    'max_features': ['auto', 'sqrt', 'log2'],\n    'max_depth' : [4,5,6,7,8],\n    'criterion' :['gini', 'entropy']\n}","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:12:58.149600Z","iopub.execute_input":"2022-08-11T15:12:58.149980Z","iopub.status.idle":"2022-08-11T15:12:58.155004Z","shell.execute_reply.started":"2022-08-11T15:12:58.149954Z","shell.execute_reply":"2022-08-11T15:12:58.154080Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rf_grid = GridSearchCV(estimator=rf, param_grid = param_grid_rf, scoring=\"accuracy\",cv=2, return_train_score=True)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:13:14.494069Z","iopub.execute_input":"2022-08-11T15:13:14.494412Z","iopub.status.idle":"2022-08-11T15:13:14.500169Z","shell.execute_reply.started":"2022-08-11T15:13:14.494387Z","shell.execute_reply":"2022-08-11T15:13:14.498796Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rf_grid_fit = rf_grid.fit(X,y)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:13:32.724642Z","iopub.execute_input":"2022-08-11T15:13:32.724965Z","iopub.status.idle":"2022-08-11T15:14:32.779648Z","shell.execute_reply.started":"2022-08-11T15:13:32.724942Z","shell.execute_reply":"2022-08-11T15:14:32.778492Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":" rf_grid_fit.best_params_","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:14:42.505235Z","iopub.execute_input":"2022-08-11T15:14:42.505692Z","iopub.status.idle":"2022-08-11T15:14:42.513416Z","shell.execute_reply.started":"2022-08-11T15:14:42.505664Z","shell.execute_reply":"2022-08-11T15:14:42.512358Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rf_grid_fit.best_score_","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:15:13.651937Z","iopub.execute_input":"2022-08-11T15:15:13.652247Z","iopub.status.idle":"2022-08-11T15:15:13.657817Z","shell.execute_reply.started":"2022-08-11T15:15:13.652224Z","shell.execute_reply":"2022-08-11T15:15:13.657175Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rf = RandomForestClassifier(criterion=\"entropy\", max_depth=8, max_features=\"auto\", n_estimators=500)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:15:59.717979Z","iopub.execute_input":"2022-08-11T15:15:59.718312Z","iopub.status.idle":"2022-08-11T15:15:59.723419Z","shell.execute_reply.started":"2022-08-11T15:15:59.718287Z","shell.execute_reply":"2022-08-11T15:15:59.722241Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"rf.fit(X_train, y_train)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:16:13.673297Z","iopub.execute_input":"2022-08-11T15:16:13.673652Z","iopub.status.idle":"2022-08-11T15:16:14.361491Z","shell.execute_reply.started":"2022-08-11T15:16:13.673622Z","shell.execute_reply":"2022-08-11T15:16:14.360427Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pred = rf.predict(X_test)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:16:29.837238Z","iopub.execute_input":"2022-08-11T15:16:29.837554Z","iopub.status.idle":"2022-08-11T15:16:29.900694Z","shell.execute_reply.started":"2022-08-11T15:16:29.837530Z","shell.execute_reply":"2022-08-11T15:16:29.899709Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"accuracy_score(y_test, pred)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:16:41.680462Z","iopub.execute_input":"2022-08-11T15:16:41.681243Z","iopub.status.idle":"2022-08-11T15:16:41.687899Z","shell.execute_reply.started":"2022-08-11T15:16:41.681217Z","shell.execute_reply":"2022-08-11T15:16:41.686935Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_data.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:17:41.271323Z","iopub.execute_input":"2022-08-11T15:17:41.271688Z","iopub.status.idle":"2022-08-11T15:17:41.285596Z","shell.execute_reply.started":"2022-08-11T15:17:41.271665Z","shell.execute_reply":"2022-08-11T15:17:41.284894Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_data.drop(['PassengerId','Cabin','Name','Ticket'],axis=1, inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:17:58.368444Z","iopub.execute_input":"2022-08-11T15:17:58.369343Z","iopub.status.idle":"2022-08-11T15:17:58.375142Z","shell.execute_reply.started":"2022-08-11T15:17:58.369308Z","shell.execute_reply":"2022-08-11T15:17:58.374061Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_test =pd.get_dummies(data=test_data, columns=['Sex', 'Embarked'])","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:18:11.362813Z","iopub.execute_input":"2022-08-11T15:18:11.363117Z","iopub.status.idle":"2022-08-11T15:18:11.371553Z","shell.execute_reply.started":"2022-08-11T15:18:11.363094Z","shell.execute_reply":"2022-08-11T15:18:11.370867Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_test.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:18:32.862250Z","iopub.execute_input":"2022-08-11T15:18:32.862601Z","iopub.status.idle":"2022-08-11T15:18:32.874591Z","shell.execute_reply.started":"2022-08-11T15:18:32.862576Z","shell.execute_reply":"2022-08-11T15:18:32.873502Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_test['Age'].fillna(value=df_test['Age'].mean(), inplace=True)\ndf_test['Fare'].fillna(value=df_test['Fare'].mean(), inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:18:55.196323Z","iopub.execute_input":"2022-08-11T15:18:55.196653Z","iopub.status.idle":"2022-08-11T15:18:55.202841Z","shell.execute_reply.started":"2022-08-11T15:18:55.196629Z","shell.execute_reply":"2022-08-11T15:18:55.201941Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_predict_testdata = rf.predict(df_test)","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:19:25.397853Z","iopub.execute_input":"2022-08-11T15:19:25.398169Z","iopub.status.idle":"2022-08-11T15:19:25.473167Z","shell.execute_reply.started":"2022-08-11T15:19:25.398145Z","shell.execute_reply":"2022-08-11T15:19:25.472377Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_predict_testdata","metadata":{"execution":{"iopub.status.busy":"2022-08-11T15:19:39.319802Z","iopub.execute_input":"2022-08-11T15:19:39.320127Z","iopub.status.idle":"2022-08-11T15:19:39.327227Z","shell.execute_reply.started":"2022-08-11T15:19:39.320103Z","shell.execute_reply":"2022-08-11T15:19:39.326149Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}