{"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":"import numpy as np\nimport pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\n\n\n# 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-05T13:36:59.579464Z","iopub.execute_input":"2022-07-05T13:36:59.580701Z","iopub.status.idle":"2022-07-05T13:36:59.593685Z","shell.execute_reply.started":"2022-07-05T13:36:59.580643Z","shell.execute_reply":"2022-07-05T13:36:59.592117Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"> # **Read Dataset**","metadata":{}},{"cell_type":"code","source":"train_data = pd.read_csv(\"/kaggle/input/titanic/train.csv\")\ntest_data = pd.read_csv(\"/kaggle/input/titanic/test.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:36:59.605396Z","iopub.execute_input":"2022-07-05T13:36:59.606182Z","iopub.status.idle":"2022-07-05T13:36:59.629093Z","shell.execute_reply.started":"2022-07-05T13:36:59.606133Z","shell.execute_reply":"2022-07-05T13:36:59.628031Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"> # Asking Basic Question","metadata":{}},{"cell_type":"code","source":"#checking for total shape in dataset\ndisplay(train_data.shape)\ndisplay(test_data.shape)","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:36:59.630908Z","iopub.execute_input":"2022-07-05T13:36:59.631452Z","iopub.status.idle":"2022-07-05T13:36:59.639603Z","shell.execute_reply.started":"2022-07-05T13:36:59.631419Z","shell.execute_reply":"2022-07-05T13:36:59.638570Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"display(train_data.sample(5))\ndisplay(test_data.sample(5))","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:36:59.640903Z","iopub.execute_input":"2022-07-05T13:36:59.641572Z","iopub.status.idle":"2022-07-05T13:36:59.678597Z","shell.execute_reply.started":"2022-07-05T13:36:59.641507Z","shell.execute_reply":"2022-07-05T13:36:59.677312Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#checking for total null values columns (missing data)\ndisplay([feature for feature in train_data.columns if train_data[feature].isnull().sum()])\ndisplay([feature for feature in test_data.columns if test_data[feature].isnull().sum()])","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:36:59.681671Z","iopub.execute_input":"2022-07-05T13:36:59.682384Z","iopub.status.idle":"2022-07-05T13:36:59.702156Z","shell.execute_reply.started":"2022-07-05T13:36:59.682340Z","shell.execute_reply":"2022-07-05T13:36:59.700492Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#checking for total null values Mean (missing data)\ndisplay (train_data.isnull().mean())\ndisplay (test_data.isnull().mean())","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:36:59.703698Z","iopub.execute_input":"2022-07-05T13:36:59.704638Z","iopub.status.idle":"2022-07-05T13:36:59.721168Z","shell.execute_reply.started":"2022-07-05T13:36:59.704599Z","shell.execute_reply":"2022-07-05T13:36:59.720310Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.info()","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:36:59.722474Z","iopub.execute_input":"2022-07-05T13:36:59.723024Z","iopub.status.idle":"2022-07-05T13:36:59.741329Z","shell.execute_reply.started":"2022-07-05T13:36:59.722992Z","shell.execute_reply":"2022-07-05T13:36:59.740284Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_data.info()","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:36:59.742697Z","iopub.execute_input":"2022-07-05T13:36:59.743301Z","iopub.status.idle":"2022-07-05T13:36:59.759690Z","shell.execute_reply.started":"2022-07-05T13:36:59.743264Z","shell.execute_reply":"2022-07-05T13:36:59.758276Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.describe()","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:36:59.761407Z","iopub.execute_input":"2022-07-05T13:36:59.762010Z","iopub.status.idle":"2022-07-05T13:36:59.800191Z","shell.execute_reply.started":"2022-07-05T13:36:59.761970Z","shell.execute_reply":"2022-07-05T13:36:59.799119Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.duplicated().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:36:59.803504Z","iopub.execute_input":"2022-07-05T13:36:59.804653Z","iopub.status.idle":"2022-07-05T13:36:59.815991Z","shell.execute_reply.started":"2022-07-05T13:36:59.804615Z","shell.execute_reply":"2022-07-05T13:36:59.814452Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_data.duplicated().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:36:59.818213Z","iopub.execute_input":"2022-07-05T13:36:59.819082Z","iopub.status.idle":"2022-07-05T13:36:59.830911Z","shell.execute_reply.started":"2022-07-05T13:36:59.819033Z","shell.execute_reply":"2022-07-05T13:36:59.829871Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"display(train_data.corr()['Survived'])","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:36:59.832545Z","iopub.execute_input":"2022-07-05T13:36:59.832941Z","iopub.status.idle":"2022-07-05T13:36:59.848111Z","shell.execute_reply.started":"2022-07-05T13:36:59.832905Z","shell.execute_reply":"2022-07-05T13:36:59.846568Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"> # **Exploratory Data Analysis(EDA)**\n\n","metadata":{}},{"cell_type":"markdown","source":">  **How Many People Survived And Non-Survived ?**\n\n> **Univariate EDA Apply In Survived Columns**","metadata":{}},{"cell_type":"code","source":"train_data.head(3)","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:36:59.850181Z","iopub.execute_input":"2022-07-05T13:36:59.851646Z","iopub.status.idle":"2022-07-05T13:36:59.869679Z","shell.execute_reply.started":"2022-07-05T13:36:59.851604Z","shell.execute_reply":"2022-07-05T13:36:59.868671Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data['Survived'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:36:59.871260Z","iopub.execute_input":"2022-07-05T13:36:59.871660Z","iopub.status.idle":"2022-07-05T13:36:59.881582Z","shell.execute_reply.started":"2022-07-05T13:36:59.871627Z","shell.execute_reply":"2022-07-05T13:36:59.880585Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data['Survived'].value_counts().plot(kind='pie', autopct='%.2f')\nplt.show()\nsns.countplot(train_data['Survived'])\n\nplt.show()\n","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:36:59.882831Z","iopub.execute_input":"2022-07-05T13:36:59.883565Z","iopub.status.idle":"2022-07-05T13:37:00.168934Z","shell.execute_reply.started":"2022-07-05T13:36:59.883498Z","shell.execute_reply":"2022-07-05T13:37:00.167666Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"> **Univariate EDA Apply In Pclass Columns**","metadata":{}},{"cell_type":"code","source":"train_data['Survived'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:37:00.170887Z","iopub.execute_input":"2022-07-05T13:37:00.171432Z","iopub.status.idle":"2022-07-05T13:37:00.180991Z","shell.execute_reply.started":"2022-07-05T13:37:00.171383Z","shell.execute_reply":"2022-07-05T13:37:00.179886Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data['Pclass'].value_counts().plot(kind='pie', autopct='%.2f')\nplt.show()\n\nsns.countplot(train_data['Pclass'])\nplt.show()\n","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:37:00.183100Z","iopub.execute_input":"2022-07-05T13:37:00.183484Z","iopub.status.idle":"2022-07-05T13:37:00.469187Z","shell.execute_reply.started":"2022-07-05T13:37:00.183449Z","shell.execute_reply":"2022-07-05T13:37:00.468097Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(x=train_data['Pclass'],hue=train_data[\"Pclass\"])","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:37:00.470781Z","iopub.execute_input":"2022-07-05T13:37:00.471356Z","iopub.status.idle":"2022-07-05T13:37:00.687876Z","shell.execute_reply.started":"2022-07-05T13:37:00.471322Z","shell.execute_reply":"2022-07-05T13:37:00.687011Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"> # **Relation Find Between Pclass And Survived**","metadata":{}},{"cell_type":"code","source":"sns.heatmap(pd.crosstab(train_data['Pclass'],train_data['Survived']))","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:37:00.689296Z","iopub.execute_input":"2022-07-05T13:37:00.689824Z","iopub.status.idle":"2022-07-05T13:37:00.935088Z","shell.execute_reply.started":"2022-07-05T13:37:00.689788Z","shell.execute_reply":"2022-07-05T13:37:00.934196Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"> **Univariate EDA Apply In SexColumns**","metadata":{}},{"cell_type":"code","source":"train_data['Sex'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:37:00.936781Z","iopub.execute_input":"2022-07-05T13:37:00.937567Z","iopub.status.idle":"2022-07-05T13:37:00.947921Z","shell.execute_reply.started":"2022-07-05T13:37:00.937495Z","shell.execute_reply":"2022-07-05T13:37:00.946769Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(train_data['Sex'])","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:37:00.949415Z","iopub.execute_input":"2022-07-05T13:37:00.950116Z","iopub.status.idle":"2022-07-05T13:37:01.117548Z","shell.execute_reply.started":"2022-07-05T13:37:00.950059Z","shell.execute_reply":"2022-07-05T13:37:01.116386Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"> **Relation Find Between Sex And Survived**","metadata":{}},{"cell_type":"code","source":"sns.heatmap(pd.crosstab(train_data['Sex'],train_data['Survived']))","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:37:01.119237Z","iopub.execute_input":"2022-07-05T13:37:01.119574Z","iopub.status.idle":"2022-07-05T13:37:01.360695Z","shell.execute_reply.started":"2022-07-05T13:37:01.119543Z","shell.execute_reply":"2022-07-05T13:37:01.359485Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"> **Relation Find Between Pclass And Sex**","metadata":{}},{"cell_type":"code","source":"sns.heatmap(pd.crosstab(train_data['Pclass'],train_data['Survived']))","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:37:01.362243Z","iopub.execute_input":"2022-07-05T13:37:01.362580Z","iopub.status.idle":"2022-07-05T13:37:01.600542Z","shell.execute_reply.started":"2022-07-05T13:37:01.362549Z","shell.execute_reply":"2022-07-05T13:37:01.599328Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"> **Univariate EDA Apply In Age Columns**","metadata":{}},{"cell_type":"code","source":"plt.hist(train_data['Age'])","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:37:01.607340Z","iopub.execute_input":"2022-07-05T13:37:01.607791Z","iopub.status.idle":"2022-07-05T13:37:01.834736Z","shell.execute_reply.started":"2022-07-05T13:37:01.607745Z","shell.execute_reply":"2022-07-05T13:37:01.833664Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.kdeplot(train_data['Age'])\nsns.kdeplot(train_data['Fare'])","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:37:01.836205Z","iopub.execute_input":"2022-07-05T13:37:01.837057Z","iopub.status.idle":"2022-07-05T13:37:02.069181Z","shell.execute_reply.started":"2022-07-05T13:37:01.837021Z","shell.execute_reply":"2022-07-05T13:37:02.068359Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.boxplot(train_data['Age'])","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:37:02.070325Z","iopub.execute_input":"2022-07-05T13:37:02.071027Z","iopub.status.idle":"2022-07-05T13:37:02.242981Z","shell.execute_reply.started":"2022-07-05T13:37:02.070993Z","shell.execute_reply":"2022-07-05T13:37:02.241798Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data.info()","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:37:02.245373Z","iopub.execute_input":"2022-07-05T13:37:02.245748Z","iopub.status.idle":"2022-07-05T13:37:02.263647Z","shell.execute_reply.started":"2022-07-05T13:37:02.245713Z","shell.execute_reply":"2022-07-05T13:37:02.262306Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"> **Relation Find Between Pclass, Sex And Age**","metadata":{}},{"cell_type":"code","source":"sns.barplot(train_data['Pclass'],train_data['Age'])","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:37:02.265503Z","iopub.execute_input":"2022-07-05T13:37:02.266646Z","iopub.status.idle":"2022-07-05T13:37:02.557793Z","shell.execute_reply.started":"2022-07-05T13:37:02.266596Z","shell.execute_reply":"2022-07-05T13:37:02.556513Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.barplot(train_data['Pclass'],train_data['Age'], hue=train_data['Survived'])","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:37:02.559710Z","iopub.execute_input":"2022-07-05T13:37:02.560476Z","iopub.status.idle":"2022-07-05T13:37:02.968606Z","shell.execute_reply.started":"2022-07-05T13:37:02.560426Z","shell.execute_reply":"2022-07-05T13:37:02.967419Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#relation between sex Age And Survived\nsns.barplot(train_data['Sex'],train_data['Age'], hue=train_data['Survived'])","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:37:02.970271Z","iopub.execute_input":"2022-07-05T13:37:02.971089Z","iopub.status.idle":"2022-07-05T13:37:03.340410Z","shell.execute_reply.started":"2022-07-05T13:37:02.971035Z","shell.execute_reply":"2022-07-05T13:37:03.339200Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\nsns.barplot(train_data['Embarked'],train_data['Age'], hue=train_data['Survived'])","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:37:03.342062Z","iopub.execute_input":"2022-07-05T13:37:03.342537Z","iopub.status.idle":"2022-07-05T13:37:03.756911Z","shell.execute_reply.started":"2022-07-05T13:37:03.342475Z","shell.execute_reply":"2022-07-05T13:37:03.756064Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\nsns.barplot(train_data['Embarked'],train_data['Survived'])","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:37:03.758414Z","iopub.execute_input":"2022-07-05T13:37:03.758855Z","iopub.status.idle":"2022-07-05T13:37:04.045005Z","shell.execute_reply.started":"2022-07-05T13:37:03.758819Z","shell.execute_reply":"2022-07-05T13:37:04.043755Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.crosstab(train_data['Pclass'],train_data['Survived'])","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:37:04.046631Z","iopub.execute_input":"2022-07-05T13:37:04.046964Z","iopub.status.idle":"2022-07-05T13:37:04.069455Z","shell.execute_reply.started":"2022-07-05T13:37:04.046934Z","shell.execute_reply":"2022-07-05T13:37:04.068427Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.heatmap(pd.crosstab(train_data['Pclass'],train_data['Survived']))","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:37:04.070760Z","iopub.execute_input":"2022-07-05T13:37:04.071186Z","iopub.status.idle":"2022-07-05T13:37:04.311472Z","shell.execute_reply.started":"2022-07-05T13:37:04.071152Z","shell.execute_reply":"2022-07-05T13:37:04.309038Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.pairplot(train_data)","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:37:04.313146Z","iopub.execute_input":"2022-07-05T13:37:04.313510Z","iopub.status.idle":"2022-07-05T13:37:14.753753Z","shell.execute_reply.started":"2022-07-05T13:37:04.313476Z","shell.execute_reply":"2022-07-05T13:37:14.752417Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.barplot(train_data['Pclass'],train_data['Fare'],hue=train_data['Sex'])","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:37:14.755300Z","iopub.execute_input":"2022-07-05T13:37:14.755791Z","iopub.status.idle":"2022-07-05T13:37:15.144447Z","shell.execute_reply.started":"2022-07-05T13:37:14.755753Z","shell.execute_reply":"2022-07-05T13:37:15.143047Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.scatterplot(train_data['Age'], train_data['Fare'],size=train_data['Survived'])","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:37:15.146568Z","iopub.execute_input":"2022-07-05T13:37:15.147047Z","iopub.status.idle":"2022-07-05T13:37:15.446768Z","shell.execute_reply.started":"2022-07-05T13:37:15.146997Z","shell.execute_reply":"2022-07-05T13:37:15.445655Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.scatterplot(train_data['Age'], train_data['Fare'],hue=train_data['Sex'],size=train_data['Pclass'])","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:37:15.448267Z","iopub.execute_input":"2022-07-05T13:37:15.448713Z","iopub.status.idle":"2022-07-05T13:37:15.830514Z","shell.execute_reply.started":"2022-07-05T13:37:15.448679Z","shell.execute_reply":"2022-07-05T13:37:15.829550Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\nsns.catplot(x='Pclass',y='Survived',hue='Sex',kind='point',data=train_data)","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:37:15.832172Z","iopub.execute_input":"2022-07-05T13:37:15.832799Z","iopub.status.idle":"2022-07-05T13:37:16.416481Z","shell.execute_reply.started":"2022-07-05T13:37:15.832763Z","shell.execute_reply":"2022-07-05T13:37:16.415281Z"},"trusted":true},"execution_count":null,"outputs":[]}]}