{"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-25T06:29:28.291658Z","iopub.execute_input":"2022-07-25T06:29:28.292053Z","iopub.status.idle":"2022-07-25T06:29:28.323103Z","shell.execute_reply.started":"2022-07-25T06:29:28.291972Z","shell.execute_reply":"2022-07-25T06:29:28.321858Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data = pd.read_csv(\"/kaggle/input/titanic/train.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:33:48.511628Z","iopub.execute_input":"2022-07-25T06:33:48.512132Z","iopub.status.idle":"2022-07-25T06:33:48.531409Z","shell.execute_reply.started":"2022-07-25T06:33:48.512063Z","shell.execute_reply":"2022-07-25T06:33:48.530474Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:33:57.469221Z","iopub.execute_input":"2022-07-25T06:33:57.469857Z","iopub.status.idle":"2022-07-25T06:33:57.494215Z","shell.execute_reply.started":"2022-07-25T06:33:57.469805Z","shell.execute_reply":"2022-07-25T06:33:57.493415Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.columns","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:34:40.398175Z","iopub.execute_input":"2022-07-25T06:34:40.398697Z","iopub.status.idle":"2022-07-25T06:34:40.408478Z","shell.execute_reply.started":"2022-07-25T06:34:40.398654Z","shell.execute_reply":"2022-07-25T06:34:40.407291Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.info()","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:35:36.070449Z","iopub.execute_input":"2022-07-25T06:35:36.070839Z","iopub.status.idle":"2022-07-25T06:35:36.095051Z","shell.execute_reply.started":"2022-07-25T06:35:36.070806Z","shell.execute_reply":"2022-07-25T06:35:36.093484Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.describe()","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:35:50.636291Z","iopub.execute_input":"2022-07-25T06:35:50.637549Z","iopub.status.idle":"2022-07-25T06:35:50.672892Z","shell.execute_reply.started":"2022-07-25T06:35:50.637503Z","shell.execute_reply":"2022-07-25T06:35:50.671722Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.shape","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:36:14.831876Z","iopub.execute_input":"2022-07-25T06:36:14.833014Z","iopub.status.idle":"2022-07-25T06:36:14.839319Z","shell.execute_reply.started":"2022-07-25T06:36:14.832973Z","shell.execute_reply":"2022-07-25T06:36:14.838282Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:36:29.930919Z","iopub.execute_input":"2022-07-25T06:36:29.931416Z","iopub.status.idle":"2022-07-25T06:36:29.943410Z","shell.execute_reply.started":"2022-07-25T06:36:29.931373Z","shell.execute_reply":"2022-07-25T06:36:29.942490Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = data\n","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:36:45.529175Z","iopub.execute_input":"2022-07-25T06:36:45.529577Z","iopub.status.idle":"2022-07-25T06:36:45.533918Z","shell.execute_reply.started":"2022-07-25T06:36:45.529546Z","shell.execute_reply":"2022-07-25T06:36:45.532774Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data = df.copy()\ntrain_data[\"Age\"].fillna(df[\"Age\"].median(skipna=True), inplace=True)\ntrain_data[\"Embarked\"].fillna(df['Embarked'].value_counts().idxmax(), inplace=True)\ntrain_data.drop('Cabin', axis=1, inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:36:56.483271Z","iopub.execute_input":"2022-07-25T06:36:56.483668Z","iopub.status.idle":"2022-07-25T06:36:56.496750Z","shell.execute_reply.started":"2022-07-25T06:36:56.483638Z","shell.execute_reply":"2022-07-25T06:36:56.495747Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\n\nplt.figure(figsize=(15,8))\nax = df[\"Age\"].hist(bins=15, density=True, stacked=True, color='teal', alpha=0.6)\ndf[\"Age\"].plot(kind='density', color='teal')\nax = train_data[\"Age\"].hist(bins=15, density=True, stacked=True, color='orange', alpha=0.5)\ntrain_data[\"Age\"].plot(kind='density', color='orange')\nax.legend(['Raw Age', 'Adjusted Age'])\nax.set(xlabel='Age')\nplt.xlim(-10,85)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:37:24.327174Z","iopub.execute_input":"2022-07-25T06:37:24.328038Z","iopub.status.idle":"2022-07-25T06:37:25.059657Z","shell.execute_reply.started":"2022-07-25T06:37:24.327972Z","shell.execute_reply":"2022-07-25T06:37:25.058425Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1=df.copy()\n","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:38:03.401292Z","iopub.execute_input":"2022-07-25T06:38:03.401714Z","iopub.status.idle":"2022-07-25T06:38:03.407554Z","shell.execute_reply.started":"2022-07-25T06:38:03.401681Z","shell.execute_reply":"2022-07-25T06:38:03.406312Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1['Age'].fillna(df1['Age'].median(skipna=True),inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:38:18.013041Z","iopub.execute_input":"2022-07-25T06:38:18.013409Z","iopub.status.idle":"2022-07-25T06:38:18.020600Z","shell.execute_reply.started":"2022-07-25T06:38:18.013380Z","shell.execute_reply":"2022-07-25T06:38:18.019204Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:38:29.119683Z","iopub.execute_input":"2022-07-25T06:38:29.120090Z","iopub.status.idle":"2022-07-25T06:38:29.129608Z","shell.execute_reply.started":"2022-07-25T06:38:29.120056Z","shell.execute_reply":"2022-07-25T06:38:29.128583Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1.drop('Cabin',axis=1,inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:38:49.269543Z","iopub.execute_input":"2022-07-25T06:38:49.269927Z","iopub.status.idle":"2022-07-25T06:38:49.276390Z","shell.execute_reply.started":"2022-07-25T06:38:49.269895Z","shell.execute_reply":"2022-07-25T06:38:49.275166Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:38:53.910805Z","iopub.execute_input":"2022-07-25T06:38:53.911188Z","iopub.status.idle":"2022-07-25T06:38:53.920802Z","shell.execute_reply.started":"2022-07-25T06:38:53.911155Z","shell.execute_reply":"2022-07-25T06:38:53.919763Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1.loc[df1['Embarked'].isnull()==True,'Embarked']='S'\n","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:39:12.752406Z","iopub.execute_input":"2022-07-25T06:39:12.752796Z","iopub.status.idle":"2022-07-25T06:39:12.759778Z","shell.execute_reply.started":"2022-07-25T06:39:12.752764Z","shell.execute_reply":"2022-07-25T06:39:12.758296Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:39:17.619492Z","iopub.execute_input":"2022-07-25T06:39:17.619869Z","iopub.status.idle":"2022-07-25T06:39:17.629960Z","shell.execute_reply.started":"2022-07-25T06:39:17.619837Z","shell.execute_reply":"2022-07-25T06:39:17.628820Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1.info()","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:39:23.451913Z","iopub.execute_input":"2022-07-25T06:39:23.452326Z","iopub.status.idle":"2022-07-25T06:39:23.466453Z","shell.execute_reply.started":"2022-07-25T06:39:23.452292Z","shell.execute_reply":"2022-07-25T06:39:23.465485Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1.duplicated().sum()\n","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:39:38.952709Z","iopub.execute_input":"2022-07-25T06:39:38.953061Z","iopub.status.idle":"2022-07-25T06:39:38.964635Z","shell.execute_reply.started":"2022-07-25T06:39:38.953033Z","shell.execute_reply":"2022-07-25T06:39:38.963608Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1.drop(['Name', 'PassengerId'], axis=1, inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:40:33.117178Z","iopub.execute_input":"2022-07-25T06:40:33.117579Z","iopub.status.idle":"2022-07-25T06:40:33.127782Z","shell.execute_reply.started":"2022-07-25T06:40:33.117546Z","shell.execute_reply":"2022-07-25T06:40:33.123360Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1.drop(['Ticket'],axis=1,inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:40:50.926158Z","iopub.execute_input":"2022-07-25T06:40:50.926586Z","iopub.status.idle":"2022-07-25T06:40:50.933188Z","shell.execute_reply.started":"2022-07-25T06:40:50.926547Z","shell.execute_reply":"2022-07-25T06:40:50.932344Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:40:55.808577Z","iopub.execute_input":"2022-07-25T06:40:55.808932Z","iopub.status.idle":"2022-07-25T06:40:55.827893Z","shell.execute_reply.started":"2022-07-25T06:40:55.808904Z","shell.execute_reply":"2022-07-25T06:40:55.826750Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1.Survived.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:41:21.786638Z","iopub.execute_input":"2022-07-25T06:41:21.787294Z","iopub.status.idle":"2022-07-25T06:41:21.797011Z","shell.execute_reply.started":"2022-07-25T06:41:21.787239Z","shell.execute_reply":"2022-07-25T06:41:21.796062Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1.loc[:,['Sex','Age']]","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:41:52.148371Z","iopub.execute_input":"2022-07-25T06:41:52.148759Z","iopub.status.idle":"2022-07-25T06:41:52.163673Z","shell.execute_reply.started":"2022-07-25T06:41:52.148727Z","shell.execute_reply":"2022-07-25T06:41:52.162278Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"(df1[(df1['Sex']=='male')])\n","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:42:09.961690Z","iopub.execute_input":"2022-07-25T06:42:09.962727Z","iopub.status.idle":"2022-07-25T06:42:09.983222Z","shell.execute_reply.started":"2022-07-25T06:42:09.962685Z","shell.execute_reply":"2022-07-25T06:42:09.982470Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.preprocessing import LabelEncoder\n","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:42:51.045730Z","iopub.execute_input":"2022-07-25T06:42:51.046597Z","iopub.status.idle":"2022-07-25T06:42:51.123299Z","shell.execute_reply.started":"2022-07-25T06:42:51.046556Z","shell.execute_reply":"2022-07-25T06:42:51.122379Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"lc = LabelEncoder()\ndf1.Sex = lc.fit_transform(df1.Sex)\ndf1.Embarked = lc.fit_transform(df1.Embarked)","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:44:12.656380Z","iopub.execute_input":"2022-07-25T06:44:12.657489Z","iopub.status.idle":"2022-07-25T06:44:12.663573Z","shell.execute_reply.started":"2022-07-25T06:44:12.657427Z","shell.execute_reply":"2022-07-25T06:44:12.662484Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:44:22.260294Z","iopub.execute_input":"2022-07-25T06:44:22.260686Z","iopub.status.idle":"2022-07-25T06:44:22.281415Z","shell.execute_reply.started":"2022-07-25T06:44:22.260653Z","shell.execute_reply":"2022-07-25T06:44:22.280172Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1.drop(['SibSp','Parch'],axis=1,inplace=True)\n","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:44:49.462266Z","iopub.execute_input":"2022-07-25T06:44:49.462655Z","iopub.status.idle":"2022-07-25T06:44:49.469411Z","shell.execute_reply.started":"2022-07-25T06:44:49.462620Z","shell.execute_reply":"2022-07-25T06:44:49.468257Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:44:51.737973Z","iopub.execute_input":"2022-07-25T06:44:51.738739Z","iopub.status.idle":"2022-07-25T06:44:51.760588Z","shell.execute_reply.started":"2022-07-25T06:44:51.738697Z","shell.execute_reply":"2022-07-25T06:44:51.759402Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x=df1.drop(['Survived'],axis=1)\ny=df1.Survived","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:45:15.642034Z","iopub.execute_input":"2022-07-25T06:45:15.642401Z","iopub.status.idle":"2022-07-25T06:45:15.648926Z","shell.execute_reply.started":"2022-07-25T06:45:15.642370Z","shell.execute_reply":"2022-07-25T06:45:15.647622Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:45:23.829369Z","iopub.execute_input":"2022-07-25T06:45:23.829776Z","iopub.status.idle":"2022-07-25T06:45:23.845121Z","shell.execute_reply.started":"2022-07-25T06:45:23.829744Z","shell.execute_reply":"2022-07-25T06:45:23.844365Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:45:26.278227Z","iopub.execute_input":"2022-07-25T06:45:26.278875Z","iopub.status.idle":"2022-07-25T06:45:26.286969Z","shell.execute_reply.started":"2022-07-25T06:45:26.278822Z","shell.execute_reply":"2022-07-25T06:45:26.285952Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.preprocessing import StandardScaler","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:45:48.166170Z","iopub.execute_input":"2022-07-25T06:45:48.166540Z","iopub.status.idle":"2022-07-25T06:45:48.171328Z","shell.execute_reply.started":"2022-07-25T06:45:48.166508Z","shell.execute_reply":"2022-07-25T06:45:48.170379Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sc = StandardScaler()\ns_x = sc.fit_transform(x)","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:46:21.956545Z","iopub.execute_input":"2022-07-25T06:46:21.956913Z","iopub.status.idle":"2022-07-25T06:46:21.965324Z","shell.execute_reply.started":"2022-07-25T06:46:21.956884Z","shell.execute_reply":"2022-07-25T06:46:21.964477Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"s_x","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:46:25.049495Z","iopub.execute_input":"2022-07-25T06:46:25.050531Z","iopub.status.idle":"2022-07-25T06:46:25.058238Z","shell.execute_reply.started":"2022-07-25T06:46:25.050460Z","shell.execute_reply":"2022-07-25T06:46:25.056727Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.model_selection import train_test_split\nx_train,x_test,y_train,y_test=train_test_split(s_x,y,random_state=0,test_size=0.25)","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:46:38.038034Z","iopub.execute_input":"2022-07-25T06:46:38.038465Z","iopub.status.idle":"2022-07-25T06:46:38.102001Z","shell.execute_reply.started":"2022-07-25T06:46:38.038409Z","shell.execute_reply":"2022-07-25T06:46:38.100897Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_train.shape\n","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:46:45.445553Z","iopub.execute_input":"2022-07-25T06:46:45.446954Z","iopub.status.idle":"2022-07-25T06:46:45.455256Z","shell.execute_reply.started":"2022-07-25T06:46:45.446897Z","shell.execute_reply":"2022-07-25T06:46:45.453720Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_train.shape","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:46:55.463414Z","iopub.execute_input":"2022-07-25T06:46:55.463945Z","iopub.status.idle":"2022-07-25T06:46:55.471290Z","shell.execute_reply.started":"2022-07-25T06:46:55.463899Z","shell.execute_reply":"2022-07-25T06:46:55.470533Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.linear_model import LogisticRegression\n","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:47:07.652226Z","iopub.execute_input":"2022-07-25T06:47:07.652680Z","iopub.status.idle":"2022-07-25T06:47:07.738524Z","shell.execute_reply.started":"2022-07-25T06:47:07.652630Z","shell.execute_reply":"2022-07-25T06:47:07.737683Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model = LogisticRegression()\n\nmodel.fit(x_train, y_train)","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:48:01.258595Z","iopub.execute_input":"2022-07-25T06:48:01.258969Z","iopub.status.idle":"2022-07-25T06:48:01.274465Z","shell.execute_reply.started":"2022-07-25T06:48:01.258941Z","shell.execute_reply":"2022-07-25T06:48:01.273158Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_train_pred=model.predict(x_train)\nx_test_pred=model.predict(x_test)","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:48:20.440209Z","iopub.execute_input":"2022-07-25T06:48:20.441299Z","iopub.status.idle":"2022-07-25T06:48:20.446107Z","shell.execute_reply.started":"2022-07-25T06:48:20.441254Z","shell.execute_reply":"2022-07-25T06:48:20.445344Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.score(x_train,y_train)\n","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:48:40.321090Z","iopub.execute_input":"2022-07-25T06:48:40.321509Z","iopub.status.idle":"2022-07-25T06:48:40.329306Z","shell.execute_reply.started":"2022-07-25T06:48:40.321472Z","shell.execute_reply":"2022-07-25T06:48:40.328234Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.score(x_test,y_test)","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:49:01.955698Z","iopub.execute_input":"2022-07-25T06:49:01.956142Z","iopub.status.idle":"2022-07-25T06:49:01.964188Z","shell.execute_reply.started":"2022-07-25T06:49:01.956107Z","shell.execute_reply":"2022-07-25T06:49:01.963301Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import classification_report\n\nreport=classification_report(y_test,x_test_pred)\nprint(report)","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:49:29.668707Z","iopub.execute_input":"2022-07-25T06:49:29.669100Z","iopub.status.idle":"2022-07-25T06:49:29.680680Z","shell.execute_reply.started":"2022-07-25T06:49:29.669065Z","shell.execute_reply":"2022-07-25T06:49:29.679495Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_test","metadata":{"execution":{"iopub.status.busy":"2022-07-25T06:51:01.359073Z","iopub.execute_input":"2022-07-25T06:51:01.360216Z","iopub.status.idle":"2022-07-25T06:51:01.367526Z","shell.execute_reply.started":"2022-07-25T06:51:01.360176Z","shell.execute_reply":"2022-07-25T06:51:01.366364Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test = pd.read_csv(\"/kaggle/input/titanic/test.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-07-25T07:03:24.022330Z","iopub.execute_input":"2022-07-25T07:03:24.022761Z","iopub.status.idle":"2022-07-25T07:03:24.033487Z","shell.execute_reply.started":"2022-07-25T07:03:24.022723Z","shell.execute_reply":"2022-07-25T07:03:24.032532Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test","metadata":{"execution":{"iopub.status.busy":"2022-07-25T07:03:24.937734Z","iopub.execute_input":"2022-07-25T07:03:24.938463Z","iopub.status.idle":"2022-07-25T07:03:24.961245Z","shell.execute_reply.started":"2022-07-25T07:03:24.938408Z","shell.execute_reply":"2022-07-25T07:03:24.960003Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df = test.copy()","metadata":{"execution":{"iopub.status.busy":"2022-07-25T07:03:25.755654Z","iopub.execute_input":"2022-07-25T07:03:25.756454Z","iopub.status.idle":"2022-07-25T07:03:25.761098Z","shell.execute_reply.started":"2022-07-25T07:03:25.756370Z","shell.execute_reply":"2022-07-25T07:03:25.760075Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df","metadata":{"execution":{"iopub.status.busy":"2022-07-25T07:03:27.040281Z","iopub.execute_input":"2022-07-25T07:03:27.041289Z","iopub.status.idle":"2022-07-25T07:03:27.062727Z","shell.execute_reply.started":"2022-07-25T07:03:27.041250Z","shell.execute_reply":"2022-07-25T07:03:27.061771Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df.drop([\"Name\", \"Parch\"], axis=1, inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-25T07:03:27.912554Z","iopub.execute_input":"2022-07-25T07:03:27.913102Z","iopub.status.idle":"2022-07-25T07:03:27.920591Z","shell.execute_reply.started":"2022-07-25T07:03:27.913053Z","shell.execute_reply":"2022-07-25T07:03:27.919166Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df","metadata":{"execution":{"iopub.status.busy":"2022-07-25T07:03:32.186278Z","iopub.execute_input":"2022-07-25T07:03:32.186684Z","iopub.status.idle":"2022-07-25T07:03:32.209698Z","shell.execute_reply.started":"2022-07-25T07:03:32.186652Z","shell.execute_reply":"2022-07-25T07:03:32.208522Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"le = LabelEncoder()\ntest_df.Sex = le.fit_transform(test_df['Sex'])","metadata":{"execution":{"iopub.status.busy":"2022-07-25T07:03:36.344015Z","iopub.execute_input":"2022-07-25T07:03:36.344935Z","iopub.status.idle":"2022-07-25T07:03:36.349246Z","shell.execute_reply.started":"2022-07-25T07:03:36.344902Z","shell.execute_reply":"2022-07-25T07:03:36.348538Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df.drop([\"Ticket\", \"PassengerId\",\"SibSp\"], axis=1, inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-25T07:03:37.210488Z","iopub.execute_input":"2022-07-25T07:03:37.211129Z","iopub.status.idle":"2022-07-25T07:03:37.218242Z","shell.execute_reply.started":"2022-07-25T07:03:37.211085Z","shell.execute_reply":"2022-07-25T07:03:37.217105Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df.drop([\"Cabin\"], axis=1, inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-25T07:04:28.012252Z","iopub.execute_input":"2022-07-25T07:04:28.012778Z","iopub.status.idle":"2022-07-25T07:04:28.021473Z","shell.execute_reply.started":"2022-07-25T07:04:28.012743Z","shell.execute_reply":"2022-07-25T07:04:28.019836Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df","metadata":{"execution":{"iopub.status.busy":"2022-07-25T07:04:36.074214Z","iopub.execute_input":"2022-07-25T07:04:36.074823Z","iopub.status.idle":"2022-07-25T07:04:36.088201Z","shell.execute_reply.started":"2022-07-25T07:04:36.074784Z","shell.execute_reply":"2022-07-25T07:04:36.087383Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df.Embarked = le.fit_transform(test_df['Embarked'])","metadata":{"execution":{"iopub.status.busy":"2022-07-25T07:05:14.337525Z","iopub.execute_input":"2022-07-25T07:05:14.338081Z","iopub.status.idle":"2022-07-25T07:05:14.342677Z","shell.execute_reply.started":"2022-07-25T07:05:14.338051Z","shell.execute_reply":"2022-07-25T07:05:14.341755Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-25T07:05:32.998056Z","iopub.execute_input":"2022-07-25T07:05:32.998774Z","iopub.status.idle":"2022-07-25T07:05:33.007655Z","shell.execute_reply.started":"2022-07-25T07:05:32.998739Z","shell.execute_reply":"2022-07-25T07:05:33.006287Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df = test_df.fillna(df.mean())","metadata":{"execution":{"iopub.status.busy":"2022-07-25T07:08:23.828856Z","iopub.execute_input":"2022-07-25T07:08:23.829460Z","iopub.status.idle":"2022-07-25T07:08:23.839169Z","shell.execute_reply.started":"2022-07-25T07:08:23.829405Z","shell.execute_reply":"2022-07-25T07:08:23.838346Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-25T07:08:25.963837Z","iopub.execute_input":"2022-07-25T07:08:25.964591Z","iopub.status.idle":"2022-07-25T07:08:25.972418Z","shell.execute_reply.started":"2022-07-25T07:08:25.964556Z","shell.execute_reply":"2022-07-25T07:08:25.971562Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sc = StandardScaler()\ntest_sc = sc.fit_transform(test_df)","metadata":{"execution":{"iopub.status.busy":"2022-07-25T07:09:20.269787Z","iopub.execute_input":"2022-07-25T07:09:20.270795Z","iopub.status.idle":"2022-07-25T07:09:20.280656Z","shell.execute_reply.started":"2022-07-25T07:09:20.270752Z","shell.execute_reply":"2022-07-25T07:09:20.279269Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_sc","metadata":{"execution":{"iopub.status.busy":"2022-07-25T07:09:26.059895Z","iopub.execute_input":"2022-07-25T07:09:26.060700Z","iopub.status.idle":"2022-07-25T07:09:26.068106Z","shell.execute_reply.started":"2022-07-25T07:09:26.060650Z","shell.execute_reply":"2022-07-25T07:09:26.066851Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#submission \npreds_test = model.predict(test_sc) \n# Save test predictions to file\noutput = pd.DataFrame({'PassengerId': test.PassengerId,'Survived': preds_test})\noutput.to_csv('submission.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2022-07-25T07:09:49.031457Z","iopub.execute_input":"2022-07-25T07:09:49.031924Z","iopub.status.idle":"2022-07-25T07:09:49.043099Z","shell.execute_reply.started":"2022-07-25T07:09:49.031888Z","shell.execute_reply":"2022-07-25T07:09:49.041917Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}