2016-03-28 12:03:08 +00:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![](images/EscUpmPolit_p.gif \"UPM\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Course Notes for Learning Intelligent Systems"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Department of Telematic Engineering Systems, Universidad Politécnica de Madrid, © 2016 Carlos A. Iglesias"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## [Introduction to Machine Learning II](3_0_0_Intro_ML_2.ipynb)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Table of Contents\n",
"* [Introduction: preprocessing](#Introduction:-preprocessing)\n",
"* [Visualisation with Pandas](#Visualisation-with-Pandas)\n",
"* [Loading and Cleaning](#Loading-and-Cleaning)\n",
"* [General exploration](#General-exploration)\n",
"* [Feature Age](#Feature-Age)\n",
"* [Feature Sex](#Feature-Sex)\n",
"* [Feature Pclass](#Feature-Pclass)\n",
"* [Feature Fare](#Feature-Fare)\n",
"* [Feature Embarked](#Feature-Embarked)\n",
"* [Features SibSp](#Features-SibSp)\n",
"* [Feature ParCh](#Feature-ParCh)\n",
"* [Recap: Filling null values](#Recap:-Filling-null-values)\n",
"\t* [Feature Age: null values](#Feature-Age:-null-values)\n",
"\t* [Feature Embarking: null values](#Feature-Embarking:-null-values)\n",
"\t* [Feature Cabin: null values](#Feature-Cabin:-null-values)\n",
"* [Encoding categorical features](#Encoding-categorical-features)\n",
"\t* [Recap: encoding categorical features](#Recap:-encoding-categorical-features)\n",
"\t* [Encoding Categorical Variables as Binary ones](#Encoding-Categorical-Variables-as-Binary-ones)\n",
"* [Cleaning: dropping](#Cleaning:-dropping)\n",
"* [Feature Engineering](#Feature-Engineering)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Introduction: preprocessing"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In the previous session, we introduced two libraries for visualisation: *matplotlib* and *seaborn*. We are going to review new functionalities in this notebook, as well as the integration of *pandas* with *matplotlib*.\n",
"\n",
"Visualisation is usually combined with munging. We have done this in separated notebooks for learning purposes. We we are going to examine again the dataset, combinging both techniques, and applying the knowledge we got in the previous notebook."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Visualisation with Pandas"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Pandas provides a very good integration with matplotlib. DataFrames have the following methods:\n",
"* **plot()**, for a number of charts, that can be selected with the argument *kind*:\n",
" * 'bar' for bar plots\n",
" * 'hist' for histograms\n",
" * 'box' for boxplots\n",
" * 'kde' for density plots\n",
" * 'area' for area plots\n",
" * 'scatter' for scatter plots\n",
" * 'hexbin' for hexagonal bin plots\n",
" * 'pie' for pie charts\n",
" \n",
"Every plot kind has an equivalent on Dataframe.plot accessor. This means, you can use **df.plot(kind='line')** or **df.plot.line**. Check the [plot documentation](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.plot.html#pandas.DataFrame.plot) to learn the rest of parameters.\n",
"\n",
"In addition, the module *pandas.tools.plotting* provides: **scatter_matrix**.\n",
"\n",
"You can consult more details in the [documentation](http://pandas.pydata.org/pandas-docs/stable/visualization.html)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Loading and Cleaning"
]
},
{
"cell_type": "code",
2016-04-05 14:42:37 +00:00
"execution_count": 8,
2016-03-28 12:03:08 +00:00
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# General import and load data\n",
"import pandas as pd\n",
"\n",
"import seaborn as sns\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"sns.set(color_codes=True)\n",
"\n",
"# if matplotlib is not set inline, you will not see plots\n",
"\n",
"#alternatives auto gtk gtk2 inline osx qt qt5 wx tk\n",
"#%matplotlib auto\n",
"#%matplotlib qt\n",
"%matplotlib inline"
]
},
{
"cell_type": "code",
2016-04-05 14:42:37 +00:00
"execution_count": 11,
2016-03-28 12:03:08 +00:00
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>PassengerId</th>\n",
" <th>Survived</th>\n",
" <th>Pclass</th>\n",
" <th>Name</th>\n",
" <th>Sex</th>\n",
" <th>Age</th>\n",
" <th>SibSp</th>\n",
" <th>Parch</th>\n",
" <th>Ticket</th>\n",
" <th>Fare</th>\n",
" <th>Cabin</th>\n",
" <th>Embarked</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>Braund, Mr. Owen Harris</td>\n",
" <td>male</td>\n",
" <td>22.0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>A/5 21171</td>\n",
" <td>7.2500</td>\n",
" <td>NaN</td>\n",
" <td>S</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>Cumings, Mrs. John Bradley (Florence Briggs Th...</td>\n",
" <td>female</td>\n",
" <td>38.0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>PC 17599</td>\n",
" <td>71.2833</td>\n",
" <td>C85</td>\n",
" <td>C</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>3</td>\n",
" <td>1</td>\n",
" <td>3</td>\n",
" <td>Heikkinen, Miss. Laina</td>\n",
" <td>female</td>\n",
" <td>26.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>STON/O2. 3101282</td>\n",
" <td>7.9250</td>\n",
" <td>NaN</td>\n",
" <td>S</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>4</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>Futrelle, Mrs. Jacques Heath (Lily May Peel)</td>\n",
" <td>female</td>\n",
" <td>35.0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>113803</td>\n",
" <td>53.1000</td>\n",
" <td>C123</td>\n",
" <td>S</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>Allen, Mr. William Henry</td>\n",
" <td>male</td>\n",
" <td>35.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>373450</td>\n",
" <td>8.0500</td>\n",
" <td>NaN</td>\n",
" <td>S</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" PassengerId Survived Pclass \\\n",
"0 1 0 3 \n",
"1 2 1 1 \n",
"2 3 1 3 \n",
"3 4 1 1 \n",
"4 5 0 3 \n",
"\n",
" Name Sex Age SibSp \\\n",
"0 Braund, Mr. Owen Harris male 22.0 1 \n",
"1 Cumings, Mrs. John Bradley (Florence Briggs Th... female 38.0 1 \n",
"2 Heikkinen, Miss. Laina female 26.0 0 \n",
"3 Futrelle, Mrs. Jacques Heath (Lily May Peel) female 35.0 1 \n",
"4 Allen, Mr. William Henry male 35.0 0 \n",
"\n",
" Parch Ticket Fare Cabin Embarked \n",
"0 0 A/5 21171 7.2500 NaN S \n",
"1 0 PC 17599 71.2833 C85 C \n",
"2 0 STON/O2. 3101282 7.9250 NaN S \n",
"3 0 113803 53.1000 C123 S \n",
"4 0 373450 8.0500 NaN S "
]
},
2016-04-05 14:42:37 +00:00
"execution_count": 11,
2016-03-28 12:03:08 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#We get a URL with raw content (not HTML one)\n",
2016-03-29 09:21:43 +00:00
"url=\"https://raw.githubusercontent.com/gsi-upm/sitc/master/ml2/data-titanic/train.csv\"\n",
2016-03-28 12:03:08 +00:00
"df = pd.read_csv(url)\n",
"df_original = df.copy() # Copy to have a version of df without modifications\n",
"df.head()"
]
},
{
"cell_type": "code",
2016-04-05 14:42:37 +00:00
"execution_count": 12,
2016-03-28 12:03:08 +00:00
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>PassengerId</th>\n",
" <th>Survived</th>\n",
" <th>Pclass</th>\n",
" <th>Name</th>\n",
" <th>Sex</th>\n",
" <th>Age</th>\n",
" <th>SibSp</th>\n",
" <th>Parch</th>\n",
" <th>Fare</th>\n",
" <th>Embarked</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>Braund, Mr. Owen Harris</td>\n",
" <td>0</td>\n",
" <td>22.0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>7.2500</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>Cumings, Mrs. John Bradley (Florence Briggs Th...</td>\n",
" <td>1</td>\n",
" <td>38.0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>71.2833</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>3</td>\n",
" <td>1</td>\n",
" <td>3</td>\n",
" <td>Heikkinen, Miss. Laina</td>\n",
" <td>1</td>\n",
" <td>26.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>7.9250</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>4</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>Futrelle, Mrs. Jacques Heath (Lily May Peel)</td>\n",
" <td>1</td>\n",
" <td>35.0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>53.1000</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>Allen, Mr. William Henry</td>\n",
" <td>0</td>\n",
" <td>35.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>8.0500</td>\n",
" <td>0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" PassengerId Survived Pclass \\\n",
"0 1 0 3 \n",
"1 2 1 1 \n",
"2 3 1 3 \n",
"3 4 1 1 \n",
"4 5 0 3 \n",
"\n",
" Name Sex Age SibSp Parch \\\n",
"0 Braund, Mr. Owen Harris 0 22.0 1 0 \n",
"1 Cumings, Mrs. John Bradley (Florence Briggs Th... 1 38.0 1 0 \n",
"2 Heikkinen, Miss. Laina 1 26.0 0 0 \n",
"3 Futrelle, Mrs. Jacques Heath (Lily May Peel) 1 35.0 1 0 \n",
"4 Allen, Mr. William Henry 0 35.0 0 0 \n",
"\n",
" Fare Embarked \n",
"0 7.2500 0 \n",
"1 71.2833 1 \n",
"2 7.9250 0 \n",
"3 53.1000 0 \n",
"4 8.0500 0 "
]
},
2016-04-05 14:42:37 +00:00
"execution_count": 12,
2016-03-28 12:03:08 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Cleaning\n",
"df_clean = df.copy() # We copy to see what happens with na values\n",
"df_clean['Age'] = df['Age'].fillna(df['Age'].median())\n",
"df_clean.loc[df[\"Sex\"] == \"male\", \"Sex\"] = 0\n",
"df_clean.loc[df[\"Sex\"] == \"female\", \"Sex\"] = 1\n",
"df_clean.drop(['Cabin', 'Ticket'], axis=1, inplace=True)\n",
"df_clean.loc[df[\"Embarked\"] == \"S\", \"Embarked\"] = 0\n",
"df_clean.loc[df[\"Embarked\"] == \"C\", \"Embarked\"] = 1\n",
"df_clean.loc[df[\"Embarked\"] == \"Q\", \"Embarked\"] = 2\n",
"df_clean.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# General exploration"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In the previous session we saw that *Seaborn* provides several facilities for working with DataFrames. We are going to review some of them."
]
},
{
"cell_type": "code",
2016-03-29 10:48:56 +00:00
"execution_count": 5,
2016-03-28 12:03:08 +00:00
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>PassengerId</th>\n",
" <th>Survived</th>\n",
" <th>Pclass</th>\n",
" <th>Age</th>\n",
" <th>SibSp</th>\n",
" <th>Parch</th>\n",
" <th>Fare</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>count</th>\n",
" <td>891.000000</td>\n",
" <td>891.000000</td>\n",
" <td>891.000000</td>\n",
" <td>714.000000</td>\n",
" <td>891.000000</td>\n",
" <td>891.000000</td>\n",
" <td>891.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>mean</th>\n",
" <td>446.000000</td>\n",
" <td>0.383838</td>\n",
" <td>2.308642</td>\n",
" <td>29.699118</td>\n",
" <td>0.523008</td>\n",
" <td>0.381594</td>\n",
" <td>32.204208</td>\n",
" </tr>\n",
" <tr>\n",
" <th>std</th>\n",
" <td>257.353842</td>\n",
" <td>0.486592</td>\n",
" <td>0.836071</td>\n",
" <td>14.526497</td>\n",
" <td>1.102743</td>\n",
" <td>0.806057</td>\n",
" <td>49.693429</td>\n",
" </tr>\n",
" <tr>\n",
" <th>min</th>\n",
" <td>1.000000</td>\n",
" <td>0.000000</td>\n",
" <td>1.000000</td>\n",
" <td>0.420000</td>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>25%</th>\n",
" <td>223.500000</td>\n",
" <td>0.000000</td>\n",
" <td>2.000000</td>\n",
" <td>20.125000</td>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" <td>7.910400</td>\n",
" </tr>\n",
" <tr>\n",
" <th>50%</th>\n",
" <td>446.000000</td>\n",
" <td>0.000000</td>\n",
" <td>3.000000</td>\n",
" <td>28.000000</td>\n",
" <td>0.000000</td>\n",
" <td>0.000000</td>\n",
" <td>14.454200</td>\n",
" </tr>\n",
" <tr>\n",
" <th>75%</th>\n",
" <td>668.500000</td>\n",
" <td>1.000000</td>\n",
" <td>3.000000</td>\n",
" <td>38.000000</td>\n",
" <td>1.000000</td>\n",
" <td>0.000000</td>\n",
" <td>31.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>max</th>\n",
" <td>891.000000</td>\n",
" <td>1.000000</td>\n",
" <td>3.000000</td>\n",
" <td>80.000000</td>\n",
" <td>8.000000</td>\n",
" <td>6.000000</td>\n",
" <td>512.329200</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" PassengerId Survived Pclass Age SibSp \\\n",
"count 891.000000 891.000000 891.000000 714.000000 891.000000 \n",
"mean 446.000000 0.383838 2.308642 29.699118 0.523008 \n",
"std 257.353842 0.486592 0.836071 14.526497 1.102743 \n",
"min 1.000000 0.000000 1.000000 0.420000 0.000000 \n",
"25% 223.500000 0.000000 2.000000 20.125000 0.000000 \n",
"50% 446.000000 0.000000 3.000000 28.000000 0.000000 \n",
"75% 668.500000 1.000000 3.000000 38.000000 1.000000 \n",
"max 891.000000 1.000000 3.000000 80.000000 8.000000 \n",
"\n",
" Parch Fare \n",
"count 891.000000 891.000000 \n",
"mean 0.381594 32.204208 \n",
"std 0.806057 49.693429 \n",
"min 0.000000 0.000000 \n",
"25% 0.000000 7.910400 \n",
"50% 0.000000 14.454200 \n",
"75% 0.000000 31.000000 \n",
"max 6.000000 512.329200 "
]
},
2016-03-29 10:48:56 +00:00
"execution_count": 5,
2016-03-28 12:03:08 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# General description of the dataset\n",
"df.describe()"
]
},
{
"cell_type": "code",
2016-03-29 10:48:56 +00:00
"execution_count": 6,
2016-03-28 12:03:08 +00:00
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"PassengerId int64\n",
"Survived int64\n",
"Pclass int64\n",
"Name object\n",
"Sex object\n",
"Age float64\n",
"SibSp int64\n",
"Parch int64\n",
"Ticket object\n",
"Fare float64\n",
"Cabin object\n",
"Embarked object\n",
"dtype: object"
]
},
2016-03-29 10:48:56 +00:00
"execution_count": 6,
2016-03-28 12:03:08 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Column types\n",
"df.dtypes"
]
},
{
"cell_type": "code",
2016-03-29 10:48:56 +00:00
"execution_count": 7,
2016-03-28 12:03:08 +00:00
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"Name object\n",
"Sex object\n",
"Ticket object\n",
"Cabin object\n",
"Embarked object\n",
"dtype: object"
]
},
2016-03-29 10:48:56 +00:00
"execution_count": 7,
2016-03-28 12:03:08 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Columns non numeric\n",
"df.dtypes[df.dtypes == object]"
]
},
{
"cell_type": "code",
2016-03-29 10:48:56 +00:00
"execution_count": 8,
2016-03-28 12:03:08 +00:00
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"PassengerId 0\n",
"Survived 0\n",
"Pclass 0\n",
"Name 0\n",
"Sex 0\n",
"Age 177\n",
"SibSp 0\n",
"Parch 0\n",
"Ticket 0\n",
"Fare 0\n",
"Cabin 687\n",
"Embarked 2\n",
"dtype: int64"
]
},
2016-03-29 10:48:56 +00:00
"execution_count": 8,
2016-03-28 12:03:08 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Number of null values\n",
"df.isnull().sum()"
]
},
{
"cell_type": "code",
2016-04-05 14:42:37 +00:00
"execution_count": 14,
2016-03-28 12:03:08 +00:00
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
2016-04-05 14:42:37 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlUAAAJbCA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wOHA6Wzepflw4CyAiPgW\ngKSDgHtK+zRJugPYH7ih4DKbjRudXTOYMLH6RlX/pvUNLI2ZmW1LNXv/9QP9ksoPvwJ4n6QLgWeA\nT5M2y1xR9p5ngZzL3JqNHZLmAceWHXoL8Frge6S4xaeBYyNig4fIzczaV95A9Q7gwYg4EHgA+BKb\ne7HK32PW9iJiYUQcmNWHs0nxhucBl0TEAcDDwDxJXaQh8oOBucCpkrpHqdhmZlawvEsqLAd+mT3+\nGXAucCOpt6pkD+DObSXS0zM1Z/b1pdfXN7pBvN3dXXVde5G/t9H6GzQ7rSY6CziG9Nmfnx1bDHwB\nCDxEbuNU1kv7RWATqZ7cD1yFe3OtjdTSqOpgc+/TTcB7gctJQx0PAncD35Y0HegHZgOf21aCK1as\nrrG4w+vpmVp1ekNXOG+23t61ua+9lutsZlpFp1d0Ws0gaT/giYhYLqkrIjZmL60gDYV7iNzGJUkz\nSA2pNwFTSTfiR5F6cxdJuoDUm3sVnvBkY1g1s//eDnwL2AXYJGk+8B7gHySdSFpS4fiIWCfpdFLP\n1SBwTumO3GycOIl0ozHUcEPhDRkinzZth1wNyWY1PpuRTztdSzPzaaBDgCURsRZYC8yX9CjuzbU2\nU02g+l3AGyq8dHSF9y4CFhVQLrOxaA7wmezxGknbR8R6YHdgWfZT0xB5Hn19L9bcy1d0r+Vo5tNO\n19LsfBpoL2CKpOuAblJPlXtzre14mxqzAkiaBayJiE3ZoSWk4Y2rgSNJQ+Y1D5GbtYkJwM7AB0mz\nx28b8npTe3PNGsWNKrN
2016-03-28 12:03:08 +00:00
"text/plain": [
2016-04-05 14:42:37 +00:00
"<matplotlib.figure.Figure at 0x7f386155ca58>"
2016-03-28 12:03:08 +00:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Analise distributon\n",
2016-04-05 14:42:37 +00:00
"df.hist(figsize=(10,10))\n",
"plt.show()"
2016-03-28 12:03:08 +00:00
]
},
{
"cell_type": "code",
2016-03-29 10:48:56 +00:00
"execution_count": 10,
2016-03-28 12:03:08 +00:00
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>PassengerId</th>\n",
" <th>Survived</th>\n",
" <th>Pclass</th>\n",
" <th>Age</th>\n",
" <th>SibSp</th>\n",
" <th>Parch</th>\n",
" <th>Fare</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>PassengerId</th>\n",
" <td>1.000000</td>\n",
" <td>-0.005007</td>\n",
" <td>-0.035144</td>\n",
" <td>0.036847</td>\n",
" <td>-0.057527</td>\n",
" <td>-0.001652</td>\n",
" <td>0.012658</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Survived</th>\n",
" <td>-0.005007</td>\n",
" <td>1.000000</td>\n",
" <td>-0.338481</td>\n",
" <td>-0.077221</td>\n",
" <td>-0.035322</td>\n",
" <td>0.081629</td>\n",
" <td>0.257307</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Pclass</th>\n",
" <td>-0.035144</td>\n",
" <td>-0.338481</td>\n",
" <td>1.000000</td>\n",
" <td>-0.369226</td>\n",
" <td>0.083081</td>\n",
" <td>0.018443</td>\n",
" <td>-0.549500</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Age</th>\n",
" <td>0.036847</td>\n",
" <td>-0.077221</td>\n",
" <td>-0.369226</td>\n",
" <td>1.000000</td>\n",
" <td>-0.308247</td>\n",
" <td>-0.189119</td>\n",
" <td>0.096067</td>\n",
" </tr>\n",
" <tr>\n",
" <th>SibSp</th>\n",
" <td>-0.057527</td>\n",
" <td>-0.035322</td>\n",
" <td>0.083081</td>\n",
" <td>-0.308247</td>\n",
" <td>1.000000</td>\n",
" <td>0.414838</td>\n",
" <td>0.159651</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Parch</th>\n",
" <td>-0.001652</td>\n",
" <td>0.081629</td>\n",
" <td>0.018443</td>\n",
" <td>-0.189119</td>\n",
" <td>0.414838</td>\n",
" <td>1.000000</td>\n",
" <td>0.216225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Fare</th>\n",
" <td>0.012658</td>\n",
" <td>0.257307</td>\n",
" <td>-0.549500</td>\n",
" <td>0.096067</td>\n",
" <td>0.159651</td>\n",
" <td>0.216225</td>\n",
" <td>1.000000</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" PassengerId Survived Pclass Age SibSp Parch \\\n",
"PassengerId 1.000000 -0.005007 -0.035144 0.036847 -0.057527 -0.001652 \n",
"Survived -0.005007 1.000000 -0.338481 -0.077221 -0.035322 0.081629 \n",
"Pclass -0.035144 -0.338481 1.000000 -0.369226 0.083081 0.018443 \n",
"Age 0.036847 -0.077221 -0.369226 1.000000 -0.308247 -0.189119 \n",
"SibSp -0.057527 -0.035322 0.083081 -0.308247 1.000000 0.414838 \n",
"Parch -0.001652 0.081629 0.018443 -0.189119 0.414838 1.000000 \n",
"Fare 0.012658 0.257307 -0.549500 0.096067 0.159651 0.216225 \n",
"\n",
" Fare \n",
"PassengerId 0.012658 \n",
"Survived 0.257307 \n",
"Pclass -0.549500 \n",
"Age 0.096067 \n",
"SibSp 0.159651 \n",
"Parch 0.216225 \n",
"Fare 1.000000 "
]
},
2016-03-29 10:48:56 +00:00
"execution_count": 10,
2016-03-28 12:03:08 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# We can see the pairwise correlation between variables. A value near 0 means low correlation\n",
"# while a value near -1 or 1 indicates strong correlation.\n",
"df.corr()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We do not find any relevant correlation. We could also represent this with a scatterplot."
]
},
{
"cell_type": "code",
2016-03-29 10:48:56 +00:00
"execution_count": 11,
2016-03-28 12:03:08 +00:00
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
2016-03-29 10:48:56 +00:00
"<seaborn.axisgrid.PairGrid at 0x7fd12b267ef0>"
2016-03-28 12:03:08 +00:00
]
},
2016-03-29 10:48:56 +00:00
"execution_count": 11,
2016-03-28 12:03:08 +00:00
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
2016-03-29 10:48:56 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAABocAAAZNCAYAAAAH8YihAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3XmcW2d58P3fOdKRRiPN7vGSxIkdxyMvITbJk+RtAgR4\neAhbaVw+hRQIT8v6pEBfulB46PK87adAKRRouqS00AAGSkp5kk8/QEgoaRNCWExix5nY1tiOx1vs\nGc+i0TpHRzrn/UOj5ZzRaGY00kg6c33/SW5ZOrqlOTrLfd33dSmWZSGEEEIIIYQQQgghhBBCCCHW\nBrXZHRBCCCGEEEIIIYQQQgghhBCrR4JDQgghhBBCCCGEEEIIIYQQa4gEh4QQQgghhBBCCCGEEEII\nIdYQCQ4JIYQQQgghhBBCCCGEEEKsIRIcEkIIIYQQQgghhBBCCCGEWEMkOCSEEEIIIYQQQgghhBBC\nCLGGeFfjTcLh8M3AX0QikVeEw+FtwJcBExiORCLvn3vOe4D3Agbw8Ugk8t1wONwBfA1YD8SA/xmJ\nRCZXo89CCCGEEEIIIYQQQgghhBBu1PCVQ+Fw+MPAPwH+uYc+C3wsEoncBqjhcPhXwuHwBuCDwC8B\nrwE+GQ6HNeBu4HAkEnkZsB/440b3VwghhBBCCCGEEEIIIYQQws1WI63cCWBfWfuGSCTyo7n/fwj4\nH8BNwBORSCQbiURiwHFgD/AS4Ptlz33VKvRXCCGEEEIIIYQQQgghhBDCtRoeHIpEIg8A2bKHlLL/\njwPdQBcwU/Z4AuhxPF54rhBCCCGEEEIIIYQQQgghhKjRqtQccjDL/r8LiJKvJ9TteHx67vEux3Or\nsizLUhRlsacJUYuG71iy/4oGkX1XtDPZf0U7k/1XtCvZd0U7k/1XtDPZf0U7a+iOJfuuaK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 12:03:08 +00:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# General description of relationship betweek variables uwing Seaborn PairGrid\n",
"# We use df_clean, since the null values of df would gives us an error, you can check it.\n",
"g = sns.PairGrid(df_clean, hue=\"Survived\")\n",
"g.map_diag(plt.hist)\n",
"g.map_offdiag(plt.scatter)\n",
"g.add_legend()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"There are two many variables, we are going to represent only a subset."
]
},
{
"cell_type": "code",
2016-03-29 10:48:56 +00:00
"execution_count": 12,
2016-03-28 12:03:08 +00:00
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
2016-03-29 10:48:56 +00:00
"<seaborn.axisgrid.PairGrid at 0x7fd128874ac8>"
2016-03-28 12:03:08 +00:00
]
},
2016-03-29 10:48:56 +00:00
"execution_count": 12,
2016-03-28 12:03:08 +00:00
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
2016-03-29 10:48:56 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAkoAAAIVCAYAAAAu+9C7AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3XucZFV56P3fru6enp7unisNGAkXwVmKRDGQYAiCevTg\njQOTc07QCDleiIrkYkzwlSQmMe8xGjnyJiZqVAQToh6MZmIUNRyDCmKOeAGBAGu4KypMMzM93dM9\nfa39/lFVM9U1vftetXv3/L6fDx967bXrWc++dPUze6/alaRpiiRJkg5VyjsBSZKklcpCSZIkKYOF\nkiRJUgYLJUmSpAwWSpIkSRkslCRJkjK05zFoCKEEfAwIQBl4c4zxnrr+twKXADuri94UY7y/5YlK\nkqTDWi6FEnAekMYYzwohnAP8OXBBXf9pwMUxxttzyU6SJImcbr3FGD8PvLHaPB7Y07DKacAVIYRb\nQgjvaGVukiRJNbnNUYoxlkMInwD+CvhkQ/engTcDLwTOCiG8vMXpSZIkkeT9FSYhhCOB24Bnxhj3\nV5etjzEOVn++FNg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2efpSDtJ1xRJkh5YDpBO\nlCApk8zwly9NK8fs4AIggbScMHbPL1ZyO/k2klJaWa8MaQJpGZhqp9RWpi3tZOr+5zJ15EOUuoZI\n1g5Xxi+XGL3nF2C8m/YT7qbUuxuAY7uPZeddgZHhhDRNaUugvaONpx2zlnUn3sfAxABbujbzqq3b\nYLKD627cQf/Afvo2drHt7BPYfvPDB9oXn7uVnq41iz00msVSb71dDfwF8FrgA1SuEH1/thfEGEcA\nQgi9VAqmP6zrXg/srWs
2016-03-28 12:03:08 +00:00
"text/plain": [
2016-03-29 10:48:56 +00:00
"<matplotlib.figure.Figure at 0x7fd128874208>"
2016-03-28 12:03:08 +00:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# PairGrid of variables\n",
"g = sns.PairGrid(df_clean, hue=\"Survived\", vars=['Pclass', 'Sex', 'Age'])\n",
"g.map_diag(plt.hist)\n",
"g.map_offdiag(plt.scatter)\n",
"g.add_legend()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can observe, for example, that more women survived as well as more people in 3rd class. \n",
"\n",
"We can represent these findings."
]
},
{
"cell_type": "code",
2016-03-29 10:48:56 +00:00
"execution_count": 13,
2016-03-28 12:03:08 +00:00
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
2016-03-29 10:48:56 +00:00
"<matplotlib.axes._subplots.AxesSubplot at 0x7fd126d16b70>"
2016-03-28 12:03:08 +00:00
]
},
2016-03-29 10:48:56 +00:00
"execution_count": 13,
2016-03-28 12:03:08 +00:00
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
2016-03-29 10:48:56 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYEAAAERCAYAAACdPxtnAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAG/1JREFUeJzt3Xt8VOW97/HPJAEScsGAsed4NKFS+Hmtr1oV8eVu1ep2\neztSrbtI1YqyqXipivYcr/XSC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yOxf/xo35+/1TVdX9Lydhh8BC4EQzW5Zq\nTzCzc4BSd59rZnOApWa2FVgJPBpyPSIikibUEHD3BDC5y8vvpG2fDcwOswYREemeJpATEYkwhYCI\nSIQpBEREIkwhICISYQoBEZEIUwiIiESYQkBEJMIUAiIiEaYQEBGJMIWAiEiEKQRERCJMISAiEmEK\nARGRCFMIiIhEmEJARCTCFAIiIhGmEBARiTCFgIhIhCkEREQiTCEgIhJhCgERkQhTCIiIRJhCQEQk\nwhQCIiIRphAQEYkwhYCISIQVBXmTmZUBxwEjgXbgPeB5d28JsTYREQnZLkPAzAYDNwNnAm8BHwJx\n4GjgHjN7EviBuzeGXaiIiGReT2cCjwNzgOvcvT19g5kVAKel3jM2nPJERCRMPYXAWe6e2NmGVCj8\n1syeynxZIiKSDT2FwE1m1u1Gd7+tu5AQEZG+r6e7g2Kpf0YDZ5EcFN4GnAocFG5pIiIStl2eCbj7\nrQBmtgwY4+5bUu0ZwIvhlyciImEK+pxAFZB+2WcAMDTz5YiISDYFek4AeAh43cyeIRkcpwEzQqtK\nRESyItCZgLvfCZwPfAK
2016-03-28 12:03:08 +00:00
"text/plain": [
2016-03-29 10:48:56 +00:00
"<matplotlib.figure.Figure at 0x7fd1296c7dd8>"
2016-03-28 12:03:08 +00:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.barplot(x=\"Pclass\", y='Survived', hue='Sex', data=df)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can see that more women survived in all the passenger classes."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we are going to put in practice our knowledge about munging and visualisation. We will analyse every feature of the dataset."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Feature Age"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We saw that there are 177 missing values of age. We are going this feature with more detail."
]
},
{
"cell_type": "code",
2016-03-29 10:48:56 +00:00
"execution_count": 14,
2016-03-28 12:03:08 +00:00
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
2016-03-29 10:48:56 +00:00
"<matplotlib.axes._subplots.AxesSubplot at 0x7fd126d55588>"
2016-03-28 12:03:08 +00:00
]
},
2016-03-29 10:48:56 +00:00
"execution_count": 14,
2016-03-28 12:03:08 +00:00
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
2016-03-29 10:48:56 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAECCAYAAADw0Rw8AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFEVJREFUeJzt3X+M3PV95/Hneu01aDN2VmZiqXJxuFZ9c5WO9EgFBwk2\nRHCBkJYinRSp4lrSq6NGFknLhTviiqinxgG1wU1p1PRknIP0Jy2qe20QSZOQgk3US0g4qb7QN0ZN\nyZlIZOOM2fVSYpbd+2PGYcI57Mx3vrMz++H5kCzN9zvf/cxL4++89rvf+f6YWF5eRpJUrnWjDiBJ\nGi6LXpIKZ9FLUuEsekkqnEUvSYWz6CWpcOt7WSgiLgbuyMwrIuKngE8ALwJPZuYvd5bZBbynM39v\nZj4wpMySpD6suEUfEbcA+4GNnVkfAn4jM3cAZ0XEtRGxFbgJuAS4Grg9IjYMKbMkqQ+97Lp5Cri+\na/px4JyImAAatLfgLwIOZ+ZiZs4BR4EL6g4rSerfikWfmQeBxa5ZR4G7gP8DvAH4O2AT8FzXMieB\nzbWllCRVVuXL2N8F3pKZPwn8IbCPdslv6lqmAZwYPJ4kaVA9fRn7CseB+c7jbwGXAl8B9kbEFHA2\ncD5wZKWBlpeXlycmJipEkKTXtL6Ks0rR7wLui4gXgVPArsx8NiLuAg53AuzJzFMrJp2YYHZ2fqXF\nRq7ZbJizRmsh51rICOas21rK2Y+eij4zn6a95U5mPgq89QzLHAAO9PXq+r6XXnqJY8e+OdAYc3PT\ntFoLA2fZtu1cJicnBx5H0nioskWvITh27Jv8530PMDW9ZaQ5Ti0c586br2X79vNGmkNSfSz6MTI1\nvYWzNm0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00
"text/plain": [
2016-03-29 10:48:56 +00:00
"<matplotlib.figure.Figure at 0x7fd1283f3198>"
2016-03-28 12:03:08 +00:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Histogram of Age\n",
"# For Series, you can use hist(), plot.hist() or plot(kind='hist')\n",
"df['Age'].hist()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We see the histogram is slightly *right skewed* (*sesgada a la derecha*), so we will replace null values with the median instead of the mean.\n",
"\n",
"In case we have a significant *skewed distribution*, the extreme values in the long tail can have a disproportionately large influence on our model. So, it can be good to transform the variable before building our model to reduce skewness.Taking the natural logarithm or the square root of each point are two simple transformations. "
]
},
{
"cell_type": "code",
2016-03-29 10:48:56 +00:00
"execution_count": 15,
2016-03-28 12:03:08 +00:00
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
2016-03-29 10:48:56 +00:00
"<matplotlib.axes._subplots.AxesSubplot at 0x7fd126bbcf60>"
2016-03-28 12:03:08 +00:00
]
},
2016-03-29 10:48:56 +00:00
"execution_count": 15,
2016-03-28 12:03:08 +00:00
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
2016-03-29 10:48:56 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXUAAAECCAYAAAAB2kexAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAE/JJREFUeJzt3W+MXfdd5/H3eOxpu7cTY7m30XZN3GxKvxLSbqQUBJTG\ndqJUxYTWgBA8CSLtblErSwHSsmpdpUKqqKpt462goqySpk7RVpRGLUFEboAaJS5IQENAWHW/aUqp\nNeYBgxkz48k2dmZmH9zr5jZr+55z556Zc3/zfkmR5t5zfO4n989nzvzuOb8ztba2hiSpDNs2O4Ak\naXwsdUkqiKUuSQWx1CWpIJa6JBXEUpekgmwftkJEbAceBl4LvAC8E1gBjgGrwKnMPNxcRElSVVX2\n1H8SmM7MHwc+BHwYOAocycz9wLaIONRgRklSRVVK/R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fXvAb4OPBgRO4DTwCO1H1mSNHZDSz0znwN+4QqLDow9jSRpXTz5SJIKYqlLUkEsdUkq\niKUuSQWx1CWpIJa6JBXEa5RKFa2trXL27Fzl9ffsuYHp6ekGE0n/P0tdquji8gJHP7fATGd4sV9c\nPsf9997J3r03bkAy6UWWulTDTGc3L7/u+s2OIV2Vpa7i1BkmqTOc0pSVlRXm5s4MXW9xscPCwrLD\nOromS13FqTNMcmH+WV7Zfd0GpLq6ubkzvOfoY8x0dg9d12EdDWOpq0hVh0mev3BuA9IM57COxmVD\nSv0rf/k3fC2/VWnd61/1Kt74oz/ccCJJKtOGlPqjJ/6ery90K637n3acttQlaUSefCRJBbHUJakg\nlrokFcRSl6SCWOqSVBB
2016-03-28 12:03:08 +00:00
"text/plain": [
2016-03-29 10:48:56 +00:00
"<matplotlib.figure.Figure at 0x7fd126bca358>"
2016-03-28 12:03:08 +00:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# We see with more bins the distribution\n",
"df['Age'].hist(bins=30, range=(0, df['Age'].max()))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we analyse the relationship of Age and Survived."
]
},
{
"cell_type": "code",
2016-03-29 10:48:56 +00:00
"execution_count": 16,
2016-03-28 12:03:08 +00:00
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
2016-03-29 10:48:56 +00:00
"<seaborn.axisgrid.FacetGrid at 0x7fd126b0f358>"
2016-03-28 12:03:08 +00:00
]
},
2016-03-29 10:48:56 +00:00
"execution_count": 16,
2016-03-28 12:03:08 +00:00
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
2016-03-29 10:48:56 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAY0AAAFhCAYAAACMIfYoAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3Xl4XPWd7/n3qVVbaS/tkmVb8s+yDd5YjAFDDAkhQCAr\nCVlu0uG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QMSGiIqHWG+zNK8hceGp2j3fyvgz/EMzXMFvcVvLf6FipdZQC0ett5oeUV3u45TFqhB6N9C/rs\nINfUFcekfiHE4kmfhohaZORUyQJbGl2jPfzTOz/AMzXMB2vu5D9f8alzgQFQ6Srnsxvv4/1r3suE\nOYKzbh9HzrbFpHYhRGxIaIioReZolOZnzvtYX8DHj4//nFHfGPepD3FL1a4Z9zMMg9uqd/PBtXdh\n2H0c8b9I0AzOuK8QYulJaIiodYdDozh//iOnftv0LO0jnVxfdi3Xl1875/67q24gY6KCQHofT59+\ncd7XE0LEh4SGiFrv0ATZmQ7SHPPrCjs10MDLrXsozijiQ7V3RXWMYRhc43o35pST51v/SMdI10JK\nFkLEmISGiEowaNI/PIE7N21+x5lBftPwFAYGn9n4MZzW6EdCbawsZurMRkxMnm5+fr4lCyHiQEJD\nRGXAO0EgaM57Ut/+roN0jHZxTck2qlwV8zp2TVk2eIqwTxVwuPcYLcOt8zpeCBF7EhoiKr1DEwC4\nc6IPDV/Qz9PNz2MzrNyx+j3zvmaaw0ZlkYvx5rUAPNX0h3mfQwgRWxIaIiq9Q+MAFM7j8dSe9rcY\nmBhkV8VOCtLzFnTd2oo
2016-03-28 12:03:08 +00:00
"text/plain": [
2016-03-29 10:48:56 +00:00
"<matplotlib.figure.Figure at 0x7fd126b0f240>"
2016-03-28 12:03:08 +00:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Now we visualise age and survived to see if there is some relationship\n",
"sns.FacetGrid(df, hue=\"Survived\", size=5).map(sns.kdeplot, \"Age\").add_legend()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We do no observe significant differences."
]
},
{
"cell_type": "code",
2016-03-29 10:48:56 +00:00
"execution_count": 17,
2016-03-28 12:03:08 +00:00
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
2016-03-29 10:48:56 +00:00
"<seaborn.axisgrid.FacetGrid at 0x7fd126a7d748>"
2016-03-28 12:03:08 +00:00
]
},
2016-03-29 10:48:56 +00:00
"execution_count": 17,
2016-03-28 12:03:08 +00:00
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
2016-03-29 10:48:56 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAagAAADSCAYAAAAffFTTAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFj5JREFUeJzt3X2QXXWZ4PFv541lmk4IpqFAJOqsPlM6pbMwvsAICRaM\nYDmiNdayM8NoXEfASYnjFijE9W0UR0dkXMYVlZclOgirlKglC+4oSoLryogwY9bMQyh5C751TGJ3\nEqCT7t4/zs3k0nTo2+ee23363u+nKlX3nnPv00/OPb96zvmd8/udvomJCSRJqpsFc52AJElTsUBJ\nkmrJAiVJqiULlCSplixQkqRaskBJkmpp0Vwn0Gsi4g3AxRTbvg/4QmZeVkHc84CJzPxcm3G+A7w/\nMzeU+O6zgH8ABoEE/iwz97STj3pLN7ePphh/DezLzL9uJ5de4BnULIqIY4DLgNMy8/eAE4GzI+I1\n7cbOzM+22/gq8GngU5n5AuBu4H1znI/mkW5vHxGxNCKuBv7LXOYxn3gGNbtWUGzzw4CdmbknIt4E\nPA4QEQ8AqzLz4YhYBXwgM09tHLVtB14AXA8clZlvb3zn48CjwLLG39gOPH+K9VcB/x14IbAQ+Fhm\n/s+IWAJcDZwAPAQ8Y3LSEfE64P1A86juzMw/afrMIuAU4KzGouuAOyiOhqVWdG37aDgLuA/4RNkN\n1GssULMoM/8lIr4O/DQi7gG+A3wxM3/a+MjkaT2a3/9zZv5xRAwCd0fEBZk5AbwBeDlwfuPzNwI/\nmmL9fwV+mJlrImIA+D8R8QPgjym6Pl4YEf8e+Jcp8v4q8NVp/nsrgN9k5njj/c+BZ06/VaRCl7cP\nMvMLABHx/ta2iOzim2WZ+ZfASorusJXA9xtHYFD0uR/MDxrfHwLuBU6NiJOLRfnLpvhDwD1TrD8N\nOL/R8DcAh1IcLa4GvtT47v3A9yb/4Yh4XUTcM+nfDZ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": {},
"output_type": "display_data"
}
],
"source": [
"# We plot the histogram per age\n",
"g = sns.FacetGrid(df, col='Survived')\n",
"g.map(plt.hist, \"Age\", color=\"steelblue\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We observe that non survived is left skewed. Most children survived."
]
},
{
"cell_type": "code",
2016-03-29 10:48:56 +00:00
"execution_count": 18,
2016-03-28 12:03:08 +00:00
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
2016-03-29 10:48:56 +00:00
"array([<matplotlib.axes._subplots.AxesSubplot object at 0x7fd126a9b9e8>,\n",
" <matplotlib.axes._subplots.AxesSubplot object at 0x7fd126974a90>], dtype=object)"
2016-03-28 12:03:08 +00:00
]
},
2016-03-29 10:48:56 +00:00
"execution_count": 18,
2016-03-28 12:03:08 +00:00
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
2016-03-29 10:48:56 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYQAAAEFCAYAAADjUZCuAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFARJREFUeJzt3WuUXXV5x/HvZJIBOkxCjCMujUQQ+9DWhS60XlAJsqAK\nVFPa1fqiLosXbCvVqmgLuLQXi1or0dJWXOUi2uUFpUWQLLwRC8FltSpV0tIHKEIYrGWMEyYzXIbM\nTF+cHRxCwpy9Z59rvp83mX3O7Oc8Z5/9z2/Ovg7Mz88jSdKyTjcgSeoOBoIkCTAQJEkFA0GSBBgI\nkqSCgSBJAmB5pxvQ44uIU4H3A0PAD4E3ZOZUZ7uSOiciPgHcnJkbO91Lv/EbQheLiCcClwKnZeYv\nAT8C/rqzXUmdERFHRcR1wG93upd+ZSB0t18DvpOZdxTTFwK/28F+pE46k8YfSJ/vdCP9ykDobk8D\n7l4wPQaMRMTBHepH6pjMfEtmfhoY6HQv/cpA6G77+nxm29qFpP2CgdDdtgFPWTC9FpjIzAc61I+k\nPmYgdLevAi+IiGcU078PXNXBfiT1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NLCY4yOjixaa7FLP/S6iYnpppZnM8uqWd1Y\nq1dDpRPLsZfHRF3rSretv62o1aw6z1R+J3BRRKwAbgGuqLG2FrG36x/ty57XRfIaSJKghkDIzBMW\nTB6/1Hqqpsr1jxrzeQ0kSQ1ey6iPeP0jSUvhmcqSJMBvCFLX+PwXN/HwrrlK8x73wmN42tqn1tyR\n9jcGgtQlNn//HmZ+4chK8w4f+EMDQUvmJiNJEmAgSJIKBoIkCTAQJEkFA0GSBBgIkqSCgSBJAgwE\nSVLBQJAkAQaCJKlgIEi
2016-03-28 12:03:08 +00:00
"text/plain": [
2016-03-29 10:48:56 +00:00
"<matplotlib.figure.Figure at 0x7fd127eceb00>"
2016-03-28 12:03:08 +00:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"#Alternative to Seaborn with matplotlib integrated in pandas\n",
"df.hist(column='Age', by='Survived', sharey=True)"
]
},
{
"cell_type": "code",
2016-03-29 10:48:56 +00:00
"execution_count": 19,
2016-03-28 12:03:08 +00:00
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
2016-03-29 10:48:56 +00:00
"array([<matplotlib.axes._subplots.AxesSubplot object at 0x7fd12688a2b0>,\n",
" <matplotlib.axes._subplots.AxesSubplot object at 0x7fd12681c9e8>], dtype=object)"
2016-03-28 12:03:08 +00:00
]
},
2016-03-29 10:48:56 +00:00
"execution_count": 19,
2016-03-28 12:03:08 +00:00
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
2016-03-29 10:48:56 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAX4AAAEFCAYAAADkP4z+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAEyRJREFUeJzt3X1wZXV9x/F3sksAQ5YN9MrUrqwI+tXWVivOYC0FFGxF\n6iCdsc60tEWxVIvKk8wIitIHO/Zh16pUqjz6h9UCQm1hKJ0pjDKOgCCt2sIXEMoSqp2wzbLZLGxg\nk/6RuzXj7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1hpIk1ccDuCSpMBa/JBXG4pekwlj8klQYi1+SCmPxS1JhLH5J\nKozFL0mFsfglqTAWvyQVxuKXpMJY/JJUGItfkgpT5bTMkvpodnaGLVseZ3j4BV2P3bDhcNasWVND\nqvLs3r2bsbEtXY978smxGtJ0x+KXVphdU9v42OfvYGj40K7GTU9tZdP5p7Bx4xE1JSvL2NgWLth8\nS9evw47xRziodVRNqTpj8Usr0NDwoRyw7rB+xyhelddh146tNaXpnNv4JakwFr8kFcbil6TCWPyS\nVBiLX5IKY/FLUmEsfkkqTEf78UfEMcAnM/ONEXEkcC0wA3w/M8+uMZ8kqccWXeOPiAuBK4D921dt\nBi7OzOOBwYg4tcZ8kqQe62RTzyPAafMuH52Zd7Z/vhU4qeepJEm1WbT4M/Mm4Pl5Vw3M+3kSOLjX\noSRJ9alyrp6ZeT+PANs6GdRqjVRYVP3M1blWa4Tt24eXdZmjo8ONfC6WqtUaYf367s+uCTA4OLD4\nL+3DQs9nU5/nJubqx1yA3s2HKsX/nYg4LjO/AZwM3N7JoPHxyQqLqlerNWKuDu3JNDExtazLnZiY\nWvC5aGIpdGJ8fJJt23Z
2016-03-28 12:03:08 +00:00
"text/plain": [
2016-03-29 10:48:56 +00:00
"<matplotlib.figure.Figure at 0x7fd1268b0d30>"
2016-03-28 12:03:08 +00:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# We can observe the detail for children\n",
"df[df.Age < 20].hist(column='Age', by='Survived', sharey=True)"
]
},
{
"cell_type": "code",
2016-03-29 10:48:56 +00:00
"execution_count": 20,
2016-03-28 12:03:08 +00:00
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
2016-03-29 10:48:56 +00:00
"0.4817073170731707"
2016-03-28 12:03:08 +00:00
]
},
2016-03-29 10:48:56 +00:00
"execution_count": 20,
2016-03-28 12:03:08 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#Mean of survival for young\n",
"df[df.Age < 20]['Survived'].mean()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"There were null values, we will recap at the end of this notebook how to manage them.\n",
"\n",
"We are going now to see the distribution of passengers younger than 20 that survived."
]
},
{
"cell_type": "code",
2016-03-29 10:48:56 +00:00
"execution_count": 21,
2016-03-28 12:03:08 +00:00
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
2016-03-29 10:48:56 +00:00
"<matplotlib.axes._subplots.AxesSubplot at 0x7fd1267abcc0>"
2016-03-28 12:03:08 +00:00
]
},
2016-03-29 10:48:56 +00:00
"execution_count": 21,
2016-03-28 12:03:08 +00:00
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
2016-03-29 10:48:56 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAW8AAAEmCAYAAACtaxGwAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFAFJREFUeJzt3Xtw1eWdx/F3LpJAjBogoIhQ6jiPbd3VFTu2SkVFrBbH\nXndsXbXVeqn3C7AVHVxwK9gWpYotaL3W6rrV9bKCSKdTd+24Hbe1di1u9/FaaFBKhECQyC1k/8hB\n0xYSODk5vzznvF8zDCfnnN/zfGfyyydPnt/ze05FR0cHkqS0VGZdgCRp9xnekpQgw1uSEmR4S1KC\nDG9JSpDhLUkJqu7uxRBCNXA38CFgAHAD8EdgIfBK7m3zY4wP92GNkqS/0G14A2cA78QYzwohNAC/\nBWYCN8UY5/Z5dZKkHeopvH8CbB9VVwJbgLHAwSGEzwGvApfHGDf0XYmSpL9UsSt3WIYQ6oEngDuA\nGuClGOOLIYRrgIYY49S+LVOS1FVPI29CCAcAjwK3xRgfCiHsHWNcl3v5MeDWntrYurW9o7q6qneV\nSlL5qdjZCz1dsBwOLAEujjE+k3t6SQjhkhjjr4EJwAs99d7S0rYbtaonjY31NDevz7oMaYc8Pwun\nsbF+p6/1NPKeBuwDTA8hXAd0AFcC3wshbAZWAucXqE5J0i7apTnv3mpuXu/WhQ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gxhjjcSGEA4F7gW3A0hjjxX1YnyRpB3oceYcQpgI/BLZv93UzcE2McTxQGUL4bB/W\nJ0nagV2ZNnkN+HyXr8f
2016-03-28 12:03:08 +00:00
"text/plain": [
2016-03-29 10:48:56 +00:00
"<matplotlib.figure.Figure at 0x7fd126a9e2b0>"
2016-03-28 12:03:08 +00:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"df.query('Age < 20 and Survived == 1').groupby(['Sex','Pclass']).size().unstack(['Pclass']).plot(kind='bar')"
]
},
{
"cell_type": "code",
2016-03-29 10:48:56 +00:00
"execution_count": 22,
2016-03-28 12:03:08 +00:00
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
2016-03-29 10:48:56 +00:00
"<matplotlib.axes._subplots.AxesSubplot at 0x7fd12672e4a8>"
2016-03-28 12:03:08 +00:00
]
},
2016-03-29 10:48:56 +00:00
"execution_count": 22,
2016-03-28 12:03:08 +00:00
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
2016-03-29 10:48:56 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAW8AAAE4CAYAAACUt3JbAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFchJREFUeJzt3XuUXWV5x/FvMmOCjIOOcRaVpkSL+nhrRbHVZakI3sVr\nL7Z2KW3RQhGrFqRVqLd6Ka0mtGpFFPFuLWjRKkXaChW1Ld6waIsPoi1hKmjAwQlJNTJJ/9gnrjFk\nMsmZfc4+75vvZy0Wc67v88xMfmfPu/e794odO3YgSSrLyq4LkCTtO8NbkgpkeEtSgQxvSSqQ4S1J\nBTK8JalA43t6MCLGgfOAewCrgNcB1wOfAK7pPe3szLxggDVKknaxx/AGng3clJnHRcQU8BXg1cD6\nzDxr4NVJknZrqfA+H9i5Vb0S+BFwBHDfiHg68A3gRZm5ZXAlSpJ2tWJvVlhGxCTwMeDtwGrgqsy8\nMiJOB6Yy87TBlilJWmjJHZYR8TPApcB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alAhrckFcjwlqQCGd6SVCDDW5IKZHhLUoEMb0kqkOEtSQUa7+dFEbECeCvw\nIOAHwPMy81ttFiZJWly/W95PB1Zn5iOAlwEb2itJkrSUfsP7SOCTAJl5BfDQ1iqSJC2p3/A+CPj+\ngtu3RYTz55I0JH3NeQNzwOSC2yszc3sL9fyEbVtubvstR2KsLsa0v7LHtL9yxxvUWCt27Nixzy+K\niF8BnpyZx0fEw4GXZ+axrVcnSdqtfre8LwQeGxGf693+3ZbqkSTthb62vCVJ3XInoyQVyPCWpAIZ\n3pJUIMNbkgpkeEtSgfo9VHCk9E6UdSzwKGAN8F3gU8A/ZWbxh9PU3F/NvS0UEQ+k119mXt11PW2z\nv+Er/lDBiDgGOAP4MvB
2016-03-28 12:03:08 +00:00
"text/plain": [
2016-03-29 10:48:56 +00:00
"<matplotlib.figure.Figure at 0x7fd12668b320>"
2016-03-28 12:03:08 +00:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Passengers older than 25 that survived grouped by Sex\n",
"\n",
"df.query('Age < 20 and Survived == 1').groupby(['Sex','Pclass']).size().plot(kind='bar')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We are going to improve it a bit."
]
},
{
"cell_type": "code",
2016-03-29 10:48:56 +00:00
"execution_count": 23,
2016-03-28 12:03:08 +00:00
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
2016-03-29 10:48:56 +00:00
"<matplotlib.axes._subplots.AxesSubplot at 0x7fd126985cc0>"
2016-03-28 12:03:08 +00:00
]
},
2016-03-29 10:48:56 +00:00
"execution_count": 23,
2016-03-28 12:03:08 +00:00
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
2016-03-29 10:48:56 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAW8AAAENCAYAAADAAORFAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAE2ZJREFUeJzt3Xtw3WWdx/F3mljaJik0JWXcKQ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s7aW5eVdI2GxreXtL2pGIwvDWoNDevYsqsOxlaO7ok7W1qW8ctl9YycuSY\nkrQnFYvhrUFnaO1oho3cq9xlSIOac96SlCHDW5IyZHhLUob6NecdEYcC01NKR0bEu4FFwJM9m2en\nlO4YqAIlSa/XZ3hHxHnAp4G/9bx0EDAzpfT1gSxMkrRt/Zk2WQoc3+v5QcAxEXF/RNwUEbUDU5ok\naVv6DO+U0gKgo9dLDwPnpZSOAJYDXx6Y0iRJ21LIdd4/SSm90PN4AXBdXweMGjWCmprqAprKR2Nj\nfblLqAjr15fnDzn7rzjK0X+7at8VEt6LI+KslNIS4Cjg0b4OaG1tL6CZfDQ21tPSsqHcZVSE1ta2\nsrRr/xVHOfqvkvtue/8xFRLeE4HrI2IT8BxweoF1SZIK1K/wTimtBA7vefwb4L0DWZQkafu8SUeS\nMmR4S1KGDG9JypDhLUkZMrwlKUOGtyRlyPCWpAwZ3pKUIcNbkjJkeEtShgxvScqQ4S1JGTK8JSlD\nhSwJO6h1dnbS3LyqpG02NLy9pO1JUsWFd3PzKqbMupOhtaNL0t6mtnXccmktI0eOKUl7kgQVGN4A\nQ2tHM2zkXuUuQ5IGjHP
2016-03-28 12:03:08 +00:00
"text/plain": [
2016-03-29 10:48:56 +00:00
"<matplotlib.figure.Figure at 0x7fd12663a0f0>"
2016-03-28 12:03:08 +00:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# We pass 'Sex' from columns to rows with unstack, so that now Pclass is in the columns\n",
"df.query('Age < 20 and Survived == 1').groupby(['Sex','Pclass']).size().unstack(['Sex']).plot(kind='bar')"
]
},
{
"cell_type": "code",
2016-03-29 10:48:56 +00:00
"execution_count": 24,
2016-03-28 12:03:08 +00:00
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
2016-03-29 10:48:56 +00:00
"<matplotlib.axes._subplots.AxesSubplot at 0x7fd126629908>"
2016-03-28 12:03:08 +00:00
]
},
2016-03-29 10:48:56 +00:00
"execution_count": 24,
2016-03-28 12:03:08 +00:00
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
2016-03-29 10:48:56 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAW8AAAENCAYAAADAAORFAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFnxJREFUeJzt3X+QXGWd7/H3ZAZMZjLABCaUt0IG5ceXtRbZTbigFmVA\n2CvIpZBF71pcRAVhiWEJErhC5LcSoiFBAhrZgGFFuQoRjBuXy1rChYhbYBBFF3z4ESAM8mNCmkyY\nISQzmfvHDNwhJtPNpHt6ns77VZWq7j6nz/l2ns6nnzznnOfU9fX1IUnKy5hqFyBJevcMb0nKkOEt\nSRkyvCUpQ4a3JGXI8JakDDWUslJETARWAkcBvcDNwGbgjymlGRWrTpK0VUV73hHRAHwX6B54aQEw\nO6U0DRgTEcdXsD5J0laUMmxyNbAI+DNQB0xJKa0YWHYX/b1xSdIIGjK8I+LzwCsppV/QH9xbvmc9\nsGtlSpMkbUuxMe8vAJsj4u+Ag4DvA62DljcDrxXbSU9Pb19DQ/2wi5SkHVTdthYMGd4D49oARMQ9\nwJnAvIj4aErpfuAY4J5iey8UuoutkrXW1mY6OtZXuwwNk+2Xr1pvu9bW5m0uK+lsky2cByyOiJ2A\nx4Glw6xLkjRMJYd3Suljg54eXv5SJEml8iIdScqQ4S1JGTK8JSlDhrckZcjwlqQMGd6SlKHhnOed\nlR/84GZWrnyInp4e6uvr+dKXZhJxQLXLkqTtUtPh/eyzz/DAA/ezaNH3AHjqqSe58spLWbLk1ipX\nJknbp6aHTcaPH8/LL7/M8uXLWLOmg3333Y/Fi7/PqlVPcfbZZ3L22Wdy0UVfobu7i1//+lfMmHE6\nfX193HTTDSxadF21y5ekbarr6+ur+E46OtZXfifb8OSTiaVLf8zKlQ8xbtw4Tj99OrfeeguzZ19K\nW9veLF++jBdf/DOnnz6dhQvns27dOjo6XuFb3/oOY8aU9ttW6/Mr1DrbL1+13natrc3D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htdtLY209LSwgc+sA8ATU2NTJ164MC2d6W5eWf226+NW265mZ/+dByvv/4648eP\np7W1mTFj6mhtbWb16mdZuHAe0D97YVtbW9GaVB22S3lU4t/yaFJKroyUUg5YngxMSinNBTbQf9Dy\njog4O6X0G+BI4OGhtlEodA+5j0Khi41dr5ZcdDEbu16lUOgqOufB2rVdbNrUy3vfuxdHHPHfOOqo\nj1MoFFi+fBkdHevp6+t7exubN29++/GmTT2sWbOeyy67gssu+zpTpx7I3LlX8/LLL9HRsf7tdffa\nq42vfOWSd8xeWMvzMOSq1ufHGEkjec51NZSSK+U01A9FKT3vO4AlEXHfwPozgeeB6yNiI/AScMb2\nFDhp0mTmn3vs9mxiq9ssRV1dHaeccipXXXUFy5bdQXd3N6ee+tbHGXzgse4d76mrq+Pooz/BRRd9\nhd13n8Buu+3OunWvvWPdWbMu+IvZCyWpHJxVsAzsueXN9iuf5557hsv/Y15Nnuf9xiuvc+mHzx/R\n60ecVVCSaozhLUkZMrwlKUOGtyRlaFRMTOWsgpL07oyK8C73NJKjbepGSSq3URHekM80knfdtZzn\nnnuWM888q9qlSNqBOeY9DHV1zhooqbpGTc+7Gu66azkPPHA/b775Jq+++iqf/vRnWLHiPp555mlm\nzJjJyy+/zP3338uGDRvYddfdmDNn3jve/5Of/Jhf/OJudt65gWnTjuTEE/+hSp9E0o5mhw5vgO7u\nN1iw4Dp++ct/57bb/jc33LCE3/52JbfddisHHPABrr12EQDnnvtP/OlPj739vmeffYZf/vIXLFp0\nE3vsMZ6TTz6FQw75MHvtVdpl+ZK0PXb48N5//wBg/Phm2tr2BqC5eRc2beqhvr6BSy+dzbhx41iz\n5hV6enreft+qVU/z0ksvMnPmdBoaxtDZuY729tWGt6QRMWrCe8PaoWcerNS2tjV+3dOziV/96j5u\nuGEJb765gdNO+yyD54GZPLmN979/H66+eiGtrc18+9s3sM8++2137ZJUilER3pMmTeaqYy8t+za3\nR319A2PHjmP69NMA2H33Vtas6Xh7+b777seUKf+V6dNPo6+vl/33/ytaWydu1z4lqVTOKlgGzkqX\nN9uvfJxVsLycVVCSaozhLUkZMrwlKUOGtyRlyPCWpAwZ3pKUoaLneUfEGGAxEMBm4EzgTeDmged/\nTCnNqGCNkqQtlNLzPg7oSykdBlwMzAEWALNTStOAMRFxfAVrlCRtoWh4p5SWAWcMPG0DCsCUlNKK\ngdfuAo6qTHmSpK0pacw7pbQ5Im4GFgK3AoOv+lkP7Fr+0iRJ21Ly3CYppc9HxETgN8C4QYuagdeG\nem9LSyMNDbV9P8nW1uZql6DtYPuVR2dnU7VLqKiWlqZR810p5YDlycCklNJcYAPQC6yMiGkppfuA\nY4B7htpGoVC+GQNHI+fGyJvtVz6FQle1S6ioQqFrRL8rQ/1QlNLzvgNYEhH3Dax/NvAn4MaI2Al4\nHFhahjolSSUqGt4ppW5ga/f3Orzs1UiSSuJFOpKUIcNbkjJkeEtShgxvScqQ4S1JGTK8JSlDhrck\nZcjwlqQMGd6SlCHDW5IyZHhLUoYMb0nKkOEtSRkyvCUpQ4a3JGXI8JakDBnekpShkm9ALI2E3t5e\n2ttXj+g+OzubRvTei5MmTaa+vrZvyK3KM7w1qrS3r+bCn1/O2AmN1S6lIjas7eaqYy+lre191S5F\nmTO8NeqMndDIuInjq12GNKoNGd4R0QB8D9gb2Bm4EngeWA48MbDaopTS7RWsUZK0hWI975OBNSml\nUyKiBfgdcDkwP6V0TcWrkyRtVbHwvg14q1c9BtgETAUOiIhPAk8CM1NKI3e0R5I09KmCKaXulFJX\nRDTTH+IXAQ8B56WUpgG
2016-03-28 12:03:08 +00:00
"text/plain": [
2016-03-29 10:48:56 +00:00
"<matplotlib.figure.Figure at 0x7fd129692d68>"
2016-03-28 12:03:08 +00:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Now we make that the plot shows both values combined, and change the labels\n",
"df.query('Age < 20 and Survived == 1').groupby(['Sex','Pclass']).size().unstack(['Sex']).plot(kind='bar', \\\n",
" \n",
" stacked=True) "
]
},
{
"cell_type": "code",
2016-03-29 10:48:56 +00:00
"execution_count": 25,
2016-03-28 12:03:08 +00:00
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
2016-03-29 10:48:56 +00:00
"<matplotlib.text.Text at 0x7fd126537be0>"
2016-03-28 12:03:08 +00:00
]
},
2016-03-29 10:48:56 +00:00
"execution_count": 25,
2016-03-28 12:03:08 +00:00
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
2016-03-29 10:48:56 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAATcAAAJoCAYAAAADEqaNAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XmcXHWZqPEn6Qayig3T4IIEBHldQRaX0QygLMqgI4zX\nYVQGQRRh2Ny4DigC47AoCC4gIigMjuggiIwwEBG4LKMiq4jgCxoVguIkUJilCSSdvn+cE2hieqt0\ndXX/8nw/Hz7p2k69VU0/fc6pqtOT+vr6kKTSTG73AJLUCsZNUpGMm6QiGTdJRTJukopk3CQVqbPd\nA+jZImIW8Bvg7vqsSfW/X8rM89szVXtExPnALzLz9HbPoonHuI1PPZm53coTEfEC4J6IuDUz72nj\nXNKEYdwmgMz8Q0Q8AGwVEXOBs4GXABsAi4D3ZOYDEfH3wCeB3vq/ozLz5kHOfw7wReCVwDrAtfVl\nKyLiCeAUYDfg+VRrjl+MiMnAacDbgceBnwEvz8w3DbG8pcDlwNbAezPzjpWPLyKmA18G3ggsA76f\nmZ/q/xxExPuBg+rlbgB8NjO/GhEbAxcCG9ZX/e/M/PRA56/63EbEMuALwJuAacAnM/Oyfvf5z1Rr\nz48Ch2Xm/fUa5QbAi4ErMvPoVR7L+cCWwArg9sz8UH3Z24BP1Y+hB/h4Zt4SEd8ApmfmPhHxCuA6\nYKfM/NWq82r43Oc2AUTEXwNbALcAewCNzHxDZr4UuA04rL7q54BDMvO1wLHAzkOcfwZwW2a+BtgO\n6AY+Wl+2HvC/mTkbeBdwSkSsC3wQ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2rRnXW91X8+evSNnnPE5rr32h8yYMYOO\njk6WLVv29OX77XcAJ5/
2016-03-28 12:03:08 +00:00
"text/plain": [
2016-03-29 10:48:56 +00:00
"<matplotlib.figure.Figure at 0x7fd1265e2a20>"
2016-03-28 12:03:08 +00:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"#Small touches\n",
"\n",
"pclass_labels = ['First', 'Second', 'Third']\n",
"sex_labels = {'Female': 0, 'Male': 1}\n",
"\n",
"plt = df.query('Age < 20 and Survived == 1').groupby(['Sex','Pclass']).size().unstack(['Sex']).plot(kind='bar', \n",
" stacked=True, rot=0, subplots=False, figsize=(5,10))\n",
"plt.set_xticklabels(pclass_labels)\n",
"plt.legend(labels=sex_labels)\n",
"plt.set_xlabel('Passenger class')\n",
"plt.set_title('Passenger class per sex')"
]
},
{
"cell_type": "code",
2016-03-29 10:48:56 +00:00
"execution_count": 26,
2016-03-28 12:03:08 +00:00
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
2016-03-29 10:48:56 +00:00
"<matplotlib.text.Text at 0x7fd1264403c8>"
2016-03-28 12:03:08 +00:00
]
},
2016-03-29 10:48:56 +00:00
"execution_count": 26,
2016-03-28 12:03:08 +00:00
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
2016-03-29 10:48:56 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAZoAAAEKCAYAAAArYJMgAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHfFJREFUeJzt3Xl8VPW9//FXCCIkoAI3rggCyqcutVcFV0TErV6ty8+q\n1bqCC1TBW5WfigsuVax63a2lLrhUrVTrBldR0YK2dcENLfUjhqJStQIGgYQtYe4f5wQnSMIJ5ptz\nMnk/Hw8emTkzc+Z9JmHec77nzDlFuVwOERGRUNqkHUBERAqbikZERIJS0YiISFAqGhERCUpFIyIi\nQaloREQkqLZpBxBZnZn1AMqB6fGkovjnre4+Lp1U6TCzccD77n5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p566lHcP1xVPjU1\nNXzxxecA9OljAHTs2JGttuoFQKdOnVi2bDldunRl/PhHmDLlJUpKSqmurqnzPLNmfczbb0/jpZde\nIJfLrVqzCUFFIyKSIasPnfXq1YtddunLyJGjyOVy3H//PWyxRbf41voPOfbII79nhx125IgjjuLt\nt6fx2mt/qXN7jx49Oeigbdl//4OoqKhgwoSnmnpRVlHRiIjUY+nXVc0+r9VPyzxo0CD+/OdXOeus\n01myZAkDBgykpKSkzv3WdLl//wHcdNN1TJ78PB07dqS4uC0rVqxYdftJJ53KmDFX8dRTf6KqqorB\ng8/4votY/zK15qM3H3D673KFcgiabz6fwYZ7ztAhaIAlXy1m9B4jUznWWRb3EFKm5HT05mR09GYR\nkSagozc3HR2CRkREgsr
2016-03-28 12:03:08 +00:00
"text/plain": [
2016-03-29 10:48:56 +00:00
"<matplotlib.figure.Figure at 0x7fd12648d470>"
2016-03-28 12:03:08 +00:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"#The same horizontal\n",
"pclass_labels = ['First', 'Second', 'Third']\n",
"sex_labels = {'Female': 0, 'Male': 1}\n",
"\n",
"plt = df.query('Age > 25 and Survived == 1').groupby(['Sex','Pclass']).size().unstack(['Sex']).plot(kind='barh', \n",
" stacked=True, rot=0, subplots=False)\n",
"plt.set_yticklabels(pclass_labels)\n",
"plt.legend(labels=sex_labels)\n",
"\n",
"plt.set_ylabel('Passenger class')\n",
"plt.set_title('Passenger class per sex')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Feature Sex"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We are now going to explore the Sex attribute"
]
},
{
"cell_type": "code",
2016-03-29 10:48:56 +00:00
"execution_count": 27,
2016-03-28 12:03:08 +00:00
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"Sex\n",
"female 314\n",
"male 577\n",
"dtype: int64"
]
},
2016-03-29 10:48:56 +00:00
"execution_count": 27,
2016-03-28 12:03:08 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# How many passengers by sex\n",
"df.groupby('Sex').size()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We see men are more numerous than women."
]
},
{
"cell_type": "code",
2016-03-29 10:48:56 +00:00
"execution_count": 28,
2016-03-28 12:03:08 +00:00
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
2016-03-29 10:48:56 +00:00
"<matplotlib.axes._subplots.AxesSubplot at 0x7fd1265aaf60>"
2016-03-28 12:03:08 +00:00
]
},
2016-03-29 10:48:56 +00:00
"execution_count": 28,
2016-03-28 12:03:08 +00:00
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
2016-03-29 10:48:56 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYQAAAERCAYAAAB7FtAjAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAEehJREFUeJzt3XuQnXV9x/H3ZjeBXDZxGdZUisbL0G8sNXRA0SBDAA2S\nigYZW8aOpYIkXmKo09EqoTjacYVRBmtk0ClEQ62toxnFViZqNQxknepE6ozdNn5NL5aJdGqAk+xm\nIyWX7R/PL3BYNrsnl2fPsnm/ZjI5z++5fXfm2f2c3+93nud0jIyMIEnSjHYXIEmaGgwESRJgIEiS\nCgNBkgQYCJKkwkCQJAHQVfcJIuLDwJuBmcCdwIPARuAQMJCZa8p2q4DVwH6gLzPvq7s2SdLTau0h\nRMQyYGlmXgBcDLwIuB1Yl5nLgBkRsTIiFgJrgaXA5cAtETGzztokSc9U95DRG4CBiLgX+HvgW8C5\nmbm1rN8MLAfOB/oz80BmDgI7gCU11yZJalL3kNHpVL2CK4CXUoVCcwgNAfOBbmBPU/teYEHNtUmS\nmtQdCI8B2zPzAPDziHgCOLNpfTewGxikCobR7ZKkSVJ3IPQDNwCfjogzgLnA9yNiWWY+AKwAtgDb\ngL6ImAXMBhYDA+Md+MCBgyNdXZ21Fi9J01DHEVfU/XC7iLgVuLQU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JmAbOBxcDARMdv\nNPYdV32NxvBx7a/pq9EYZteuobaeXxrLibg2xwuUOnsINwLPA26OiI8AI8CfAJ8tk8bbgU2ZORIR\n64F+oINq0vnJGuuSJI2hzjmE9wPvH2PVxWNsuwHYUFctkqSJeWOaJAkwECRJhYEgSQIMBElSYSBI\nkgADQZJUGAiSJMBAkCQ
2016-03-28 12:03:08 +00:00
"text/plain": [
2016-03-29 10:48:56 +00:00
"<matplotlib.figure.Figure at 0x7fd1265740b8>"
2016-03-28 12:03:08 +00:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Plot with seaborn\n",
"sns.countplot('Sex', data=df)"
]
},
{
"cell_type": "code",
2016-03-29 10:48:56 +00:00
"execution_count": 29,
2016-03-28 12:03:08 +00:00
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
2016-03-29 10:48:56 +00:00
"<matplotlib.axes._subplots.AxesSubplot at 0x7fd1264b7080>"
2016-03-28 12:03:08 +00:00
]
},
2016-03-29 10:48:56 +00:00
"execution_count": 29,
2016-03-28 12:03:08 +00:00
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
2016-03-29 10:48:56 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXUAAAERCAYAAACEmDeEAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAEQZJREFUeJzt3X1sXXd5wPGvYyclcZ3gUpPRtQSGuieMEaYAZWFVUwop\n6VrIQNMqJsagNOUlpEMMBg0C7R/TCrpUy6qC1gbCOhhiFS8TUYBBUBujgQJDYt7CQ/ZaAtNws5tc\nx1aXN++Pc8s8N/a9xNe+9i/fzz/1Pef4+El1/PXxufced01MTCBJKsOSTg8gSWofoy5JBTHqklQQ\noy5JBTHqklQQoy5JBelpZaOIeB/wamApcB/wCLAHOAsMZ+a2xnZbgduAU8BgZu6dg5klSdNoeqYe\nERuBDZn5UuBa4JnATmBHZm4ElkTElohYDWwHNgCbgTsjYumcTS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IKYtQlqSBGXZIKYtQlqSBGXZIKYtQlqSBGXZIKYtQlqSBGXZIKYtQlqSBG\nXZIKYtQlqSBGXZIKYtQlqSBGXZIKYtQlqSBGXZIKYtQlqSBGXZIKYtQlqSBGXZIKYtQlqSBGXZIK\nYtQlqSBGXZIKYtQlqSBGXZIK0tPKRhHxEuCuzHxZRDwH2AOcBYYzc1tjm63AbcApYDAz987NyJKk\n6TQ9U4+I9wD3Axc1Fu0EdmTmRmBJRGyJiNXAdmADsBm4MyKWztHMkqRptHL55Z+B10x6/MLMPND4\neB+wCbgKGMrM05lZBw4D69o6qSSpqaZRz8zPA6cnLeqa9PEosBLoA45PWn4CWNWOASVJrTufJ0rP\nTvq4DzgG1KniPnW5JGk
2016-03-28 12:03:08 +00:00
"text/plain": [
2016-03-29 10:48:56 +00:00
"<matplotlib.figure.Figure at 0x7fd126481208>"
2016-03-28 12:03:08 +00:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Same graph with matplotlib and pandas\n",
"colors_sex = ['#ff69b4', 'b']\n",
"df.groupby('Sex').size().plot(kind='bar', rot=0, color=colors_sex)"
]
},
{
"cell_type": "code",
2016-03-29 10:48:56 +00:00
"execution_count": 30,
2016-03-28 12:03:08 +00:00
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"Sex\n",
"female 233\n",
"male 109\n",
"Name: Survived, dtype: int64"
]
},
2016-03-29 10:48:56 +00:00
"execution_count": 30,
2016-03-28 12:03:08 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# How many passergers survived by sex\n",
"df.groupby('Sex')['Survived'].sum()"
]
},
{
"cell_type": "code",
2016-03-29 10:48:56 +00:00
"execution_count": 31,
2016-03-28 12:03:08 +00:00
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"Sex\n",
"female 0.742038\n",
"male 0.188908\n",
"Name: Survived, dtype: float64"
]
},
2016-03-29 10:48:56 +00:00
"execution_count": 31,
2016-03-28 12:03:08 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# How many passergers survived by sex\n",
"df.groupby('Sex')['Survived'].mean()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We see that 74% of female survived, while only 18% of male survived."
]
},
{
"cell_type": "code",
2016-03-29 10:48:56 +00:00
"execution_count": 32,
2016-03-28 12:03:08 +00:00
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
2016-03-29 10:48:56 +00:00
"<matplotlib.axes._subplots.AxesSubplot at 0x7fd126396ac8>"
2016-03-28 12:03:08 +00:00
]
},
2016-03-29 10:48:56 +00:00
"execution_count": 32,
2016-03-28 12:03:08 +00:00
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
2016-03-29 10:48:56 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYEAAAERCAYAAACdPxtnAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFzhJREFUeJzt3X2YnXV95/H3PEBIJhM6gVkrRaJeF35Rq1SJkGTTFqjg\nXhBqhLYaH+gGUxFWXUvX1ay1WFfdttao4GY1pnCx4EM1l9DWh6yygA+pzarrSnDrFzBXC1G3Bjxk\nwoQhM8nsH/cZPBmSmZtk7jkzc79f/8z53U/nm+s6OZ9zP/x+v47R0VEkSfXU2e4CJEntYwhIUo0Z\nApJUY4aAJNWYISBJNWYISFKNdVd58IjoADYCZwJDwLrM3Nmy/jXANcAIcGNmfqzKeiRJh6r6TGA1\nMC8zVwDrgQ3j1n8AOB9YCfxRRJxYcT2SpBZVh8BKYCtAZm4Hlo5b/32gD5jfbNtzTZKmUdUhsAjY\n09IeiYjW9/wB8F1gB/CFzByouB5JUouqQ2AA6G19v8w8CBARLwAuBpYAzwSeFhGXVVyPJKlFpTeG\ngW3AKmBLRCyj+MU/Zg+wD3g8M0cj4mcUl4aOaGTkwGh3d1dlxUrSHNVxxBVVDiDX8nTQC5uL1gJn\nAT2ZuTkirgSuAB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LQ8sx8AUBEvJzijOB+4P6IeH/l1UmSKjXZmcCBltfnAre3tI+f8mok\nSdNqsjOBhyPibKAH+BWaIdCcXnJXtaVJkqo2WQj8IfAZ4GnA1Zk5GBF/DLwFuLjq4iRJ1ZowBDLz\nbuB54xZ/Brg+M/ccZhdJ0iwy4T2BiPgvEXFi67LMvH8sACJicUT8eZUFSpKqM9nloM8CfxMRPwG+\nTnEfYARYQjF20CnAWyu
2016-03-28 12:03:08 +00:00
"text/plain": [
2016-03-29 10:48:56 +00:00
"<matplotlib.figure.Figure at 0x7fd1263523c8>"
2016-03-28 12:03:08 +00:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"#Graphical representation\n",
"# You can add the parameter estimator to change the estimator. (e.g. estimator=np.median)\n",
"# For example, estimator=np.size is you get the same chart than with countplot\n",
"#sns.barplot(x='Sex', y='Survived', data=df, estimator=np.size)\n",
"sns.barplot(x='Sex', y='Survived', data=df)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can see now if men and women follow the same age distribution."
]
},
{
"cell_type": "code",
2016-03-29 10:48:56 +00:00
"execution_count": 38,
2016-03-28 12:03:08 +00:00
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
2016-03-29 10:48:56 +00:00
"array([<matplotlib.axes._subplots.AxesSubplot object at 0x7fd125f6e588>,\n",
" <matplotlib.axes._subplots.AxesSubplot object at 0x7fd125ccaf98>], dtype=object)"
2016-03-28 12:03:08 +00:00
]
},
2016-03-29 10:48:56 +00:00
"execution_count": 38,
2016-03-28 12:03:08 +00:00
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
2016-03-29 10:48:56 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAX4AAAEFCAYAAADkP4z+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAGPVJREFUeJzt3XuUZWV55/FvdTXVYPUF6CmYmJa21fiYyygBIpco3bBg\nKRrTcTJrnFky2h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PARYANwXmauBhZExNpuFiiVYfBL5T0ALIyIPmAZsAs4IjM3NR6/DTipW8VJZXmoRypvO7AK\n+BdgOfAG4NVNj2+j+IUgzWkGv1Te+4AvZ+b5EfGrwP8EBpoeXwI8UaahoaEllRVVpq2RkcHK3m+m\nDjposK3PO9vf1Wy2U3VbZRn8Unn/j+LwDhQBvxD4XkSszsw7gFOAjWUa2rJlWyUFDQ0tKdXW8PBo\nJe/XiuHh0ZY/b9nPN5ttzcWaJtoqy+CXyvsEcHVE3AnsB5wDfAe4MiL2A+4HbuxifVIpBr9UUmaO\nAm+a4qE1s1yK1BZH9UhSzRj8klQzBr8k1YzBL0k1Y/BLUs04qkdSx7S62tyEgw/+zQqr0YRpgz8i\nFgBXAEExA+E7gadxRkJJ02hltblnXruVqz88yNKlh3Sgsnors8f/BmA8M18VEaspZiTso5iRcFNE\nXBYRazPz5o5WKqknudrc3DPtMf5GoJ/euLkSGMYZCSWpZ5U6uZuZYxFxDXAp8HmKPf4JzkgoST2k\n9MndzFwXEYcAdwMHND1UakbCTs1AN1W73ZyJsJOmmuVwNr/XudimpJkrc3L3VGBFZl4EPEWx1Nw9\nM52RsKoZ6JrtbWa7bs5E2EmTZzmscma/Zp1ot5O1SpqZMnv8XwA+HRF3NJ7/HoqFKJyRUJJ60LTB\nn5k7cEZCSZo3vHJXkmr
2016-03-28 12:03:08 +00:00
"text/plain": [
2016-03-29 10:48:56 +00:00
"<matplotlib.figure.Figure at 0x7fd125d3ac88>"
2016-03-28 12:03:08 +00:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
2016-03-29 10:48:56 +00:00
"df.hist(column='Age', by='Sex')"
2016-03-28 12:03:08 +00:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"It seems they follow a similar distribution. We can separate per passenger class."
]
},
{
"cell_type": "code",
2016-03-29 10:48:56 +00:00
"execution_count": 40,
2016-03-28 12:03:08 +00:00
"metadata": {
"collapsed": false
},
"outputs": [
{
2016-03-29 10:48:56 +00:00
"data": {
"text/plain": [
"array([[<matplotlib.axes._subplots.AxesSubplot object at 0x7fd125d3d8d0>,\n",
" <matplotlib.axes._subplots.AxesSubplot object at 0x7fd1259fc6a0>],\n",
" [<matplotlib.axes._subplots.AxesSubplot object at 0x7fd1259c96d8>,\n",
" <matplotlib.axes._subplots.AxesSubplot object at 0x7fd1259829b0>]], dtype=object)"
]
},
"execution_count": 40,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYQAAAEFCAYAAADjUZCuAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHsdJREFUeJzt3XuUnHWd5/F3dYcO0IQQsy1HiQSI8GVnXESDCyKQyMBy\nG404M7q7h9GIwILhfjlLYHGdYWHZEaLDqHg2EBCPXMRjhtsgCmEhMIoGkEnO6DdchNBBl5jt0EmH\n0Onu2j+ep6DS6aT7+T2/ujxVn9c5HLqq+vnWryv1rW89l+/vVyqXy4iIiHQ0egAiItIcVBBERARQ\nQRARkZQKgoiIACoIIiKSUkEQEREAJjV6ADIxZnYrsNLdFzV6LCKNYmanAZcCI8Bm4AJ3f6axo2od\nKghNzswOBr4NHA6sbPBwRBrGzA4C/hfwEXd/w8xOAn4MzGzsyFqHDhk1vwXAEuCHjR6ISIO9DZzh\n7m+kt58B9jYzfbGNRC9kk3P38wDM7LhGj0Wkkdz9VeDVqrsWAfe6+1CDhtRyVBBEpFDMbHfge8A+\nwIkNHk5L0SEjESkMM9sX+GdgEJjr7v0NHlJL0R6CiBSCmU0DHgeWuPvVjR5PK1JBKA5NSyvt7hxg\nBnCqmX02va8M/Jm79zVuWK2jpOmvRUQEcu4hmNl7gRXAccDuwAPA6vThm9z9nnzDEykG5YK0guCC\nkF77+12SbkGA2cAN7v6NGAMTKQrlgrSKPFcZXQ/cBLye3p4NnGJmj5vZzWbWnXt0IsWgXJCWEFQQ\nzGw+8Ia7/wwopf89DVzm7nOAl4GvRRq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3Tpo1/bk3n0+oj\nNBegfvkQuyDcAtxqZst
"text/plain": [
"<matplotlib.figure.Figure at 0x7fd125af3a90>"
]
},
"metadata": {},
"output_type": "display_data"
2016-03-28 12:03:08 +00:00
}
],
"source": [
2016-03-29 10:48:56 +00:00
"df.hist(column='Age', by='Pclass')"
2016-03-28 12:03:08 +00:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We see there are more young men in third class. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Feature Pclass"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We have already seen how passengers are distributed with Pclass"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"Pclass\n",
"1 216\n",
"2 184\n",
"3 491\n",
"dtype: int64"
]
},
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.groupby('Pclass').size()"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7f2f9406ba58>"
]
},
"execution_count": 35,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYQAAAESCAYAAAD9gqKNAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAETBJREFUeJzt3X+sX3V9x/Hn9V4tvbftepFrZUUalyXvhZAtYUaWVm0p\nAv5iGMp0Wjtm1flrScU5g3HYynAxLBCGzrAVO5BhNnUdsQMRGRFF2Ypx07m4t45F6m3ZepEv9gdt\nKbd3f5zPlXvLvbffW+75ntve5yNp+v2e7/me+7r35t7X/Zwfn9M1MjKCJEnPazqAJGl2sBAkSYCF\nIEkqLARJEmAhSJIKC0GSBEBPnRuPiJXAF4EfAF3A94E/B26jKqNHgXWZeTgi1gIbgGFgc2ZuqTOb\nJGm8rjqvQyiF8P7MfNOY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RsS7gUeAWzNzOCKuBO6hKoRNmelvFknqoLoP\nKm8GNk/w0oUTrLsV2FpnHknS5LxSWZIEWAiSpGJOTG6nE5fTl3eGU5cLLATNcoODO9i09RPM7/cU\nxrocaO1n06UfdepyWQia/eb399F3mtc3SHXzGIIkCbAQJEmFhSBJAiwESVJhIUiSAAtBklRYCJIk\nwEKQJBUWgiQJsBAkSYWFIEkCLARJUmEhSJIAC0GSVFgIkiTAQpAkFRaCJAmwECRJhYUgSQIsBElS\nYSFIkgALQZJUWAiSJMBCkCQVFoIkCbAQJEmFhSBJAiwESVJhIUiSAAtBklRYCJIkAHrq/gARcTZw\nB3B9Zn4mIs4AbqMqo0eBdZl5OCLWAhuAYWBzZm6pO5sk6Rm1jhAiohe4Ebh3zOKrgU9l5krgYWB9\nWe8qYDVwHnBFRCyuM5s
"text/plain": [
"<matplotlib.figure.Figure at 0x7f2f9417f2b0>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Distribution\n",
"sns.countplot('Pclass', data=df)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Most passengers are in 3rd class."
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7f2f9409a0f0>"
]
},
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYEAAAESCAYAAAAbq2nJAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAF7VJREFUeJzt3X+U3XV95/HnZCZAMgnNAKMYY1IVfGOt6ImWE1GjEGtp\naxeq1NIqRS3uWcWtbO0vsVZslVo9REx/IdbIqlStUkGWH4WKPxCxx2TVZau8bXcrIQmriVxMMklg\nMpn9494hd4Yk853JfO6dyff5OGdO7vf3e+Y7mdf31+fz7RkdHUWSVE/zul2AJKl7DAFJqjFDQJJq\nzBCQpB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6b7I3i32n9fEvaLYT+PRU2wlk5sQnf+49yDz307w8JEnq\noKr3BN4G/DrNdgLfBj4BfCEzHy1WmSSpuNLtBCRJs1jpdgKSpFlsqu0EPs+RtROQJM0iVc8EvgL8\nUmaOlCxGktRZVTuQe5kBIElHn6pnApsi4svAN4DHngjKzD8pUZQkqTOqhsB/tL4kSUeRqiHwZ0Wr\nkCR1RdUQ2Mf4l76MAj8BTpzxiiRJHVP1HcOP3UBuvVFsDfCcUkVJkjqj6tNBj8nMRzPzVuDnC9Qj\nSeqgqo3F3jBh1FOAJ898OZKkTqp6T+DFbZ9HgR3Aq2e+HElSJ1W9J/D6sc+tPoR+kpmjh1lEkjQH\nHPaeQEScHhGfbRu+juYrI7dGxBmli5MklTXZjeF1NF8mQ0SsBl4APJHm00FXlC1NklTaZCEwLzNv\nan3+FZpvFtuZmd8FesqWJkkqbbIQGG77fBbw5SksK0ma5Sa7MbwnIs4FjgeWA18CiIgAegvXJkkq\nbLIQeCvwt8AA8JuZORw
"text/plain": [
"<matplotlib.figure.Figure at 0x7f2f9405ffd0>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Survivors per class\n",
"sns.barplot(x='Pclass', y='Survived', data=df)"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"source": [
"As expected, passenger class is very significant, since most survivors are in first class.\n",
"\n",
"We can also see the distribution of classes per sex."
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<seaborn.axisgrid.FacetGrid at 0x7f2f94db5400>"
]
},
"execution_count": 37,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAWgAAAEZCAYAAAC6m7+xAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAF7lJREFUeJzt3X2QXXWd5/F3k9aEJEQ6GJAJkmV06rtSrlOLjMwmSMKD\nMM4guIBSY2B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ET8XX2rcSsmFNCZ+fyQ8Ih4JXAk\n8LtNFSVJPfYD4EsRcRqwierxe28D3l5PZfEq4OaI2ACcTtUH/U3gb4E/aqVidmI2u8x8luob6ONU\n/TSSVLR6PvpTxth0xxjrjqp//4gWwxkmPlDljFGrXkt15VOS1JCJtqDf2rU8DKwH3t37ciRJIyba\nB306QH0FdDgzO41WJUmacBfHYuAqYA+gLyJ+BZySmd9rsjhJms4m+kSV84HjM3PvzFwA/DFwYXNl\nSZImGtBbM/OBkReZ+X26hnxLknpvohcJt0XEicCt9es/ALY2U5Kk6WrhwoUzgNf1+LQPrlu3rud5\nFRFfBb6RmTf2+twjJhrQ76eaCepSqqep/AB4b1NFSZq2XvdvDj8zZ82d35OTbdr4JD+6/bIAftKT\nE06yiQb00cDmzBwAiIhvAX8IfLGpwiRNT7Pmzmf2vAWT+p71CMOlwKuBA4FPUV1rewPVAJeTgd8D\nZgGXZOblXcfuRjXi8ADgFcC5mXl7L+qaaB/0KcAJXa+PBt7TiwIkqRCvr6cjPR9YAbyzXj4d+EVm\nHgYcxm9OHvce4NHMPBL498BFvSpooi3oGZnZ3YczzAuPvhpXRLyRauKRCzPzy3W/zZuBJ+pdPpuZ\nN9UTlJxN1be9qvsbSpI
"text/plain": [
"<matplotlib.figure.Figure at 0x7f2f8ffd6198>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.factorplot('Pclass',data=df,hue='Sex',kind='count')"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"Pclass Sex \n",
"1 female 0.968085\n",
" male 0.368852\n",
"2 female 0.921053\n",
" male 0.157407\n",
"3 female 0.500000\n",
" male 0.135447\n",
"Name: Survived, dtype: float64"
]
},
"execution_count": 38,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.groupby(['Pclass', 'Sex']).Survived.mean()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We see most women in first class and second survived, 96% and 92% respectively."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Feature Fare"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We are going to analyse the feature *Fare* and will take the opportunity to introduce how to manage outliers.\n",
"\n",
"As we see in the PairGrid chart, Fare is directly related to the Passenger class."
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7f2f8ff4c1d0>"
]
},
"execution_count": 39,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAEDCAYAAADZUdTgAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFHZJREFUeJzt3X+QXWd93/H3SpGFtVqNZM0ixLoYOs18PZ5MZko1YypR\n60djuxSICRKBiUZ1ImiVjpNRjXHH+UO2UdNCSa1SG/KjCgLhkCnQUR00HhzjcXBlcCOnzNgwSb4Y\nG+R4JdC1R45XxpIvu9s/7jFdCUl7dffes7v3eb9mPHPuc87V83yt1ed59vy4d2BychJJUhkWzPYA\nJEn1MfQlqSCGviQVxNCXpIIY+pJUEENfkgryc9MdEBGDwOeBFcAlwG7gh8AfABPAk5l5U3XsrcCW\nqn13Zn61R+OWJHWgnZX+rwN/m5mbaAX6fwP+K/DbmfnPgOURcX1EvBn4VWAt8G5gT0QM9GTUkqSO\ntBP6zwMrq+2VwAvAWzLzW1XbQeBaYCPw1cwcz8zngR8AV3V3uJKkmZg29DPzi8AVEfEU8HXgVuDE\nlEOOA6uBVUBjSnujapckzRHThn5EbAWOZObPA5uAPznrkPOdwvHUjiTNMdNeyAXWAX8OkJnfjohL\nz3rfCDAKHAWuPKv96IX+4MnJycmBAecGSbpIHQdnO6H/PeBtwP+KiCuAMeD7EbEuM78BvBe4G3gK\n+HBE3A68HnhjZv71BUc9MECjMdbp2Oe84eEh65un+rk2sL75bnh4qOP3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Vp\nHmrn7p1TwNZz7LruHMceAA50YVySpB7wiVxJKoihL0kFMfQlqSCGviQVxNCXpIIY+pJUEENfkgpi\n6EtSQQx9SSqIoS9JBTH
"text/plain": [
"<matplotlib.figure.Figure at 0x7f2f8ffa4ba8>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"df['Fare'].hist()"
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"array([[<matplotlib.axes._subplots.AxesSubplot object at 0x7f2f8feb4160>,\n",
" <matplotlib.axes._subplots.AxesSubplot object at 0x7f2f8fe02e48>]], dtype=object)"
]
},
"execution_count": 40,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAEMCAYAAADHxQ0LAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHP9JREFUeJzt3XuQVeWZ7/FvC9JIAwViBwlGYmoyj0PNZOo4VJkBR5CJ\nOJbXBBytUIwJyYTJMRnG25SZDF445iTHHJgcNRlzUKJxtCY6RYyEaNAyGm8nGJ0RPck8KgqES6Ql\njVyE7qa7zx/v28fdm+7ea2/W2pdev09VV++9Lu96evXaz3r3u9613qbe3l5ERGT4O6bWAYiISHUo\n4YuI5IQSvohITijhi4jkhBK+iEhOKOGLiOTEyFoHkDdm1gO8ARyOk5qAze5+bu2iEklH0fE9AtgD\nfMXdnxhindnAne7+0epEmV9K+NXXC8x29521DkQkA/2ObzObCaw1s993990l1pOMKeFXX1P8OYKZ\nGXAnMInwv7ne3f81zusB/gG4HJgO/AHwHWAKcAhY7O4vZh69yND6Hd/u/pyZvQH8KfBjM/sr4KuE\nBP8L4K8LVzaz44C7gT8GjgXWuPu1cd4lwPWEbw6dwN+6+88Hm57lH9mo1IZfX74JPOzu04HPAXeZ\n2YjCBdz9D+LLHwJ3u7sBfwP8yMz0/5R6dCzQYWbTCMf4me5+KtACfLl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QvIpITSvgi\nIjmhhC8ikhMlx7Q1s9nAg8CrQBOwEfgmcC/hhLETWOTuXWa2EFgKdAOr3H11VoGLiEh5ktbwn3T3\nue5+lrsvBZYDt7n7bGATsNjMxgDLgLnAWcCVZjYhk6hFRKRsSRN+U9H7OcDa+HotcDZwOrDB3fe7\n+yHgGWBWGkGKiMjRK9m
"text/plain": [
"<matplotlib.figure.Figure at 0x7f2f8feba390>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"df.hist(['Fare','Pclass'])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We see the distribution is right sweked. We are going to detect outliers using a box plot"
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7f2f8fd941d0>"
]
},
"execution_count": 41,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXUAAAEDCAYAAADKhpQUAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAD9JJREFUeJzt3XuMXGd5x/Hv2psary/yhq6MMaUXIT0IVVUaJUpltzhx\nGyPSUqtxGqK4FsKlChJS3LQxoiihxrSo4qbKoP6TxDS1EqEgRRg3KDJR0og0ETaNwuWPPjRBTVvb\n4CUs7Tq+sOxO/5gxOl5mdmc3s549734/kpV3zjkz5/nD+c3j95zzzkCj0UCSVIZl/S5AktQ7hrok\nFcRQl6SCGOqSVBBDXZIKYqhLUkEGuzkoInYCe4EJ4CPAt4FDNL8UTgG7MnOiddweYBK4LzMPLkjV\nkqS2Bma7Tz0irgSeA34TWAPsB64A/jkzH42IvwX+i2bIPw9cA/wUOA78Tmb+eOHKlyRVddOp/x7w\n1cw8C5wF7oiI7wF3tPYfAe4Gvgscy8wzABHxDLAZeKznVUuS2uom1H8FWBURh4F1wEeBocycaO0/\nDWwA1gOjlfeNtrZLki6TbkJ9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67q9rq+olSaak4fPhR\nALZtu6nPlUhzZ6cuVRw9+hXOnTvLuXNn7dZVS4a6VHGxS58+lurCUJekghjqUsX27Te3HUt1YahL\nFdWLo14oVR0Z6lLF3r13th1LdWGoSxWvvPLDtmOpLgx1SSqIoS5JBTHUpYqVK4fajqW6MNSlCm9p\nVN0Z6lLFD37w/bZjqS4MdaniqaeeaDuW6sJQl6SCGOqSVBBDXaq46qqr246lujDUpYo777y77Viq\nC0Ndqjhw4FNtx1JdGOp
"text/plain": [
"<matplotlib.figure.Figure at 0x7f2f8fda1e48>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.boxplot(data=df['Fare'])"
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7f2f8fd53f28>"
]
},
"execution_count": 42,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXUAAAEDCAYAAADKhpQUAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAEAlJREFUeJzt3X9s3Hd9x/GnE6fpnDiKC7eQeSKbYHujapqgqsqUUPJj\nA4QYMJZKTIuyrilStCEayrItm1SSRttUMVpBi6axtulCVTaxgdiybiWtSn+NDndCg/YP3oWwhZFk\nyW0yk42X4iTeH3cB+/CPs3vn8338fEjW9/y97933/Yf9urc/38/3456JiQkkSWVY0ekCJEmtY6hL\nUkEMdUkqiKEuSQUx1CWpIIa6JBWkt5mDImIX8LvAOPBh4HngQWofCmeA3Zk5Xj9uH3ARuDczj7Sl\naknStHrmmqceEVcBzwJvAPqBw8Aq4B8y83MR8cfAt6mF/FeAa4ELwHPA9Zn53faVL0marJlO/ZeA\nRzNzDBgD9kbEt4C99eePAfuBF4GhzBwFiIhngC3Awy2vWpI0rWZC/aeANRHxd8B64HagLzPH68+f\nAzYCG4DqpNdV6/slSYukmV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s5OkZcJQl6SCGOqSVBBDXZIKYqhLUkEMdUkqiKEuSQXxn2RIDW5/YIiTZ0fZtGEtB2+6\nrtPlSPNipy41OHl2dMpW6iaGutRg04a1U7ZSN3GZAGkaLhOgpcxlAiRpmfBCqdRgzx2P/+DxkQM7\nOliJNH926pJUEENdkgpiqEtSQQx1qYFTGtXNnNIoTcMpjVrKZpvS6OwXqcG+u59mZGyc/r5VfPyW\n6ztdjjQvDr9IDUbGxqdspW5iqEtSQQx1qcGq3hVTtlI38UKpNA0vlGopc+0XSVomnP0iNdj70ScY\nv3CJVb0r+OT+bZ0uR5o
"text/plain": [
"<matplotlib.figure.Figure at 0x7f2f8fd679b0>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# We can see the same with matplotlib.\n",
"# There is a bug and if you import seaborn, you should add 'sym='k.' to show the outliers\n",
"df.boxplot(column='Fare', return_type='axes', sym='k.')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Since Fare depends on Pclass, we are going to show outliers per passenger class."
]
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"OrderedDict([('Fare',\n",
" <matplotlib.axes._subplots.AxesSubplot at 0x7f2f8fdb73c8>)])"
]
},
"execution_count": 43,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAX8AAAEdCAYAAADkeGc2AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAGbVJREFUeJzt3X2UXXV97/H3JAPBwNBEHSNGpC3aL9Jer6KCN6h5QEGu\nRazhYpFGarBifQJatKG3CLKs5WJl8VSqBSIPym1BqBJBjTTyaK4RXSq0+gXjNcrDhaFGTYjBSTL3\nj72HnIkzmZPMmTlz5vd+rZV1zuyzz97fczZ8zm//9m/v3TUwMIAkqSzT2l2AJGniGf6SVCDDX5IK\nZPhLUoEMf0kqkOEvSQXqbncB6nwRcQ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T309W1odymS9LRmw//g\niPg88EyqVv/MzBzsx3gc2A+YA/Q1vKevni5JmmSa6fZ5EDgnM98M/ClwJUN/NHbcKxhtuiSpzUZt\n+WfmI1QHfMnMH0XE/wNeEREzMvMpYC7wMPAIQ1v6c4HVO1v27Nkz6e6evru1d5Te3p52l6AWcVtO\nHSVvy2ZG+7wN2C8zPxERz6Xq3vk0cBzwWWAx8GVgDXBFROwLbAPmUY38GdH69ZvGVn2HsM9/6nBb\nTh2lbMuRfuCa6fO/GbguIo4F9qA60Ptd4JqIeBewDrg6M7dGxDJgJVX4n5OZU/+blaQO1DUwMNC2\nlff1bWjfyidQKS2MErgtp45StmVvb8+wx1+9vIMkFcjwl6QCGf6SVCDDX5IKZPhLUoEMf0kqkOEv\nSQUy/CWpQIa/JBXI8JekAhn+klQgw1+SCmT4S1KBDH9JKpDhL0kFMvwlqUCGvyQVyPCXpAIZ/pJU\nIMNfkgpk+EtSgQx/SSq
"text/plain": [
"<matplotlib.figure.Figure at 0x7f2f8fcdb0f0>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"df.boxplot(column='Fare', by = 'Pclass', return_type='axes', sym='k.')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We see that most outliers are in class 1. In particular, we see some values higher thatn 500 that should be an error."
]
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>PassengerId</th>\n",
" <th>Survived</th>\n",
" <th>Pclass</th>\n",
" <th>Name</th>\n",
" <th>Sex</th>\n",
" <th>Age</th>\n",
" <th>SibSp</th>\n",
" <th>Parch</th>\n",
" <th>Ticket</th>\n",
" <th>Fare</th>\n",
" <th>Cabin</th>\n",
" <th>Embarked</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>258</th>\n",
" <td>259</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>Ward, Miss. Anna</td>\n",
" <td>female</td>\n",
" <td>35.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>PC 17755</td>\n",
" <td>512.3292</td>\n",
" <td>NaN</td>\n",
" <td>C</td>\n",
" </tr>\n",
" <tr>\n",
" <th>679</th>\n",
" <td>680</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>Cardeza, Mr. Thomas Drake Martinez</td>\n",
" <td>male</td>\n",
" <td>36.0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>PC 17755</td>\n",
" <td>512.3292</td>\n",
" <td>B51 B53 B55</td>\n",
" <td>C</td>\n",
" </tr>\n",
" <tr>\n",
" <th>737</th>\n",
" <td>738</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>Lesurer, Mr. Gustave J</td>\n",
" <td>male</td>\n",
" <td>35.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>PC 17755</td>\n",
" <td>512.3292</td>\n",
" <td>B101</td>\n",
" <td>C</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" PassengerId Survived Pclass Name \\\n",
"258 259 1 1 Ward, Miss. Anna \n",
"679 680 1 1 Cardeza, Mr. Thomas Drake Martinez \n",
"737 738 1 1 Lesurer, Mr. Gustave J \n",
"\n",
" Sex Age SibSp Parch Ticket Fare Cabin Embarked \n",
"258 female 35.0 0 0 PC 17755 512.3292 NaN C \n",
"679 male 36.0 0 1 PC 17755 512.3292 B51 B53 B55 C \n",
"737 male 35.0 0 0 PC 17755 512.3292 B101 C "
]
},
"execution_count": 44,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df[df.Fare > 400]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can replace this value by the median(), the mean(), or the second highest value."
]
},
{
"cell_type": "code",
"execution_count": 45,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>PassengerId</th>\n",
" <th>Survived</th>\n",
" <th>Pclass</th>\n",
" <th>Name</th>\n",
" <th>Sex</th>\n",
" <th>Age</th>\n",
" <th>SibSp</th>\n",
" <th>Parch</th>\n",
" <th>Ticket</th>\n",
" <th>Fare</th>\n",
" <th>Cabin</th>\n",
" <th>Embarked</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>258</th>\n",
" <td>259</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>Ward, Miss. Anna</td>\n",
" <td>female</td>\n",
" <td>35.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>PC 17755</td>\n",
" <td>512.3292</td>\n",
" <td>NaN</td>\n",
" <td>C</td>\n",
" </tr>\n",
" <tr>\n",
" <th>737</th>\n",
" <td>738</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>Lesurer, Mr. Gustave J</td>\n",
" <td>male</td>\n",
" <td>35.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>PC 17755</td>\n",
" <td>512.3292</td>\n",
" <td>B101</td>\n",
" <td>C</td>\n",
" </tr>\n",
" <tr>\n",
" <th>679</th>\n",
" <td>680</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>Cardeza, Mr. Thomas Drake Martinez</td>\n",
" <td>male</td>\n",
" <td>36.0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>PC 17755</td>\n",
" <td>512.3292</td>\n",
" <td>B51 B53 B55</td>\n",
" <td>C</td>\n",
" </tr>\n",
" <tr>\n",
" <th>88</th>\n",
" <td>89</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>Fortune, Miss. Mabel Helen</td>\n",
" <td>female</td>\n",
" <td>23.0</td>\n",
" <td>3</td>\n",
" <td>2</td>\n",
" <td>19950</td>\n",
" <td>263.0000</td>\n",
" <td>C23 C25 C27</td>\n",
" <td>S</td>\n",
" </tr>\n",
" <tr>\n",
" <th>27</th>\n",
" <td>28</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>Fortune, Mr. Charles Alexander</td>\n",
" <td>male</td>\n",
" <td>19.0</td>\n",
" <td>3</td>\n",
" <td>2</td>\n",
" <td>19950</td>\n",
" <td>263.0000</td>\n",
" <td>C23 C25 C27</td>\n",
" <td>S</td>\n",
" </tr>\n",
" <tr>\n",
" <th>341</th>\n",
" <td>342</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>Fortune, Miss. Alice Elizabeth</td>\n",
" <td>female</td>\n",
" <td>24.0</td>\n",
" <td>3</td>\n",
" <td>2</td>\n",
" <td>19950</td>\n",
" <td>263.0000</td>\n",
" <td>C23 C25 C27</td>\n",
" <td>S</td>\n",
" </tr>\n",
" <tr>\n",
" <th>438</th>\n",
" <td>439</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>Fortune, Mr. Mark</td>\n",
" <td>male</td>\n",
" <td>64.0</td>\n",
" <td>1</td>\n",
" <td>4</td>\n",
" <td>19950</td>\n",
" <td>263.0000</td>\n",
" <td>C23 C25 C27</td>\n",
" <td>S</td>\n",
" </tr>\n",
" <tr>\n",
" <th>311</th>\n",
" <td>312</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>Ryerson, Miss. Emily Borie</td>\n",
" <td>female</td>\n",
" <td>18.0</td>\n",
" <td>2</td>\n",
" <td>2</td>\n",
" <td>PC 17608</td>\n",
" <td>262.3750</td>\n",
" <td>B57 B59 B63 B66</td>\n",
" <td>C</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" PassengerId Survived Pclass Name \\\n",
"258 259 1 1 Ward, Miss. Anna \n",
"737 738 1 1 Lesurer, Mr. Gustave J \n",
"679 680 1 1 Cardeza, Mr. Thomas Drake Martinez \n",
"88 89 1 1 Fortune, Miss. Mabel Helen \n",
"27 28 0 1 Fortune, Mr. Charles Alexander \n",
"341 342 1 1 Fortune, Miss. Alice Elizabeth \n",
"438 439 0 1 Fortune, Mr. Mark \n",
"311 312 1 1 Ryerson, Miss. Emily Borie \n",
"\n",
" Sex Age SibSp Parch Ticket Fare Cabin Embarked \n",
"258 female 35.0 0 0 PC 17755 512.3292 NaN C \n",
"737 male 35.0 0 0 PC 17755 512.3292 B101 C \n",
"679 male 36.0 0 1 PC 17755 512.3292 B51 B53 B55 C \n",
"88 female 23.0 3 2 19950 263.0000 C23 C25 C27 S \n",
"27 male 19.0 3 2 19950 263.0000 C23 C25 C27 S \n",
"341 female 24.0 3 2 19950 263.0000 C23 C25 C27 S \n",
"438 male 64.0 1 4 19950 263.0000 C23 C25 C27 S \n",
"311 female 18.0 2 2 PC 17608 262.3750 B57 B59 B63 B66 C "
]
},
"execution_count": 45,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#Calculate hight values\n",
"df.sort_values('Fare', ascending=False).head(8)"
]
},
{
"cell_type": "code",
"execution_count": 46,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>PassengerId</th>\n",
" <th>Survived</th>\n",
" <th>Pclass</th>\n",
" <th>Name</th>\n",
" <th>Sex</th>\n",
" <th>Age</th>\n",
" <th>SibSp</th>\n",
" <th>Parch</th>\n",
" <th>Ticket</th>\n",
" <th>Fare</th>\n",
" <th>Cabin</th>\n",
" <th>Embarked</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>258</th>\n",
" <td>259</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>Ward, Miss. Anna</td>\n",
" <td>female</td>\n",
" <td>35.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>PC 17755</td>\n",
" <td>263.000</td>\n",
" <td>NaN</td>\n",
" <td>C</td>\n",
" </tr>\n",
" <tr>\n",
" <th>88</th>\n",
" <td>89</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>Fortune, Miss. Mabel Helen</td>\n",
" <td>female</td>\n",
" <td>23.0</td>\n",
" <td>3</td>\n",
" <td>2</td>\n",
" <td>19950</td>\n",
" <td>263.000</td>\n",
" <td>C23 C25 C27</td>\n",
" <td>S</td>\n",
" </tr>\n",
" <tr>\n",
" <th>27</th>\n",
" <td>28</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>Fortune, Mr. Charles Alexander</td>\n",
" <td>male</td>\n",
" <td>19.0</td>\n",
" <td>3</td>\n",
" <td>2</td>\n",
" <td>19950</td>\n",
" <td>263.000</td>\n",
" <td>C23 C25 C27</td>\n",
" <td>S</td>\n",
" </tr>\n",
" <tr>\n",
" <th>341</th>\n",
" <td>342</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>Fortune, Miss. Alice Elizabeth</td>\n",
" <td>female</td>\n",
" <td>24.0</td>\n",
" <td>3</td>\n",
" <td>2</td>\n",
" <td>19950</td>\n",
" <td>263.000</td>\n",
" <td>C23 C25 C27</td>\n",
" <td>S</td>\n",
" </tr>\n",
" <tr>\n",
" <th>737</th>\n",
" <td>738</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>Lesurer, Mr. Gustave J</td>\n",
" <td>male</td>\n",
" <td>35.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>PC 17755</td>\n",
" <td>263.000</td>\n",
" <td>B101</td>\n",
" <td>C</td>\n",
" </tr>\n",
" <tr>\n",
" <th>438</th>\n",
" <td>439</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>Fortune, Mr. Mark</td>\n",
" <td>male</td>\n",
" <td>64.0</td>\n",
" <td>1</td>\n",
" <td>4</td>\n",
" <td>19950</td>\n",
" <td>263.000</td>\n",
" <td>C23 C25 C27</td>\n",
" <td>S</td>\n",
" </tr>\n",
" <tr>\n",
" <th>679</th>\n",
" <td>680</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>Cardeza, Mr. Thomas Drake Martinez</td>\n",
" <td>male</td>\n",
" <td>36.0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>PC 17755</td>\n",
" <td>263.000</td>\n",
" <td>B51 B53 B55</td>\n",
" <td>C</td>\n",
" </tr>\n",
" <tr>\n",
" <th>311</th>\n",
" <td>312</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>Ryerson, Miss. Emily Borie</td>\n",
" <td>female</td>\n",
" <td>18.0</td>\n",
" <td>2</td>\n",
" <td>2</td>\n",
" <td>PC 17608</td>\n",
" <td>262.375</td>\n",
" <td>B57 B59 B63 B66</td>\n",
" <td>C</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" PassengerId Survived Pclass Name \\\n",
"258 259 1 1 Ward, Miss. Anna \n",
"88 89 1 1 Fortune, Miss. Mabel Helen \n",
"27 28 0 1 Fortune, Mr. Charles Alexander \n",
"341 342 1 1 Fortune, Miss. Alice Elizabeth \n",
"737 738 1 1 Lesurer, Mr. Gustave J \n",
"438 439 0 1 Fortune, Mr. Mark \n",
"679 680 1 1 Cardeza, Mr. Thomas Drake Martinez \n",
"311 312 1 1 Ryerson, Miss. Emily Borie \n",
"\n",
" Sex Age SibSp Parch Ticket Fare Cabin Embarked \n",
"258 female 35.0 0 0 PC 17755 263.000 NaN C \n",
"88 female 23.0 3 2 19950 263.000 C23 C25 C27 S \n",
"27 male 19.0 3 2 19950 263.000 C23 C25 C27 S \n",
"341 female 24.0 3 2 19950 263.000 C23 C25 C27 S \n",
"737 male 35.0 0 0 PC 17755 263.000 B101 C \n",
"438 male 64.0 1 4 19950 263.000 C23 C25 C27 S \n",
"679 male 36.0 0 1 PC 17755 263.000 B51 B53 B55 C \n",
"311 female 18.0 2 2 PC 17608 262.375 B57 B59 B63 B66 C "
]
},
"execution_count": 46,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Replace\n",
"df.loc[df.Fare > 400, 'Fare'] = 263.0\n",
"\n",
"# Check we have removed outliers\n",
"df.sort_values('Fare', ascending=False).head(8)"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"OrderedDict([('Fare',\n",
" <matplotlib.axes._subplots.AxesSubplot at 0x7f2f8fcb91d0>)])"
]
},
"execution_count": 47,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAX8AAAEdCAYAAADkeGc2AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAGZ9JREFUeJzt3X+cXHV97/HXJgvBQChRtwEj5t6i/Sj1ehUVvMGaHyjI\nbQGvoVqlSAlUrGLBChp6iwQfvd5cVB4ULJUC4ZeigkZKFCViQEV5GNRipZUPFBXlx4XlGjQBgkk2\n949zNpnE3exkZ2Znd7+v5+ORx8ycOXPms3Meec93vud7vqdny5YtSJLKMqXbBUiSxp7hL0kFMvwl\nqUCGvyQVyPCXpAIZ/pJUoN5uF6CJLyLmAD8CvlcvmgacmZnfacO2rwCuz8ybhnn+D4EfZ+bjrb5X\nu0XEnsDdmfmfG5bNAT6fma/exW1dAbwSeByYCjwCnJSZTw6x7qjeQ2Wx5a92uSczF2bmQmAJ8KEx\net/FwKwxeq9d1QMMdSLNaE+uWVJ/xvOAfwdO28m6nsCjnbLlr3bpabi/L/AgQETMBpYDuwObgZOA\nF1D9Mjg6Il4LnAW8G7geuBf4fWBNZp46uMGI6AX+Cfi9elvnUAXcm4ADI2JRZj7YsO6n6ve5A3hL\nZu4fEbcCd9ev+1vgSmAfqv8Hf5WZd0VEf2b21du5HrgIWAA8v97evnXtqyLifwDvBzYC38vMMyNi\nBvAFql8/3x7ms9o9Iq4GAvgB1ZflmsyM+n3fDhyUmWfs5PP+Lv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3kHSeOT0DpJUIMNfkgpk\n+EtSgQx/SSqQ4S9JBTL8JalAhr8kFcjwl6QCGf6SVCDDX5IK5PQOHXbKx25j46YBduudwiVnzO92\nOZIE2PLvuI2bBra7laT
"text/plain": [
"<matplotlib.figure.Figure at 0x7f2f8fcb4d30>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"df.boxplot(column='Fare', by='Pclass', return_type='axes', sym='k.')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Feature Embarked"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can analyze the distribution based on the port of embarkation (C = Cherbourg; Q = Queenstown; S = Southampton). "
]
},
{
"cell_type": "code",
"execution_count": 48,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"Embarked\n",
"C 168\n",
"Q 77\n",
"S 644\n",
"dtype: int64"
]
},
"execution_count": 48,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.groupby('Embarked').size()"
]
},
{
"cell_type": "code",
"execution_count": 49,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7f2f8fbdad30>"
]
},
"execution_count": 49,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYQAAAESCAYAAAD9gqKNAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFI1JREFUeJzt3XuQnXV9x/H3uiuRbBKzwBpjEMTbl0FrZywWm1gCoUSt\nd4NajRnGqMVbG/FKq0BEtF4Ko+LYaiyKGTpTLxlrhpEGRJQAGrzfv1pUaBLaLHo0NxI3m+0fzy9w\nNm52T5Z9zlmy79dMhuf8nuc857t7hv08v9/vuXQNDw8jSdKDOl2AJGlqMBAkSYCBIEkqDARJEmAg\nSJIKA0GSBEBPnTuPiJXACmAY6AL+DHga8C/AfuAHmfn6su1bgXNK+yWZ+eU6a5MkjdT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HX\ntPZjSJLur1Z7CGTmRqpHaB62iLiZ6mZ4zwGuy8zBsmobMJ9qSGmg6S0DpV2S1CYtB8L9kZmLIuJJ\nwNWMnHs41DzEuPMTfX0z6enpHvezt2/vbalG3X99fb3098/udBmSJqjWQIiIJwPbMnNzZv4gIrqB\nHRExIzP3UvUatgBbGdkjWADcOta+G43dLdXQaOyaUO06fI3GLgYGdnS6DEljGOug7bAfkHOYTgfe\nDBAR84BZwPXAOWX9MuBaYBNwakTMiYhZwEKqCWxJUpvUHQj/CjwsIr5ONYH8WuBi4NyI+BrQB1yV\nmXuAC4AN5d/qzPRQU5LaqNYho/KHfvkoq5aOsu06YF2d9UiSDq3uHoIk6QHCQJAkAQaCJKkwECRJ\ngIEgSSoMBEkSYCBIkgoDQZIEGAiSpMJAkCQBBoIkqTAQJEmAgSBJKgwESRJgIEiSCgNBkgQYCJKk\nwkCQJAEGgiSpMBAkSYC
"text/plain": [
"<matplotlib.figure.Figure at 0x7f2f8fb5d198>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Distribution\n",
"sns.countplot('Embarked', data=df)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Since there are missing values, we will replace them by the most popular value ('S'), and we will also encode it since it is a categorical variable.\n",
"\n",
"We can see if this has impact on its survival."
]
},
{
"cell_type": "code",
"execution_count": 50,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"Embarked\n",
"C 0.553571\n",
"Q 0.389610\n",
"S 0.336957\n",
"Name: Survived, dtype: float64"
]
},
"execution_count": 50,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.groupby(['Embarked']).Survived.mean()"
]
},
{
"cell_type": "code",
"execution_count": 51,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7f2f8fb017b8>"
]
},
"execution_count": 51,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoA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wM0RsQDYlJnd9e/eCtxa387xwFcOFgCS\npLE33JnA8vrfnxrNyjNzbUSsi4g1QC9wef0+wNMOSyk9P/X29rJx44ZWl1FId/fAs87HHtvAjBkT\n43LkscfOY/LkQ788PtzIYj+tf/wCtfcEvjXS9wQyc/CTPw8Nscyj1C4PSZrgNm7cwN1/+EmOmTb+\ne5Z5du/AK9y/uPF6Dps0/i8Hbd21i3M+cw3HH//SQ15X0XsCHwF+h9p7Aj8BvgbckZnPHXIFkp53\njpk2jTnTx/8R9a7eXnima9/0C6ZNZ9oYHF1PJGW/JyBJGscKn/fU3xO4BPgocAbF3hNQQcuX38TF\nF7+V5ctvanUpkiqk6MhifwP8DHg1tfcEXp6Zo7pZrF+3e/cuVq9eAcDq1SvZvXtXiyuSVBVF7wn8\nHfBbmdlbZjFV1dPTQ19freukvr699PT0cPjh4/+mmqSJr+jloDcaAJL0/FP0TGBDRNwLPADseyIo\nM/97GUVJkpqjaAj8qv5HkvQ8UjQEPldqFZKkligaAnsYOOhLH/AMcPSYVyRJapqiYwzvu4FcH1Fs\nCfDKsoqSJDXHiDvJyMznMnMFcG4J9UiSmqjooDKXDmo6Dnjx2JcjSWqmovcEzmr43AdsA9459uVI\nkpqp6D2B9/Z/rvch9Exm9h3kKy01kfozB/s0l9Q6w40sdirw6cx8R336G8CFwDMRcUFm/kMTahyx\njRs38KkbvsPhM49qdSmF9PUO7JF76dfvo23y1BZVU9zuHU9x9RUXjUmf5pJaY7gzgWXA9QARsRh4\nHfBCavcElgFvLLW6Q3D
"text/plain": [
"<matplotlib.figure.Figure at 0x7f2f8fac9358>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.barplot(x='Embarked', y='Survived', data=df)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"It seems passengers embarked in C (Cherbourg) have a higher chance of survival.\n",
"We can analyse this by sex."
]
},
{
"cell_type": "code",
"execution_count": 52,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7f2f8faf1550>"
]
},
"execution_count": 52,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYEAAAESCAYAAAAbq2nJAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHjFJREFUeJzt3XucVXW9//HXXAUGkBmYMEBULn4w0/zhkYDwSuIlSzua\nmmUaaf28hifTRI95g7z8HC5HLcGDaZadR1amRyHG0lTUc5TMOBaf0hQYoB8DjDAzMMxtnz/2Htwz\nzWUBa+09e9b7+Xj4YK+19vruD6xx3nut71rfb14ikUBEROIpP9sFiIhI9igERERiTCEgIhJjCgER\nkRhTCIiIxJhCQEQkxgqj/gAz+zjwJFDh7g902PZpYA7QDCx19zuirkdERD4U6ZmAmQ0AFgLPdfGW\nBcDngWnADDObEGU9IiLSXtSXgxqA04CNHTeY2SHAFnff4O4J4FlgesT1iIhImkhDwN1b3X1XF5sP\nAKrTljcBH42yHhERaa83dQznZbsAEZG4ibxjuBsbaP/Nf2RqXZeam1sShYUFkRYlItIHdfklO5Mh\n0K4Id19jZoPMbDTJX/5nABd010BNzY4IyxMR6ZvKywd1uS3SEDCzicC9wEFAk5mdDTwFvOfuvwIu\nA34KJIDH3f2dKOsREZH28nJpKOnq6trcKVZEpJcoLx/U5eWg3tQxLCIiGaYQEBGJMYWAiEiMKQRE\nRGJMISAiEmMKARGRGMvmE8M5pbW1lXnz7qGmZgsFBYXU1tZy5ZWzGDNmbLZLExHZawqBgN59969s\n2vR37rprHgBVVeuoqlrH8uVLqa7eRHNzE2eddQ5jx47nhhu+RUXFfbz99iqWLXuG2bO/m+XqJVct\nWbKI5cufZcaM05k58+vZLkf6ID0sFlBzczO33noTAwYM4KijJnLkkUdRW1vLT37yKLfd9j127Wrg\nqqv+L4sW/ZDXX3+NV15ZwZo173HHHXczYMCAbJUtOayhYSdf/eoFJBIJ8vLyefjhH9OvX/9slyU5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ihh4b+95R9E8XPXtR6+tmWfVNc3Npu\neejQgey/f+/79446BDaQ/ObfZgSwMfX6MOBdd68BMLOXgKOBLkOgpmZHtx9WU1PPzpr6bt+zJ3bW\n1FNTU091dW2X79m6tZ6WllZOPfUs5sz5Lueeez6tra3MmvVtqqtraW2FzZvr6NevmZaWVrZsqaeo\nqJaWlla2bt3BmWeew9e//g1GjTqQM888h3nz7mHKlBNobm6hurqWa6+dzbXXXkdxcTFDhw5j+vTP\ndFuPZEdNiD93bfLy024Ry+uwHIKefrZl39TW1rVb3rKljsbG7Dya1V3Y57VNhBwFM5sC3OLup5jZ\nRGB+qhMYM/sI8DJwROrS0HLgVndf0VV71dW13RabjecERADWrHmPu56fH/qdaTX/vYG6v2xl4KFl\nlE4aEVq79Ztruf7EWRp1N0K1tdu59NKv7F5evPhRBg0anJVayssHdfkNItIzAXd/1cxWmtkKoAW4\nwswuAj5w91+Z2T3AC2bWBLzSXQAEoaGkpa8pnTQi1F/+Ih1F3ifg7rM7rFqVtm0xsDjqGkREpHMa\nO0hEJMYUAiIiMaYQEBGJMYWAiEiMKQRERGJMw1GKSKxF8XwRQH19+wcI161bS0lJeE+Wh/UMk0Kg\nj1uyZBHLlz/LjBmnM3Pm17NdjkivE/Y8JG1aG1vaLS98+QfkF4fz4GmQuU6CUgj0YQ0NO6msTA5N\nXVm5jAsuuJB+/fpnuSqR3ieKeUhadjXzQdrygKEDKdiv9/3KVZ9AH9bU1ETbsCCJRCtNTU1ZrkhE\nehuFgIhIjCkERERiTCE
"text/plain": [
"<matplotlib.figure.Figure at 0x7f2f8fabd320>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.barplot(x=\"Embarked\", y='Survived', hue='Sex', data=df)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"There is also an improvement by gender for passengers embarking in Cherbourg."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We have to fill null values (2 null values) and encode this variable, since it is categorical. We will do it after reviewing the rest of features."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Features SibSp"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We analyse the distribution."
]
},
{
"cell_type": "code",
"execution_count": 53,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"SibSp\n",
"0 608\n",
"1 209\n",
"2 28\n",
"3 16\n",
"4 18\n",
"5 5\n",
"8 7\n",
"dtype: int64"
]
},
"execution_count": 53,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.groupby('SibSp').size()"
]
},
{
"cell_type": "code",
"execution_count": 54,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7f2f8fa57588>"
]
},
"execution_count": 54,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYQAAAESCAYAAAD9gqKNAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFbdJREFUeJzt3X+UX3V95/HnNCPBTBIziUMMyZJat/u21O3uupzFDSoQ\nJZSqy9ZgdcWsNbobtnoOpdJz6J7lR1ntuqzQrdrWntRU5OBZYY3WSIWIFgQJDa6t6LZ9i2BJJ8HN\nECZMSEpIJrN/3E/Cd4bM5Dth7vfOJM/HOTncn995DSf5vu7n3u+9366RkREkSfqppgNIkqYHC0GS\nBFgIkqTCQpAkARaCJKmwECRJAHTX+eIRsRZYA4wAXcC/BF4P/CFwCHg4Mz9Ytv1N4JKy/PrM/Fqd\n2SRJo3V16j6EiHgj8A7g54ErM/O7EXEr8DkggduB1wG9wH3AmZnpTRKS1CGdPGV0DfDfgZ/OzO+W\nZZuAC4Dzga9l5nBmPgn8HXBmB7NJ0kmvI4UQEWcB24BhYLBl1U5gCbAYGGhZPlCWS5I6pFMjhA8A\nny3TXS3Lu1646YTLJUk1qfWicovzgA+V6UUty5cC24EdwKvHLN8x0QsePDg80t09awojStJJYdwD\n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nBvY0HUOSJjw4nfQX5EzSG4EPA0TEYmAucDdwSVm/GrgT2AqcFRHzI2IusILqArYkqUPqLoRPA6dF\nxLeoLiD/J+Ba4L0RcS/QC9ycmc8CVwGby5/rMtNDaknqoFpPGZU3+kuPsmrVUbbdCGysM48kaXx1\njxAkSTOEhSBJAiwESVJhIUiSAAtBklRYCJIkwEKQJBUWgiQJsBAkSYWFIEkCLARJUmEhSJIAC0GS\nVFgIkiTAQpAkFRaCJAm
"text/plain": [
"<matplotlib.figure.Figure at 0x7f2f8fa64278>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Distribution\n",
"sns.countplot('SibSp', data=df)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can see that most passengers traveled without siblings or spouses. \n",
"\n",
"We analyse if this had impact on its survival."
]
},
{
"cell_type": "code",
"execution_count": 55,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"SibSp\n",
"0 0.345395\n",
"1 0.535885\n",
"2 0.464286\n",
"3 0.250000\n",
"4 0.166667\n",
"5 0.000000\n",
"8 0.000000\n",
"Name: Survived, dtype: float64"
]
},
"execution_count": 55,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.groupby('SibSp').Survived.mean()"
]
},
{
"cell_type": "code",
"execution_count": 56,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"array([<matplotlib.axes._subplots.AxesSubplot object at 0x7f2f8f9e30f0>,\n",
" <matplotlib.axes._subplots.AxesSubplot object at 0x7f2f8f91a160>], dtype=object)"
]
},
"execution_count": 56,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYQAAAEJCAYAAACUk1DVAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAGLlJREFUeJzt3X+Q3PV93/HnIRCyhM5gchayNMhMbb89LkknmCmthBE/\nbAjDr7RAnYkGx+BMiG08CuCkc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yYDkwAKzKzNVt6Vo6zGx/9XU2713Y\n0rZvebW34m40XY17yCgizgTek5mLgfOBLwA3A3+emUuBjcBVETEbuAE4GzgLuDYijm1X45KkajVy\nDuFx4PLy9ivAHGAp8PVy3lrgA8BpwIbM3JWZ/cATwJJq25Uktcu4h4wycxAYOrj5EWAdcF5m7ivn\nbQfmA/OA4fuuveV8SdIU0PBJ5Yi4BLgKOBd4btiiroNscrD5kqQaavSk8nnApyj2DHZGxM6IODoz\n9wALgC3AVkbuESwAnqy64SHd3bPo6Zk7Yt7o6YmoqlYde5outaaLWbNmTonfhbrWqmNPVddq1LiB\nEBHdwOeAczLz1XL2Y8ClwH3lv48CG4A7y/X3A4sprjhqi76+fnp7dx6Y7umZO2J6IqqqVceepkOt\n6RYq/f17a/+7UNdadeypHbUa1cgewgeB44EHIqILGAR+C/hKRFwNbALuzsyBiFgBrKcIhJWZWc0j\nkiS1XSMnlVcBq8ZYdO4Y664B1lTQlyRpkvnRFZIkwECQJJUMBEkSYCBIkkoGgiQJMBAkSSUDQZIE\nGAiSpJKBIEkCDARJUslAkCQBBoIkqWQgSJIAA0GSVDIQJEmAgSBJKhkIkiTAQJAklRr5TmUi4mTg\nIeC2zLwjIu4C3gu8VK5
"text/plain": [
"<matplotlib.figure.Figure at 0x7f2f8f943f60>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"df.hist(column='SibSp', by='Survived', sharey=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We see that it does not provide too much information. While the survival mean of all passengers is 38%, passengers with 0 SibSp has 34% of probability. Surprisingly, passengers with 1 sibling or spouse have a higher probability, 53%. We are going to see the distribution by gender"
]
},
{
"cell_type": "code",
"execution_count": 57,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"SibSp Sex \n",
"0 female 174\n",
" male 434\n",
"1 female 106\n",
" male 103\n",
"2 female 13\n",
" male 15\n",
"3 female 11\n",
" male 5\n",
"4 female 6\n",
" male 12\n",
"5 female 1\n",
" male 4\n",
"8 female 3\n",
" male 4\n",
"dtype: int64"
]
},
"execution_count": 57,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.groupby(['SibSp', 'Sex']).size()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We see that for SibSp, there is almost the same number of men and women. Now we calculate the survival probability."
]
},
{
"cell_type": "code",
"execution_count": 58,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"SibSp Sex \n",
"0 female 0.787356\n",
" male 0.168203\n",
"1 female 0.754717\n",
" male 0.310680\n",
"2 female 0.769231\n",
" male 0.200000\n",
"3 female 0.363636\n",
" male 0.000000\n",
"4 female 0.333333\n",
" male 0.083333\n",
"5 female 0.000000\n",
" male 0.000000\n",
"8 female 0.000000\n",
" male 0.000000\n",
"Name: Survived, dtype: float64"
]
},
"execution_count": 58,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.groupby(['SibSp', 'Sex']).Survived.mean()"
]
},
{
"cell_type": "code",
"execution_count": 59,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7f2f8f84b710>"
]
},
"execution_count": 59,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYEAAAESCAYAAAAbq2nJAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHyVJREFUeJzt3XucVWXd9/HPHGWYAZkZJhQRkoM/D1k+eEtgnjE8lA/c\nacljWUZ28Bjelk+iGaJ4TBBuj2BTmWVl3ZmmKFhaeXpeQabcFr/EFBjARw4DzAwzzGHv+4+9wT3j\nHNbAXnvPnvV9v16+2Ou4fwzj/u51rWtdV148HkdERKIpP9sFiIhI9igEREQiTCEgIhJhCgERkQhT\nCIiIRJhCQEQkwgrDfgMz+wjwGDDP3e/tsO00YC7QCixx95vCrkdERN4X6pWAmQ0EFgLPdr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qlfcduuVlKnhh5YWUbBfnreTkRylxpVRUQiTF9jpU/oqQ23oaH9Tb5169Z2eT8Gcrv9\nViSTFALSJ/R0Tybo/RjQPRmR3lAISJ/R3T0Z3Y8RCYf+L+ongnZxTdVdk4qaU0SiQSHQT6iLq4js\nDYVAP6IuriLSW+oiKiISYQoBEZEIUwiIiESYQkBEJMIUAr2Ql58yEF9eh2URkRykEOiF/KICyg6t\nAKBsXAX5RepHLyK5Tf0De6l8wnDKJwzPdhkiImmhKwERkQhTCIiIRJhCQEQkwhQCIiIRphAQEYkw\nhYCISIQpBEREIkwhICISYQoBEZEIUwiIiESYQiBCNACe7Ivq6kVMnz6N6upF2S5F0kghECEaAE/2\nVlNTI8uWLQFg2bKnaWp
"text/plain": [
"<matplotlib.figure.Figure at 0x7f2f8f890358>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.barplot(x=\"SibSp\", y='Survived', hue='Sex', data=df)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We observe that when SibSp > 2, the survival probability decreases to the half. We are going to check if there is a difference in the age. "
]
},
{
"cell_type": "code",
"execution_count": 60,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"SibSp Sex \n",
"0 female 28.631944\n",
" male 32.615443\n",
"1 female 30.738889\n",
" male 29.461505\n",
"2 female 16.541667\n",
" male 28.230769\n",
"3 female 16.500000\n",
" male 8.750000\n",
"4 female 8.333333\n",
" male 6.416667\n",
"5 female 16.000000\n",
" male 8.750000\n",
"8 female NaN\n",
" male NaN\n",
"Name: Age, dtype: float64"
]
},
"execution_count": 60,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.groupby(['SibSp', 'Sex']).Age.mean()"
]
},
{
"cell_type": "code",
"execution_count": 61,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7f2f8f7dab38>"
]
},
"execution_count": 61,
"metadata": {},
"output_type": "execute_result"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o0WM45JBDueWWO7nookv40Y/mAsGc+3vvPZGf/OQBli9/jdGjRzN//v289tqr\nNDTUU1Ozngsv/B633vpjPv3pf2Lx4kVdXv/WW2/i+uvncOutd7LjjhU888zSKH5MyUFqPki/JOtL\n70/XGORG99jy5a9RW7uBp59eCEBT07bhuPvsMxGAESMq2XPPvRKPR1BfX8+IEZX8+Me30djYyLp1\nHzN16rZpHmpq1rNy5Uouu+y7tLe309jYyI47VmTwp5JcpuCXfkl2HUKq1yBA7tzesKiomAsu+B77\n7rvfJ9YVFBT2+Li9PWjRn3HGVzjooEP4+c8forFx89b1hYVFVFVVcdttd4VbvMRS7Lt6pP86rkPo\n6V/JsMou25YMq+x123TdHzdqEyfux/PPPwPAihXv8sgjP+tz++D2Du3U1tYyatQYmpqaeOmlF2hu\n3nY/omHDhpGXl8d7760A4Je/fJh33307rB9BYkYt/hyXl99piEhet+UcszmNk9al+lp5eTBjxilc\ne+0P+Na3vk5bWxsXXPDdjrVdtuv6OI/p0/+dSy75DmPG7MqMGacwd+6NXW7McvHFl3PddVdSXFxM\nZeVOTJs2fft/MBEU/Dkvv6iA8r1GUP/39ZRPGEF+UXb3p/dmzJixzDr5srS/Zl923nkX5s8Pxttf\nc83sT6x/9NH/2fq4Y7vOj0888d848cR/2/r84YdP6bJ+//0PYN68+wZUu0hfFPwxUHHwKCoOHhV1\nGaEqKCjI+nMFIpmiPn4
"text/plain": [
"<matplotlib.figure.Figure at 0x7f2f8f890a90>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.barplot(x=\"SibSp\", y='Age', hue='Sex', data=df)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Effectively, when SibSp > 3, age is lower. We are going to check the relationship with Pclass."
]
},
{
"cell_type": "code",
"execution_count": 62,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"SibSp Pclass\n",
"0 1 137\n",
" 2 120\n",
" 3 351\n",
"1 1 71\n",
" 2 55\n",
" 3 83\n",
"2 1 5\n",
" 2 8\n",
" 3 15\n",
"3 1 3\n",
" 2 1\n",
" 3 12\n",
"4 3 18\n",
"5 3 5\n",
"8 3 7\n",
"dtype: int64"
]
},
"execution_count": 62,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.groupby(['SibSp', 'Pclass']).size()"
]
},
{
"cell_type": "code",
"execution_count": 63,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"SibSp Pclass\n",
"0 1 0.562044\n",
" 2 0.416667\n",
" 3 0.236467\n",
"1 1 0.746479\n",
" 2 0.581818\n",
" 3 0.325301\n",
"2 1 0.800000\n",
" 2 0.500000\n",
" 3 0.333333\n",
"3 1 0.666667\n",
" 2 1.000000\n",
" 3 0.083333\n",
"4 3 0.166667\n",
"5 3 0.000000\n",
"8 3 0.000000\n",
"Name: Survived, dtype: float64"
]
},
"execution_count": 63,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.groupby(['SibSp', 'Pclass']).Survived.mean()"
]
},
{
"cell_type": "code",
"execution_count": 64,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7f2f8f8a3a58>"
]
},
"execution_count": 64,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYEAAAESCAYAAAAbq2nJAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHIdJREFUeJzt3Xt0VeWd//F3LiSEJECAIFoG1Eq/eKljvbSISpfgtauj\nrdWfVq2Mjk6X4gVLf9MRb0VFnbYgolVHZrBV66V1LOpvxELVKl7GKTpeWsevF64BLyEcCIlJCMn5\n/bEPcBIJOZC9z8nJ/rzWcnH2JXt/A8fzOfvZ+3megmQyiYiIxFNhrgsQEZHcUQiIiMSYQkBEJMYU\nAiIiMaYQEBGJMYWAiEiMFUd9AjM7CFgAzHb3uzptOxa4GdgCuLtfGHU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3/VzF43s5eBNmCKmU0GNrj7E2b2\nc+BPZtYKvOLuL0dZj4iIdBT5PQF3n95p1Ttp2+YB86KuQUREdkw9hkVEYkwhICISYwoBEZEYy+ie\ngJmdApwE7J1atQJ4xt2fjKYsERHJhp2GgJkdBDxI0Kv3j8B/pjaNBv7ezGYA57r7XyOtUkREItHd\nlcDtwFmpcX86u8vMxgJ3AseFXpmIiESuuxA4yd1bAcysChgDJAF393p3f8/MTo66SBERicZObwyn\nBcCVwIfAHOAO4CMzuzh9HxERyT+ZdhabDOzr7hth21XB88DdURUmIiLRy/QR0U+2BgBAatC35dGU\nJCIi2ZLplcAyM1tAMCBcIXAsUGdmFwC4+/yI6hMRkQhlGgJlQAI4IrVcDxQBxxDcKFYIiIjkoYxC\nwN3P3/razAYDG909GVl
"text/plain": [
"<matplotlib.figure.Figure at 0x7f2f8f8cd240>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.barplot(x=\"Sex\", y='SibSp', hue='Pclass', data=df)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We see that in 3rd class, females had higher SibSp."
]
},
{
"cell_type": "code",
"execution_count": 65,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7f2f8f6b6e80>"
]
},
"execution_count": 65,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYEAAAESCAYAAAAbq2nJAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHsRJREFUeJzt3XmcVOWV//FPLyxNN0uzKCIDGsSDSxJFxyguiaBGs5kY\nMxo1cYkziWHiEjKTETWKEfVnAlEniQn80ho1LjGJC7+4QBaNC/E3aFwyjicKCjRohKZZuumGprvm\nj6qG6rK76nZTt25X3e/79eJl3bVOtd117n2e556nLJFIICIi8VQedQAiIhIdJQERkRhTEhARiTEl\nARGRGFMSEBGJMSUBEZ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kiSgIloLW1hSVLHgNgyZLHaW3NX7+IiJQ2\nJYES0NbWRiKRACCR6KCtrS3iiESkWCgJiIjEmJKAiEiMKQmIiMSYkoCISIwpCYiIxJiSgIhIjCkJ\niIjEWEmVjRAJqqf5qLPN7LZmTX1BYhMpJCUBiaXuZnWD7DO7bXrvLUYfVbAQRQoicBIwsz2BianF\nle7+93BCEimMzFndIPvMbq1NG4AthQtQpAByJgEz+yfgcmAvYHVq9QQzWwPc4O4PhBifiIiEKGsS\nMLM7Uvuc5+4vZ2z7MPBvZvZJdz8vtAj7oK5uAYsXP8pJJ32CCy74l6jDERHpt3KNDnrQ3c/JTAAA\n7v6yu58DPBhOaH2jipoiIsHlag46JHXF3y13v9bdH85zTLulu4qagwdXRRyViEj/lCsJdG6fnPr3\nJ6AC+CjwlxDjEhGRAsi
"text/plain": [
"<matplotlib.figure.Figure at 0x7f2f8f61f588>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.barplot(x=\"SibSp\", y='Survived', hue='Pclass', data=df)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"It seems that SibSp is relevant for determining the survival rate."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Feature ParCh"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The feature Parch (Parents-Children Aboard) is somewhat related to the previous one, since it reflects family ties. It is well known that in emergencies, family groups often all die or evacuate together, so it is expected that it will also have an impact on our model."
]
},
{
"cell_type": "code",
"execution_count": 66,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"Parch\n",
"0 678\n",
"1 118\n",
"2 80\n",
"3 5\n",
"4 4\n",
"5 5\n",
"6 1\n",
"dtype: int64"
]
},
"execution_count": 66,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.groupby('Parch').size()"
]
},
{
"cell_type": "code",
"execution_count": 67,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7f2f8f575320>"
]
},
"execution_count": 67,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYQAAAESCAYAAAD9gqKNAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFUNJREFUeJzt3X+QXWd93/H3sotFtJbQSlkLWY4FSWa+jMMkKfGMGZki\nS47l0OCYIEMIiuJG0NjFtKoT6JiZWDYu7VASkwYzKR0Fg/GYtDhRCIqLkV2wsbBApCQQ2uYLsYOV\nlZxosVde/cDyerX94zyS765Xq7vSnnt2pfdrRqN7zj336rM7q/3c5zznR9fY2BiSJL2k6QCSpNnB\nQpAkARaCJKmwECRJgIUgSSosBEkSAD11vnlEbAQ2AGNAF/BzwOuB/wocBb6dmTeUbd8HXFPW35aZ\nX6gzmyRpvK5OnYcQEW8A3gr8FPDezPxmRNwDfBpI4F7gdUAf8AhwUWZ6koQkdUgndxltBv4z8MrM\n/GZZtw24AlgNfCEzRzPzB8D3gYs6mE2SznodKYSIuBjYDYwCQy1P7QOWAUuBwZb1g2W9JKlDOjVC\neBfwqfK4q2V914s3nXK9JKkmtU4qt7gMeE95vKRl/XJgD7AXePWE9XunesPnnx8d6+npnsGIknRW\nOOEH7toLISKWAQcy8/my/P8iYmVmPgq8Bfgo8D3gtyJiM3AecH5m/t+p3ndo6HDNySXpzNPfv+CE\nz3VihLCMaq7gmBuB/xYRXcDXM/NLABGxherooqPA9R3IJUlq0bHDTmfa4OCBuRlckhrU37/ghLuM\nPFNZkgRYCJKkolNHGdVudHSUgYHdTceY1AUXXEh3t0dESZrdzphCGBjYzZ7/fi/LFy1uOso4e/Y/\nDW9/KytWvKrpKJI0pTOmEACWL1rMiiX9TceQpDnJOQRJEmAhSJIKC0GSBFgIkqTCQpAkARaCJKmw\nECRJgIUgSSosBEkSYCFIkgoLQZIEWAiSpMJCkCQBFoIkqbAQJEmAhSBJKiwESRJgIUiSitpvoRkR\n64H3ASPA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MIvwEQEYuBscycrbcvliSdonZ3Ga0E7gYWAF0R8RTwa5n5l3WGkyR1TruT\nyh8Crs7M8zKzH/hV4CP1xZIkdVq7hTCamd85tpCZf0XLJSwkSXNfu5PKRyNiHfBAWf4FYLSeSJKk\nJrRbCNcDdwB/RHW3tL8G/lVdoSRJndfuLqO1wJHM7MvMJVQ3yfkX9cWSJHVau4Xwa8BbWpbXAu+Y\n+TiSpKa0u8uoOzNb5wzGeOFWmicUET8CfApYCswDPgh8i+oQ1pcATwIbMnMkItYDm6jmJrZk5p3t\nfhGSpNPXbiF8PiIeBR6h+kV+OfCnbbzuKuAbmfl7EXEh1aT0V4GPZeafRsR/BDZGxN3AzcDFVEcv\nfSMitmbm/ml+PZKkU9TumcofjIiHgEuoRgfvzsyvtfG6z7YsXgj8A7AKuK6s2wa8F/gusCszDwJE\nxA7gUuC+9r4MSdLpaneEQGbuoLqF5rRFxFepLoZ3FfBAZo6Up/YBy6h2KQ22vGSwrJckdUjbhXA6\nMvPSiPhp4B7Gzz2caB7ipPMTfX3z6enpPr48PNzLbL3AUl9fL/39C5qOIUlTqrUQIuK1wL7MHMjM\nb0dEN3AgIuZl5hGqUcMeYC/jRwTLgZ1TvffQ0OEJy4dmNPtMGho6xODggaZjSNKUH06nfYOcaXoD\n8NsAEbEUOBd4ELimPL8OuB/YBVwcEQsj4lxgJdUEtiSpQ+ouhI8D50XEV6gmkP81cAtwbUQ8DPQB\nd2Xms8BNwPby59bM9CO1JHVQrbuMyi/69ZM8tXaSbbcCW+vMI0k6sbpHCJKkOcJCkCQBFoIkqbAQ\nJEmAhSBJKiwESRJgIUiSCgtBkgRYCJKkwkKQJAEWgiSpsBAkSYCFIEkqLARJEmAhSJIKC0GSBFgI\nkqTCQpAkARaCJKmwECR
"text/plain": [
"<matplotlib.figure.Figure at 0x7f2f8f57c550>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Distribution\n",
"sns.countplot('Parch', data=df)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We see most of the passenger had any parent or children.\n",
"\n",
"We analyze now the relationship with Survived."
]
},
{
"cell_type": "code",
"execution_count": 68,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"Parch\n",
"0 0.343658\n",
"1 0.550847\n",
"2 0.500000\n",
"3 0.600000\n",
"4 0.000000\n",
"5 0.200000\n",
"6 0.000000\n",
"Name: Survived, dtype: float64"
]
},
"execution_count": 68,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.groupby('Parch').Survived.mean()"
]
},
{
"cell_type": "code",
"execution_count": 69,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7f2f8f53e6d8>"
]
},
"execution_count": 69,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXUAAAESCAYAAAACDEUqAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3X901PWd7/FnQkIIJJAAEwLE8CvyTgAVQSgFxR+0rlQR\n67qut71W27La1u2pPffcvbeebre9e09v7/ZKrXtOt9btat1qq9ZW8VfFir9AVH4oAiYfQH6HQBIg\n/P6duX/MYKeRSSbJzHx/zOtxjsdkvl+Y9/eEvOYzr/nOd/Ki0SgiIhIO+V4PICIi6aNQFxEJEYW6\niEiIKNRFREJEoS4iEiIKdRGREClIZSczWwjMANqBu51zKxO2VQG/AQqB1c65b2RiUBER6VqXK3Uz\nmw3UOOdmAguA+zvsci/wY+fcDOBMPORFRMQDqdQvc4CnAZxzDUCZmZUAmFkecCnwbHz7N51zOzM0\nq4iIdCGVUK8EWhK+b43fBhABDgP3mdmbZvbDNM8nIiLd0JMXSvM6fD0S+AlwOXCxmc1Nx2AiItJ9\nqbxQuos/r8wBRgBN8a9bga3Oua0AZvYKMBF4MdlfFo1Go3l5eck2i2RNNBpl8Tvb+eWidRw7cRqA\ny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+W3ul4vrqI3+R8qB87\ncZoHFq3nTHuUBddNYGCAP1lIssOqyzh5qp2tTeHtbyW4cj7UH315A837jzH3U9VMHDPY63EkANSr\ni5/ldKi/vX43b63bzejKUj4/e6zX40hAJPbqIn6Ts6He3HaMR15yFPXtw53zJ+paHpIy9eriZzmZ\nZKfPxC4DcPzkGW69ejz
"text/plain": [
"<matplotlib.figure.Figure at 0x7f2f8f4a3278>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"#Probability survival\n",
"df.groupby('Parch').Survived.mean().plot()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We see the probability of surviving is higher in 2 and 3. Sincethere were too few rows for Parch >= 3, this part is not relevant."
]
},
{
"cell_type": "code",
"execution_count": 70,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"array([<matplotlib.axes._subplots.AxesSubplot object at 0x7f2f8f4fbe10>,\n",
" <matplotlib.axes._subplots.AxesSubplot object at 0x7f2f8f3c1240>], dtype=object)"
]
},
"execution_count": 70,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYQAAAEBCAYAAAB4wNK4AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFnFJREFUeJzt3X+QXWWd5/F3g0KbkF4c5hqyTcE4pfu1LGtmFtlhN5ki\nIQiupchuAeXWZFklYy0zisUAOhtrJxKzU7uODJSrDuVsMAoUbgFTPWgMYHR0mYlmNliOMPzhdzUy\nwSRILkjoJMUlsdP7xzkZ2+aGPt333B9Nv19VXbn33Ofc79P33qc/Off8eIYmJyeRJOmkfndAkjQY\nDARJEmAgSJJKBoIkCTAQJEklA0GSBMCr+t0BvbyIWA3cDCwGdgNXZ+a+/vZK6o+IeBXwp8D1wFmO\nhXq5hTDAImIR8L+BtZn5JuCrwF/0t1dSX30ZGAc8gaoLDITBthrYlZmPlvc3A5dExOI+9knqp42Z\n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TUh\nSZoHquxU3gRsavPQXW3ajgFjNfRLktRjnqksSQIMBElSyUCQJAEGgiSpVOk8BEndteFPP8eTzaNz\nWveNo6fx/v94Rc090kJkIEgD4PnWSTQnz57TusteaM7cSKrAr4wkSYCBIEkqGQiSJMBAkCSVDARJ\nEmAgSJJKBoIkCTAQJEklA0GSBFSfQvOTwO8AJwOfAB6hmA/hJOAp4KrMPBoRayhmSZsANmXm5q70\nWpJUuxm3ECJiFfDmzFwOvAP4FLAR+GxmrgR2AWsjYhGwHlgNXAhcHxGnd6vjkqR6VfnK6GHgyvL2\nAWAxsBL4SrlsC3AxcD6wMzMPZWYL2A6sqLe7kqRuqTKF5iTwQnn394CtwNsz8/ilGfcDy4ClwNSr\nbDXL5ZKkeaDy1U4j4jJ
"text/plain": [
"<matplotlib.figure.Figure at 0x7f2f8f47c390>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"df.hist(column='Parch', by='Survived', sharey=True)"
]
},
{
"cell_type": "code",
"execution_count": 71,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th>Survived</th>\n",
" <th>SibSp</th>\n",
" <th>Parch</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Pclass</th>\n",
" <th>Sex</th>\n",
" <th>Parch</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th rowspan=\"7\" valign=\"top\">1</th>\n",
" <th rowspan=\"3\" valign=\"top\">female</th>\n",
" <th>0</th>\n",
" <td>0.984375</td>\n",
" <td>0.484375</td>\n",
" <td>64</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1.000000</td>\n",
" <td>0.411765</td>\n",
" <td>17</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>0.846154</td>\n",
" <td>1.076923</td>\n",
" <td>13</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"4\" valign=\"top\">male</th>\n",
" <th>0</th>\n",
" <td>0.363636</td>\n",
" <td>0.262626</td>\n",
" <td>99</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>0.285714</td>\n",
" <td>0.357143</td>\n",
" <td>14</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>0.625000</td>\n",
" <td>0.750000</td>\n",
" <td>8</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>0.000000</td>\n",
" <td>1.000000</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"7\" valign=\"top\">2</th>\n",
" <th rowspan=\"4\" valign=\"top\">female</th>\n",
" <th>0</th>\n",
" <td>0.888889</td>\n",
" <td>0.333333</td>\n",
" <td>45</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>0.944444</td>\n",
" <td>0.722222</td>\n",
" <td>18</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>1.000000</td>\n",
" <td>0.545455</td>\n",
" <td>11</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>1.000000</td>\n",
" <td>1.500000</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"3\" valign=\"top\">male</th>\n",
" <th>0</th>\n",
" <td>0.089888</td>\n",
" <td>0.224719</td>\n",
" <td>89</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>0.500000</td>\n",
" <td>1.071429</td>\n",
" <td>14</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>0.400000</td>\n",
" <td>0.400000</td>\n",
" <td>5</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"13\" valign=\"top\">3</th>\n",
" <th rowspan=\"7\" valign=\"top\">female</th>\n",
" <th>0</th>\n",
" <td>0.588235</td>\n",
" <td>0.341176</td>\n",
" <td>85</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>0.480000</td>\n",
" <td>1.240000</td>\n",
" <td>25</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>0.320000</td>\n",
" <td>2.560000</td>\n",
" <td>25</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>0.500000</td>\n",
" <td>0.500000</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>0.000000</td>\n",
" <td>0.500000</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>0.250000</td>\n",
" <td>0.500000</td>\n",
" <td>4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>0.000000</td>\n",
" <td>1.000000</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"6\" valign=\"top\">male</th>\n",
" <th>0</th>\n",
" <td>0.121622</td>\n",
" <td>0.135135</td>\n",
" <td>296</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>0.266667</td>\n",
" <td>1.900000</td>\n",
" <td>30</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>0.166667</td>\n",
" <td>4.055556</td>\n",
" <td>18</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>0.000000</td>\n",
" <td>1.000000</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>0.000000</td>\n",
" <td>1.000000</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>0.000000</td>\n",
" <td>1.000000</td>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Survived SibSp Parch\n",
"Pclass Sex Parch \n",
"1 female 0 0.984375 0.484375 64\n",
" 1 1.000000 0.411765 17\n",
" 2 0.846154 1.076923 13\n",
" male 0 0.363636 0.262626 99\n",
" 1 0.285714 0.357143 14\n",
" 2 0.625000 0.750000 8\n",
" 4 0.000000 1.000000 1\n",
"2 female 0 0.888889 0.333333 45\n",
" 1 0.944444 0.722222 18\n",
" 2 1.000000 0.545455 11\n",
" 3 1.000000 1.500000 2\n",
" male 0 0.089888 0.224719 89\n",
" 1 0.500000 1.071429 14\n",
" 2 0.400000 0.400000 5\n",
"3 female 0 0.588235 0.341176 85\n",
" 1 0.480000 1.240000 25\n",
" 2 0.320000 2.560000 25\n",
" 3 0.500000 0.500000 2\n",
" 4 0.000000 0.500000 2\n",
" 5 0.250000 0.500000 4\n",
" 6 0.000000 1.000000 1\n",
" male 0 0.121622 0.135135 296\n",
" 1 0.266667 1.900000 30\n",
" 2 0.166667 4.055556 18\n",
" 3 0.000000 1.000000 1\n",
" 4 0.000000 1.000000 1\n",
" 5 0.000000 1.000000 1"
]
},
"execution_count": 71,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.groupby(['Pclass', 'Sex', 'Parch'])['Parch', 'SibSp', 'Survived'].agg({'Parch': np.size, 'SibSp': np.mean, 'Survived': np.mean})"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We observe that Parch has an important impact for men in first and second class. We are going to check the age."
]
},
{
"cell_type": "code",
"execution_count": 72,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"Survived 0.439024\n",
"Age 27.871951\n",
"dtype: float64"
]
},
"execution_count": 72,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.query('(Sex == \"male\") and (Pclass == [1, 2]) and (Parch == [1, 2])')[['Survived', 'Age']].mean()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We see that in those cases, the age is 27. We can compare with the rest of men if first and second class."
]
},
{
"cell_type": "code",
"execution_count": 73,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"Survived 0.269565\n",
"Age 36.063750\n",
"dtype: float64"
]
},
"execution_count": 73,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.query('(Sex == \"male\") and (Pclass == [1, 2])')[['Survived', 'Age']].mean()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We observe that there is a significant difference, so we suspect that this feature has impact of men in first and second class."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Recap: Filling null values"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Feature Age: null values"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We fill null values of Age with its median."
]
},
{
"cell_type": "code",
"execution_count": 74,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"count 891.000000\n",
"mean 29.361582\n",
"std 13.019697\n",
"min 0.420000\n",
"25% 22.000000\n",
"50% 28.000000\n",
"75% 35.000000\n",
"max 80.000000\n",
"Name: AgeFilled, dtype: float64"
]
},
"execution_count": 74,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# We create a new feature to maintain the original \n",
"df['AgeFilled'] = df['Age'].fillna(df['Age'].median())\n",
"df['AgeFilled'].describe()"
]
},
{
"cell_type": "code",
"execution_count": 75,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7f2f8f360ba8>"
]
},
"execution_count": 75,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAW8AAAEDCAYAAAD6CoU1AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAEXpJREFUeJzt3X+QXWV9x/H3koVgku2wMLcxbmu0aL+UdjpDtGiBkpCG\npE5FWxIGgUnR6Mi06NRWLfqHoqnTiTr4Axx/DkhIBfxBS92xQxACOiNWaaGibfM1RhuURLLa1S5G\n0g3Z/nFvdDfJ3h+bPbn7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BDyYmSuAS4H3ARuBD2XmcmAnsKGyCiVJR2jZ\n8s7Mz0z647OB7wPLgasa+4aBNwIfm/XqJElH1fbaJhHxFWCIekv8i5O6SfYCSyqoTZI0jbbDOzPP\njYjfBT4FTF7patpVrw4ZHFxAf/+8GZQn1ReO8h7SVO0MWC4D9mbmDzLzkYiYB4xFxPzM3E+9Nb67\n2TVGR/fNTrXqSVWv+Hc8VhWE6n+Hnn6a/YXfzoDl+dT7tImIxcAi4B5gXeP4WuCuYytRktSJdrpN\nPgrcGBFfBk4G/hz4N2BLRLwW2AVsrq5ESdLh2nna5EngiqMcWj375UiS2uEMS0kqkK9B05z26kc/\nz7dfc0ul9/h2pVeve/VJpwDVvs5NvcXw1px247Nf9rR4h+WmTds4t9I7qNfYbSJJBTK8JalAhrck\nFcjwlqQCGd6SVCDDW5IKZHhLUoEMb0kqkOEtSQUyvCWpQIa3JBXI8JakAhneklQgw1uSCuSSsJrz\nNmza1u0SjtnCk/1PTbOrb2JiovKbjIyMVX8TaYY2bNpW+Zrh0kzUagN90x1rqzkQEe8BzgPmAZuA\nB4Et1Ltd9gDrM3P82Eu
"text/plain": [
"<matplotlib.figure.Figure at 0x7f2f8f9461d0>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Bug: if you include Seaborn, add 'sym='k.' to show the outliers\n",
"df.boxplot(column='AgeFilled', return_type='axes', sym='k.')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Another alternative is to use the function interpolate()."
]
},
{
"cell_type": "code",
"execution_count": 76,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"count 891.000000\n",
"mean 29.726061\n",
"std 13.902353\n",
"min 0.420000\n",
"25% 21.000000\n",
"50% 28.500000\n",
"75% 38.000000\n",
"max 80.000000\n",
"Name: AgeFilled, dtype: float64"
]
},
"execution_count": 76,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df['AgeFilled'] = df['Age'].interpolate()\n",
"df['AgeFilled'].describe()"
]
},
{
"cell_type": "code",
"execution_count": 77,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7f2f8f2c04a8>"
]
},
"execution_count": 77,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAW8AAAEDCAYAAAD6CoU1AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAEQ9JREFUeJzt3X+QXWV9x/H3sivBhO2wMHdi3I7Rov1S2ukM0aIDlIQ0\nkHYq2pJYJEyqpFamFae0atE/lBptB3W0Fhx/dVCQiqhNS7tjh/AjIDPiIBYq2jbfxmhjTSJZ7WJX\nozHJbv+4N7rZZO+PzZ69++S+XzPMvXvuj/PZmcxnH55zznP6JicnkSSV5ZRuB5Akdc7ylqQCWd6S\nVCDLW5IKZHlLUoEsb0kq0ECrN0TEEuATwBBwKrAZ+A7wIWACeDIzX1dlSEnS0doZeb8a2J6Zq4H1\nwN8Afw28PjN/HTgjItZWF1GSNF075f1d4KzG87OA7wHPy8zHG9tGgDUVZJMkzaBleWfmp4HlEbED\neAh4EzA25S37gGWVpJMkHVfL8o6Iq4FdmfkCYDXwd9Pe0ldFMEnSzFoesAQuBLYCZOZXI+KZ0z43\nDOxp9gWHDh2eHBjon3VIqSpX3DDCwUMTnDpwClvedXm340jTzTg4bqe8vw68BPjHiFgOjAPfjIgL\nM/MLwBXAzc2+YGxsfwdZpflzyXnDPPTEbladN8zo6Hi340hHqdUGZ3ytr9Wqgo1TBT8GLAX6gbdS\nP1Xwo9T/KjyamW9s9h2jo+MuXagFq1YbtLi1INVqgzOOvFuW91ywvLWQWd5aqJqVt1dYSlKBLG9J\nKpDlLUkFsrwlqUCWtyQVyPKWpAJZ3pJUIMtbkgpkeUtSgSxvSSqQ5S1JBbK81dPuemAHV9wwwl0P\n7Oh2FKkjlrd62rbHd3Pw0AQPPrG721Gkjlje6mmrV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
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Bug: if you include Seaborn, add 'sym='k.' to show the outliers\n",
"df.boxplot(column='AgeFilled', return_type='axes', sym='k.')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Feature Embarking: null values"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We see most passengers are in 'S'. There were also missing values."
]
},
{
"cell_type": "code",
"execution_count": 78,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"2"
]
},
"execution_count": 78,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df['Embarked'].isnull().sum()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As we discussed previously, we will replace these missing values by the most popular one (mode): S."
]
},
{
"cell_type": "code",
"execution_count": 79,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 79,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#Replace nulls with the most common value\n",
"df['Embarked'].fillna('S', inplace=True)\n",
"df['Embarked'].isnull().any()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Feature Cabin: null values"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"source": [
"We are going to analyse Cabin in the exercise"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Encoding categorical features"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Recap: encoding categorical features"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In the previous notebook we saw how to encode categorical features. We are going to explore an alternative way."
]
},
{
"cell_type": "code",
"execution_count": 80,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"#df = df_original.copy()\n",
"#df['SexEncoded'] = df.Sex\n",
"#\n",
"#df.loc[df[\"SexEncoded\"] == 'male', \"SexEncoded\"] = 0\n",
"#df.loc[df[\"SexEncoded\"] == \"female\", \"SexEncoded\"] = 1\n",
"#\n",
"#df['EmbarkedEncoded'] = df.Embarked\n",
"#df.loc[df[\"EmbarkedEncoded\"] == \"S\", \"EmbarkedEncoded\"] = 0\n",
"#df.loc[df[\"EmbarkedEncoded\"] == \"C\", \"EmbarkedEncoded\"] = 1\n",
"#df.loc[df[\"EmbarkedEncoded\"] == \"Q\", \"EmbarkedEncoded\"] = 2\n",
"#df.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Encoding Categorical Variables as Binary ones"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As we see previously, translating categorical variables into integer can introduce an order. In our case, this is not a problem, since *Sex* is a binary variable, and we can consider there exists an order in *Pclass*.\n",
"\n",
"Nevertheless, we are going to introduce a general approach to encode categorical variables using some facilities provided by scikit-learn."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**LabelEncoder** transform categories into integers (0, 1, ...). We are going to use it for *Sex*."
]
},
{
"cell_type": "code",
"execution_count": 81,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>PassengerId</th>\n",
" <th>Survived</th>\n",
" <th>Pclass</th>\n",
" <th>Name</th>\n",
" <th>Sex</th>\n",
" <th>Age</th>\n",
" <th>SibSp</th>\n",
" <th>Parch</th>\n",
" <th>Ticket</th>\n",
" <th>Fare</th>\n",
" <th>Cabin</th>\n",
" <th>Embarked</th>\n",
" <th>SexCoded</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>Braund, Mr. Owen Harris</td>\n",
" <td>male</td>\n",
" <td>22.0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>A/5 21171</td>\n",
" <td>7.2500</td>\n",
" <td>NaN</td>\n",
" <td>S</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>Cumings, Mrs. John Bradley (Florence Briggs Th...</td>\n",
" <td>female</td>\n",
" <td>38.0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>PC 17599</td>\n",
" <td>71.2833</td>\n",
" <td>C85</td>\n",
" <td>C</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>3</td>\n",
" <td>1</td>\n",
" <td>3</td>\n",
" <td>Heikkinen, Miss. Laina</td>\n",
" <td>female</td>\n",
" <td>26.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>STON/O2. 3101282</td>\n",
" <td>7.9250</td>\n",
" <td>NaN</td>\n",
" <td>S</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>4</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>Futrelle, Mrs. Jacques Heath (Lily May Peel)</td>\n",
" <td>female</td>\n",
" <td>35.0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>113803</td>\n",
" <td>53.1000</td>\n",
" <td>C123</td>\n",
" <td>S</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>Allen, Mr. William Henry</td>\n",
" <td>male</td>\n",
" <td>35.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>373450</td>\n",
" <td>8.0500</td>\n",
" <td>NaN</td>\n",
" <td>S</td>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" PassengerId Survived Pclass \\\n",
"0 1 0 3 \n",
"1 2 1 1 \n",
"2 3 1 3 \n",
"3 4 1 1 \n",
"4 5 0 3 \n",
"\n",
" Name Sex Age SibSp \\\n",
"0 Braund, Mr. Owen Harris male 22.0 1 \n",
"1 Cumings, Mrs. John Bradley (Florence Briggs Th... female 38.0 1 \n",
"2 Heikkinen, Miss. Laina female 26.0 0 \n",
"3 Futrelle, Mrs. Jacques Heath (Lily May Peel) female 35.0 1 \n",
"4 Allen, Mr. William Henry male 35.0 0 \n",
"\n",
" Parch Ticket Fare Cabin Embarked SexCoded \n",
"0 0 A/5 21171 7.2500 NaN S 1 \n",
"1 0 PC 17599 71.2833 C85 C 0 \n",
"2 0 STON/O2. 3101282 7.9250 NaN S 0 \n",
"3 0 113803 53.1000 C123 S 0 \n",
"4 0 373450 8.0500 NaN S 1 "
]
},
"execution_count": 81,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from sklearn.preprocessing import LabelEncoder, OneHotEncoder\n",
"\n",
"df = df_original.copy() # take original df\n",
"\n",
"# We define here the categorical columns have non integer values, so we need to convert them\n",
"# into integers first with LabelEncoder. This can be omitted if the are already integers.\n",
"\n",
"label_enc = LabelEncoder()\n",
"label_sex = label_enc.fit_transform(df['Sex'])\n",
"df['SexCoded'] = label_sex\n",
"\n",
"df.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Ok, we see it has been easy and we have *Sex* as a binary variable.\n",
"\n",
"Now we are going to do the same with *Embarked* and *Pclass*. There are several alternatives in scikit-learn, such as *DictVectorizer* or *OneHotEncoder*.\n",
"\n",
"We are going to use *pd.get_dummies*, which provides a very easy-to-use way to encode categorical variables."
]
},
{
"cell_type": "code",
"execution_count": 82,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>PassengerId</th>\n",
" <th>Survived</th>\n",
" <th>Name</th>\n",
" <th>Sex</th>\n",
" <th>Age</th>\n",
" <th>SibSp</th>\n",
" <th>Parch</th>\n",
" <th>Ticket</th>\n",
" <th>Fare</th>\n",
" <th>Cabin</th>\n",
" <th>SexCoded</th>\n",
" <th>Embarked_C</th>\n",
" <th>Embarked_Q</th>\n",
" <th>Embarked_S</th>\n",
" <th>Pclass_1</th>\n",
" <th>Pclass_2</th>\n",
" <th>Pclass_3</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>Braund, Mr. Owen Harris</td>\n",
" <td>male</td>\n",
" <td>22.0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>A/5 21171</td>\n",
" <td>7.2500</td>\n",
" <td>NaN</td>\n",
" <td>1</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2</td>\n",
" <td>1</td>\n",
" <td>Cumings, Mrs. John Bradley (Florence Briggs Th...</td>\n",
" <td>female</td>\n",
" <td>38.0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>PC 17599</td>\n",
" <td>71.2833</td>\n",
" <td>C85</td>\n",
" <td>0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>3</td>\n",
" <td>1</td>\n",
" <td>Heikkinen, Miss. Laina</td>\n",
" <td>female</td>\n",
" <td>26.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>STON/O2. 3101282</td>\n",
" <td>7.9250</td>\n",
" <td>NaN</td>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>4</td>\n",
" <td>1</td>\n",
" <td>Futrelle, Mrs. Jacques Heath (Lily May Peel)</td>\n",
" <td>female</td>\n",
" <td>35.0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>113803</td>\n",
" <td>53.1000</td>\n",
" <td>C123</td>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>Allen, Mr. William Henry</td>\n",
" <td>male</td>\n",
" <td>35.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>373450</td>\n",
" <td>8.0500</td>\n",
" <td>NaN</td>\n",
" <td>1</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" PassengerId Survived Name \\\n",
"0 1 0 Braund, Mr. Owen Harris \n",
"1 2 1 Cumings, Mrs. John Bradley (Florence Briggs Th... \n",
"2 3 1 Heikkinen, Miss. Laina \n",
"3 4 1 Futrelle, Mrs. Jacques Heath (Lily May Peel) \n",
"4 5 0 Allen, Mr. William Henry \n",
"\n",
" Sex Age SibSp Parch Ticket Fare Cabin SexCoded \\\n",
"0 male 22.0 1 0 A/5 21171 7.2500 NaN 1 \n",
"1 female 38.0 1 0 PC 17599 71.2833 C85 0 \n",
"2 female 26.0 0 0 STON/O2. 3101282 7.9250 NaN 0 \n",
"3 female 35.0 1 0 113803 53.1000 C123 0 \n",
"4 male 35.0 0 0 373450 8.0500 NaN 1 \n",
"\n",
" Embarked_C Embarked_Q Embarked_S Pclass_1 Pclass_2 Pclass_3 \n",
"0 0.0 0.0 1.0 0.0 0.0 1.0 \n",
"1 1.0 0.0 0.0 1.0 0.0 0.0 \n",
"2 0.0 0.0 1.0 0.0 0.0 1.0 \n",
"3 0.0 0.0 1.0 1.0 0.0 0.0 \n",
"4 0.0 0.0 1.0 0.0 0.0 1.0 "
]
},
"execution_count": 82,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#Remove nulls\n",
"df['Embarked'].fillna('S', inplace=True)\n",
"df = pd.get_dummies(df, columns=['Embarked', 'Pclass'])\n",
"df.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Cleaning: dropping"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We should drop columns we will not use. In the exercise, you will need to use 'Cabin'."
]
},
{
"cell_type": "code",
"execution_count": 83,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>PassengerId</th>\n",
" <th>Survived</th>\n",
" <th>Name</th>\n",
" <th>Sex</th>\n",
" <th>Age</th>\n",
" <th>SibSp</th>\n",
" <th>Parch</th>\n",
" <th>Fare</th>\n",
" <th>SexCoded</th>\n",
" <th>Embarked_C</th>\n",
" <th>Embarked_Q</th>\n",
" <th>Embarked_S</th>\n",
" <th>Pclass_1</th>\n",
" <th>Pclass_2</th>\n",
" <th>Pclass_3</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>Braund, Mr. Owen Harris</td>\n",
" <td>male</td>\n",
" <td>22.0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>7.2500</td>\n",
" <td>1</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2</td>\n",
" <td>1</td>\n",
" <td>Cumings, Mrs. John Bradley (Florence Briggs Th...</td>\n",
" <td>female</td>\n",
" <td>38.0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>71.2833</td>\n",
" <td>0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>3</td>\n",
" <td>1</td>\n",
" <td>Heikkinen, Miss. Laina</td>\n",
" <td>female</td>\n",
" <td>26.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>7.9250</td>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>4</td>\n",
" <td>1</td>\n",
" <td>Futrelle, Mrs. Jacques Heath (Lily May Peel)</td>\n",
" <td>female</td>\n",
" <td>35.0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>53.1000</td>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>Allen, Mr. William Henry</td>\n",
" <td>male</td>\n",
" <td>35.0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>8.0500</td>\n",
" <td>1</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" PassengerId Survived Name \\\n",
"0 1 0 Braund, Mr. Owen Harris \n",
"1 2 1 Cumings, Mrs. John Bradley (Florence Briggs Th... \n",
"2 3 1 Heikkinen, Miss. Laina \n",
"3 4 1 Futrelle, Mrs. Jacques Heath (Lily May Peel) \n",
"4 5 0 Allen, Mr. William Henry \n",
"\n",
" Sex Age SibSp Parch Fare SexCoded Embarked_C Embarked_Q \\\n",
"0 male 22.0 1 0 7.2500 1 0.0 0.0 \n",
"1 female 38.0 1 0 71.2833 0 1.0 0.0 \n",
"2 female 26.0 0 0 7.9250 0 0.0 0.0 \n",
"3 female 35.0 1 0 53.1000 0 0.0 0.0 \n",
"4 male 35.0 0 0 8.0500 1 0.0 0.0 \n",
"\n",
" Embarked_S Pclass_1 Pclass_2 Pclass_3 \n",
"0 1.0 0.0 0.0 1.0 \n",
"1 0.0 1.0 0.0 0.0 \n",
"2 1.0 0.0 0.0 1.0 \n",
"3 1.0 1.0 0.0 0.0 \n",
"4 1.0 0.0 0.0 1.0 "
]
},
"execution_count": 83,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.drop(['Cabin', 'Ticket'], axis=1, inplace=True)\n",
"df.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Feature Engineering"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2016-03-29 10:57:26 +00:00
"Feature Engineering is the process of using domain/expert knowledge of the data to create features that make machine learning algorithms work better. We are going to define several [new ones](https://triangleinequality.wordpress.com/2013/09/08/basic-feature-engineering-with-the-titanic-data/) in the exercise."
2016-03-28 12:03:08 +00:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# References"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* [Basic Feature Engineering with the Titanic Data](https://triangleinequality.wordpress.com/2013/09/08/basic-feature-engineering-with-the-titanic-data/)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Licence"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The notebook is freely licensed under under the [Creative Commons Attribution Share-Alike license](https://creativecommons.org/licenses/by/2.0/). \n",
"\n",
"© 2016 Carlos A. Iglesias, Universidad Politécnica de Madrid."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
2017-04-20 14:07:10 +00:00
"version": "3.5.2"
2016-03-28 12:03:08 +00:00
}
},
"nbformat": 4,
"nbformat_minor": 0
}