{"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-05T12:57:21.883016Z","iopub.execute_input":"2022-07-05T12:57:21.883553Z","iopub.status.idle":"2022-07-05T12:57:21.920296Z","shell.execute_reply.started":"2022-07-05T12:57:21.883409Z","shell.execute_reply":"2022-07-05T12:57:21.918919Z"},"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-07-05T12:59:24.239059Z","iopub.execute_input":"2022-07-05T12:59:24.239430Z","iopub.status.idle":"2022-07-05T12:59:24.898408Z","shell.execute_reply.started":"2022-07-05T12:59:24.239402Z","shell.execute_reply":"2022-07-05T12:59:24.897235Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.read_csv(\"../input/titanic/train.csv\")\ndf.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-05T12:57:22.078128Z","iopub.execute_input":"2022-07-05T12:57:22.078759Z","iopub.status.idle":"2022-07-05T12:57:22.141054Z","shell.execute_reply.started":"2022-07-05T12:57:22.078708Z","shell.execute_reply":"2022-07-05T12:57:22.140033Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.shape","metadata":{"execution":{"iopub.status.busy":"2022-07-05T12:57:22.142456Z","iopub.execute_input":"2022-07-05T12:57:22.143345Z","iopub.status.idle":"2022-07-05T12:57:22.150757Z","shell.execute_reply.started":"2022-07-05T12:57:22.143305Z","shell.execute_reply":"2022-07-05T12:57:22.149488Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1 = pd.read_csv(\"../input/titanic/gender_submission.csv\")\ndf1.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-05T12:57:22.203063Z","iopub.execute_input":"2022-07-05T12:57:22.203520Z","iopub.status.idle":"2022-07-05T12:57:22.222446Z","shell.execute_reply.started":"2022-07-05T12:57:22.203487Z","shell.execute_reply":"2022-07-05T12:57:22.221047Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-05T12:57:22.249085Z","iopub.execute_input":"2022-07-05T12:57:22.249810Z","iopub.status.idle":"2022-07-05T12:57:22.261341Z","shell.execute_reply.started":"2022-07-05T12:57:22.249758Z","shell.execute_reply":"2022-07-05T12:57:22.260016Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = df.drop(columns = ['PassengerId','Name','Ticket','Cabin'])","metadata":{"execution":{"iopub.status.busy":"2022-07-05T12:57:22.296858Z","iopub.execute_input":"2022-07-05T12:57:22.297667Z","iopub.status.idle":"2022-07-05T12:57:22.311259Z","shell.execute_reply.started":"2022-07-05T12:57:22.297618Z","shell.execute_reply":"2022-07-05T12:57:22.309777Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-05T12:57:22.345352Z","iopub.execute_input":"2022-07-05T12:57:22.346673Z","iopub.status.idle":"2022-07-05T12:57:22.363156Z","shell.execute_reply.started":"2022-07-05T12:57:22.346631Z","shell.execute_reply":"2022-07-05T12:57:22.361711Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-05T12:57:22.385207Z","iopub.execute_input":"2022-07-05T12:57:22.386127Z","iopub.status.idle":"2022-07-05T12:57:22.396881Z","shell.execute_reply.started":"2022-07-05T12:57:22.386084Z","shell.execute_reply":"2022-07-05T12:57:22.396012Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.Age = df.Age.replace({np.nan:df[\"Age\"].mean()})","metadata":{"execution":{"iopub.status.busy":"2022-07-05T12:57:22.425306Z","iopub.execute_input":"2022-07-05T12:57:22.426576Z","iopub.status.idle":"2022-07-05T12:57:22.434790Z","shell.execute_reply.started":"2022-07-05T12:57:22.426525Z","shell.execute_reply":"2022-07-05T12:57:22.433704Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-05T12:57:22.483130Z","iopub.execute_input":"2022-07-05T12:57:22.484242Z","iopub.status.idle":"2022-07-05T12:57:22.503456Z","shell.execute_reply.started":"2022-07-05T12:57:22.484197Z","shell.execute_reply":"2022-07-05T12:57:22.502338Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['Embarked'].fillna('S', inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-07-05T12:57:22.505557Z","iopub.execute_input":"2022-07-05T12:57:22.506398Z","iopub.status.idle":"2022-07-05T12:57:22.513128Z","shell.execute_reply.started":"2022-07-05T12:57:22.506360Z","shell.execute_reply":"2022-07-05T12:57:22.512034Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-07-05T12:57:22.515167Z","iopub.execute_input":"2022-07-05T12:57:22.515756Z","iopub.status.idle":"2022-07-05T12:57:22.532516Z","shell.execute_reply.started":"2022-07-05T12:57:22.515723Z","shell.execute_reply":"2022-07-05T12:57:22.529141Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.nunique()","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:27:36.662026Z","iopub.execute_input":"2022-07-05T13:27:36.662437Z","iopub.status.idle":"2022-07-05T13:27:36.673685Z","shell.execute_reply.started":"2022-07-05T13:27:36.662398Z","shell.execute_reply":"2022-07-05T13:27:36.672651Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['Sex'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-07-05T12:57:22.534840Z","iopub.execute_input":"2022-07-05T12:57:22.536024Z","iopub.status.idle":"2022-07-05T12:57:22.549866Z","shell.execute_reply.started":"2022-07-05T12:57:22.535972Z","shell.execute_reply":"2022-07-05T12:57:22.548589Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(5,5))\nsns.heatmap(df.corr(),annot=True)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-05T12:59:58.074104Z","iopub.execute_input":"2022-07-05T12:59:58.074621Z","iopub.status.idle":"2022-07-05T12:59:58.535851Z","shell.execute_reply.started":"2022-07-05T12:59:58.074577Z","shell.execute_reply":"2022-07-05T12:59:58.534605Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig=plt.figure(figsize=(8,5),dpi=95)\nb = sns.barplot(x =df['Embarked'],y = df['Age'])\nb.set_xlabel(\"Embarked\", fontsize = 12)\nb.set_ylabel(\"Age\", fontsize = 12)\n\nb.tick_params(axis='x', rotation=0)","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:31:11.319959Z","iopub.execute_input":"2022-07-05T13:31:11.321061Z","iopub.status.idle":"2022-07-05T13:31:11.618255Z","shell.execute_reply.started":"2022-07-05T13:31:11.321005Z","shell.execute_reply":"2022-07-05T13:31:11.617028Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig=plt.figure(figsize=(8,5),dpi=95)\nb = sns.barplot(x =df['Pclass'],y = df['Age'],palette ='rocket')\nb.set_xlabel(\"Passenger Class\", fontsize = 12)\nb.set_ylabel(\"Age\", fontsize = 12)\nb.tick_params(axis='x', rotation=0)","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:33:22.518473Z","iopub.execute_input":"2022-07-05T13:33:22.519538Z","iopub.status.idle":"2022-07-05T13:33:22.818792Z","shell.execute_reply.started":"2022-07-05T13:33:22.519486Z","shell.execute_reply":"2022-07-05T13:33:22.817562Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig=plt.figure(figsize=(8,5),dpi=95)\nb = sns.barplot(x =df['Pclass'],y = df['Age'],palette ='Dark2')\nb.set_xlabel(\"Passenger Class\", fontsize = 12)\nb.set_ylabel(\"Age\", fontsize = 12)\nb.tick_params(axis='x', rotation=0)","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:32:48.342702Z","iopub.execute_input":"2022-07-05T13:32:48.343120Z","iopub.status.idle":"2022-07-05T13:32:48.638409Z","shell.execute_reply.started":"2022-07-05T13:32:48.343087Z","shell.execute_reply":"2022-07-05T13:32:48.637453Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig=plt.figure(figsize=(8,5),dpi=95)\nb = sns.scatterplot(data = df,x ='Age',y = 'Pclass',palette ='rainbow')\nb.set_xlabel(\"Passenger Class\", fontsize = 12)\nb.set_ylabel(\"Sex\", fontsize = 12)\nb.tick_params(axis='x', rotation=0)","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:38:00.803098Z","iopub.execute_input":"2022-07-05T13:38:00.803868Z","iopub.status.idle":"2022-07-05T13:38:01.083452Z","shell.execute_reply.started":"2022-07-05T13:38:00.803826Z","shell.execute_reply":"2022-07-05T13:38:01.082132Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.lineplot(data=df, x=\"Age\", y=\"Fare\")","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:19:07.456298Z","iopub.execute_input":"2022-07-05T13:19:07.456697Z","iopub.status.idle":"2022-07-05T13:19:09.735084Z","shell.execute_reply.started":"2022-07-05T13:19:07.456665Z","shell.execute_reply":"2022-07-05T13:19:09.733938Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.barplot(data=df, x=\"Age\", y=\"Survived\")","metadata":{"execution":{"iopub.status.busy":"2022-07-05T13:20:00.401662Z","iopub.execute_input":"2022-07-05T13:20:00.402070Z","iopub.status.idle":"2022-07-05T13:20:03.834758Z","shell.execute_reply.started":"2022-07-05T13:20:00.402022Z","shell.execute_reply":"2022-07-05T13:20:03.833609Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}