2015-06-11 19:17:52 +08:00
{
" cells " : [
2015-06-19 09:07:36 +08:00
{
" cell_type " : " markdown " ,
" metadata " : { } ,
" source " : [
2015-11-01 19:44:00 +08:00
" This notebook was prepared by [Donne Martin](http://donnemartin.com). Source and license info is on [GitHub](https://github.com/donnemartin/data-science-ipython-notebooks). "
2015-06-19 09:07:36 +08:00
]
} ,
2015-06-11 19:17:52 +08:00
{
" cell_type " : " markdown " ,
" metadata " : { } ,
" source " : [
" # matplotlib-applied \n " ,
" \n " ,
" * Applying Matplotlib Visualizations to Kaggle: Titanic \n " ,
" * Bar Plots, Histograms, subplot2grid \n " ,
" * Normalized Plots \n " ,
" * Scatter Plots, subplots \n " ,
" * Kernel Density Estimation Plots "
]
} ,
{
" cell_type " : " markdown " ,
" metadata " : { } ,
" source " : [
" ## Applying Matplotlib Visualizations to Kaggle: Titanic "
]
} ,
{
" cell_type " : " markdown " ,
" metadata " : { } ,
" source " : [
" Prepare the titanic data to plot: "
]
} ,
{
" cell_type " : " code " ,
2015-07-08 10:50:52 +08:00
" execution_count " : 1 ,
" metadata " : {
" collapsed " : true
} ,
" outputs " : [ ] ,
" source " : [
" % matplotlib inline \n " ,
" import pandas as pd \n " ,
" import numpy as np \n " ,
" import pylab as plt \n " ,
" import seaborn \n " ,
" \n " ,
" # Set the global default size of matplotlib figures \n " ,
" plt.rc( ' figure ' , figsize=(10, 5)) \n " ,
" \n " ,
" # Set seaborn aesthetic parameters to defaults \n " ,
" seaborn.set() "
]
} ,
{
" cell_type " : " code " ,
" execution_count " : 2 ,
2015-06-11 19:17:52 +08:00
" metadata " : {
" collapsed " : false
} ,
" outputs " : [ ] ,
" source " : [
" df_train = pd.read_csv( ' ../data/titanic/train.csv ' ) \n " ,
" \n " ,
" def clean_data(df): \n " ,
" \n " ,
" # Get the unique values of Sex \n " ,
" sexes = np.sort(df[ ' Sex ' ].unique()) \n " ,
" \n " ,
" # Generate a mapping of Sex from a string to a number representation \n " ,
" genders_mapping = dict(zip(sexes, range(0, len(sexes) + 1))) \n " ,
" \n " ,
" # Transform Sex from a string to a number representation \n " ,
" df[ ' Sex_Val ' ] = df[ ' Sex ' ].map(genders_mapping).astype(int) \n " ,
" \n " ,
" # Get the unique values of Embarked \n " ,
" embarked_locs = np.sort(df[ ' Embarked ' ].unique()) \n " ,
" \n " ,
" # Generate a mapping of Embarked from a string to a number representation \n " ,
" embarked_locs_mapping = dict(zip(embarked_locs, \n " ,
" range(0, len(embarked_locs) + 1))) \n " ,
" \n " ,
" # Transform Embarked from a string to dummy variables \n " ,
" df = pd.concat([df, pd.get_dummies(df[ ' Embarked ' ], prefix= ' Embarked_Val ' )], axis=1) \n " ,
" \n " ,
" # Fill in missing values of Embarked \n " ,
" # Since the vast majority of passengers embarked in ' S ' : 3, \n " ,
" # we assign the missing values in Embarked to ' S ' : \n " ,
" if len(df[df[ ' Embarked ' ].isnull()] > 0): \n " ,
" df.replace( { ' Embarked_Val ' : \n " ,
" { embarked_locs_mapping[np.nan] : embarked_locs_mapping[ ' S ' ] \n " ,
" } \n " ,
" }, \n " ,
" inplace=True) \n " ,
" \n " ,
" # Fill in missing values of Fare with the average Fare \n " ,
" if len(df[df[ ' Fare ' ].isnull()] > 0): \n " ,
" avg_fare = df[ ' Fare ' ].mean() \n " ,
" df.replace( { None: avg_fare }, inplace=True) \n " ,
" \n " ,
" # To keep Age in tact, make a copy of it called AgeFill \n " ,
" # that we will use to fill in the missing ages: \n " ,
" df[ ' AgeFill ' ] = df[ ' Age ' ] \n " ,
" \n " ,
" # Determine the Age typical for each passenger class by Sex_Val. \n " ,
" # We ' ll use the median instead of the mean because the Age \n " ,
" # histogram seems to be right skewed. \n " ,
" df[ ' AgeFill ' ] = df[ ' AgeFill ' ] \\ \n " ,
" .groupby([df[ ' Sex_Val ' ], df[ ' Pclass ' ]]) \\ \n " ,
" .apply(lambda x: x.fillna(x.median())) \n " ,
" \n " ,
" # Define a new feature FamilySize that is the sum of \n " ,
" # Parch (number of parents or children on board) and \n " ,
" # SibSp (number of siblings or spouses): \n " ,
" df[ ' FamilySize ' ] = df[ ' SibSp ' ] + df[ ' Parch ' ] \n " ,
" \n " ,
" return df \n " ,
" \n " ,
" df_train = clean_data(df_train) "
]
} ,
{
" cell_type " : " markdown " ,
" metadata " : { } ,
" source " : [
" ## Bar Plots, Histograms, subplot2grid "
]
} ,
{
" cell_type " : " code " ,
2015-07-08 10:50:52 +08:00
" execution_count " : 3 ,
2015-06-11 19:17:52 +08:00
" metadata " : {
" collapsed " : false
} ,
" outputs " : [
{
" data " : {
" text/plain " : [
2015-07-08 10:50:52 +08:00
" <matplotlib.text.Text at 0x11357ac50> "
2015-06-11 19:17:52 +08:00
]
} ,
2015-07-08 10:50:52 +08:00
" execution_count " : 3 ,
2015-06-11 19:17:52 +08:00
" metadata " : { } ,
" output_type " : " execute_result "
} ,
{
" data " : {
2015-07-08 10:50:52 +08:00
" image/png " : " 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 \n /XqUlp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1PCw8ORm5uLgoIC \n 7N27FxqNBqtXr5aDIvHWCDfViRMn8N577+Gll14CAPTq1QsbNmyAxWKBzWaDTqdDVlYWfvnlF5hM \n JowfPx7x8fHYt28fLBaL/MnEy8ur0RvCnpKSErvtNaVXr17Izs4GcPn7+G+//faqz7NYLFi6dKk8 \n RgoAiouL0a1bNwBAYGA
2015-06-11 19:17:52 +08:00
" text/plain " : [
2015-07-08 10:50:52 +08:00
" <matplotlib.figure.Figure at 0x113145b10> "
2015-06-11 19:17:52 +08:00
]
} ,
" metadata " : { } ,
" output_type " : " display_data "
}
] ,
" source " : [
" # Size of matplotlib figures that contain subplots \n " ,
" figsize_with_subplots = (10, 10) \n " ,
" \n " ,
" # Set up a grid of plots \n " ,
" fig = plt.figure(figsize=figsize_with_subplots) \n " ,
" fig_dims = (3, 2) \n " ,
" \n " ,
" # Plot death and survival counts \n " ,
" plt.subplot2grid(fig_dims, (0, 0)) \n " ,
" df_train[ ' Survived ' ].value_counts().plot(kind= ' bar ' , \n " ,
" title= ' Death and Survival Counts ' , \n " ,
" color= ' r ' , \n " ,
" align= ' center ' ) \n " ,
" \n " ,
" # Plot Pclass counts \n " ,
" plt.subplot2grid(fig_dims, (0, 1)) \n " ,
" df_train[ ' Pclass ' ].value_counts().plot(kind= ' bar ' , \n " ,
" title= ' Passenger Class Counts ' ) \n " ,
" \n " ,
" # Plot Sex counts \n " ,
" plt.subplot2grid(fig_dims, (1, 0)) \n " ,
" df_train[ ' Sex ' ].value_counts().plot(kind= ' bar ' , \n " ,
" title= ' Gender Counts ' ) \n " ,
" plt.xticks(rotation=0) \n " ,
" \n " ,
" # Plot Embarked counts \n " ,
" plt.subplot2grid(fig_dims, (1, 1)) \n " ,
" df_train[ ' Embarked ' ].value_counts().plot(kind= ' bar ' , \n " ,
" title= ' Ports of Embarkation Counts ' ) \n " ,
" \n " ,
" # Plot the Age histogram \n " ,
" plt.subplot2grid(fig_dims, (2, 0)) \n " ,
" df_train[ ' Age ' ].hist() \n " ,
" plt.title( ' Age Histogram ' ) "
]
} ,
{
" cell_type " : " code " ,
2015-07-08 10:50:52 +08:00
" execution_count " : 4 ,
2015-06-11 19:17:52 +08:00
" metadata " : {
" collapsed " : false
} ,
" outputs " : [
{
" data " : {
" text/plain " : [
2015-07-08 10:50:52 +08:00
" <matplotlib.text.Text at 0x1138e6f10> "
2015-06-11 19:17:52 +08:00
]
} ,
2015-07-08 10:50:52 +08:00
" execution_count " : 4 ,
2015-06-11 19:17:52 +08:00
" metadata " : { } ,
" output_type " : " execute_result "
} ,
{
" data " : {
2015-07-08 10:50:52 +08:00
" image/png " : " iVBORw0KGgoAAAANSUhEUgAAAegAAAFeCAYAAABOw4xkAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz \n AAALEgAACxIB0t1+/AAAIABJREFUeJzt3XtclHXe//H3jIAgh9QazdIlI1L3TvwthfeSZuTPjLY0 \n DDHxmGabluXKqmGKaK2r2Sp2sNtT5UYHdQvN3LtuS23phhI76KPW0jRTLFMUtZmRmMGZ3x/+nCQV \n VBjm6/h6Ph4+HsM11+FzfcB5X6e5LovX6/UKAAAYxRroAgAAwKkIaAAADERAAwBgIAIaAAADEdAA \n ABiIgAYAwEAhgS4AaGibNm3SnDlzdPjwYXm9Xl1++eV69NFHdc0119TL/JcuXaqffvpJf/zjH+tl \n fmeje/fumjt3rhISEs5r+uzsbBUXF6t58+bVhi9atEg2m63O9aWlpSk/P1/vvfee1qxZo/nz55/1 \n tB988IHmz5+viooKHTt2TNdcc40mTpyoli1bat26dSouLtbkyZPrXCNgGgIaFxWXy6UHHnhAS5Ys \n UYcOHSRJq1at0v33369169bJYrHUeRn9+/ev8zzOR11uaWCxWDRs2DANGzasHiv6xcqVK89run37 \n 9ik7O1srVqxQq1atJEnz58/XmDFjtHTpUnXv3l3du3evz1IBYxDQuKhUVFTI4XDI6XT6hvXu3VvR \n 0dGqqqrSZ599pr/85S96++23JUkbNmzw/fzss89q06ZNKisrU3x8vD799FM999xzuu666yRJY8eO \n VefOnXXgwAEdPnxY3bt318yZM33z+umnn9SjRw+tXbtWP/74ox5//HEdOXLEF45paWnasGGDpk+f \n riZNmujnn3/WK6+8oscee0y7d++W1WrVf/zHf+jxxx8/7YbE0qVLNW3aNLlcLg0bNkzp6emaPHmy \n Lr30Uo0dO1bS8Y2RNWvW6Lnnnjtl+jMF/M6dO/X444+roqJC+/fvV/v27TV37lyFhYWpY8eOGjZs \n mNavXy+n06nx48fr3Xff1bZt29SiRQvNnz9fERERat++vT7++GPfPPfu3as77rhDhYWFioqKktfr \n VWpqqp555hm1a9fON96hQ4fkdrur/b6GDh3q27gqKCjQmjVr9Pzzz6tPnz6+vhw+fFjl5eUqKSmR \n 2+3W9OnTtW3bNlVVVSk5OVkTJkxQo0aNzuIvBggczkHjonLJJZdo/PjxGjFihHr06KEJEybozTff \n VHJyskJDQ2udfu/evVq5cqVmz56t9PR0rVixQpJ05MgRFRcXq1evXrJYLLJYLOrSpYuOHj2qL7/8 \n UpK0evVqpaSkqEmTJho1apSGDh2qVatWadGiRcrLy9OmTZskSdu3b1deXp5Wrlyp999/X0ePHtXK \n lSv1xhtvSJL27Nlz2toiIiJUUFCgF198UbNnz9b27ds1aNAgFRQUyOPxSJKWLVumzMzMU6b1er1a \n smSJ0tLSfP9OLO8f//iH7r77bi1dulRr1qzRnj179K9//UuS5Ha71aJFC7399tvKzMzU5MmTNWnS \n JP33f/+37Ha71q1bd9paW7VqpeTkZK1atUqS9PHHH6tZs2bVwlmS2rdvr379+iktLU133HGHcnJy \n tH79enXt2rXaeFarVW+99ZZWrlypJUuWKCoqSjNnzlR4eLj++te/6rrrrlNBQYFWrFih8vJyvfTS \n S7X8poHAI6Bx0bn33nt95y1tNpsWLVqktLQ0ORyOWqft1KmTrNbj/23S09P1zjvvyO12a/Xq1ere \n vbtvb/DE3mjfvn19IV5QUKCMjAzt3LlTLpdLPXr0kCS1aNFCPXv21IcffiiLxaLLL7/cdzj3hhtu \n 0Pbt2zV48GAtXLhQQ4cOVZs2bU5b2z333OObX9euXfXRRx+pffv2at26tdavX68dO3aorKxMXbp0 \n OWXaE3vxK1eu9P3r27evJGn8+PFq2rSpFi9erNzcXO3fv7/aHm3Pnj0lSW3atNG1116rFi1ayGKx \n qHXr1jp8+PAZezlw4ED94x//kHTmDQdJevTRR1VUVKQxY8aocePGmjVrlgYNGuTb6DjZzz//rJEj \n R+quu+7SH/7wB0nHz2EvW7ZMaWlpSk9P15dffqlvvvnmjHUBpuAQNy4qn376qT7//HONGDFCKSkp \n SklJUVZWlnr16qXi4mI1bdq02qFet9tdbfomTZr4Xl9xxRX67W9/qw8++EArVqzQpEmTJKna4ee7 \n 775bffr0UUZGhux2u5KSkrRt27ZT6vJ4PKqqqpIkRUZG+oa3bt1aa9asUUlJiT7++GPde++9ysnJ \n 0W233XbKPE5sOJyY34kjAgMHDtSbb76pq666yhfip3OmQ9xjx46Vx+PR7bffrpSUFP3444/V3g8L \n C/O9Dgk5+4+U5ORkVVRU6KOPPtInn3yiWbNmnTLO2rVrdfjwYaWnp6tnz57q2bOnsrKylJKSoi1b \n tlQb99ixY8rKylK7du10//33+4Z7PB49/fTTuvrqqyUdP9VQH9caAP7GHjQuKs2bN9f8+fO1ceNG \n 37B9+/apoqJC1157rZo3b64ffvhB5eXl8nq9ev/992ucX79+/bRw4UJVVlbqd7/7naTqQdeyZUsl \n JCRoypQp6tevnySpbdu2Cg0N1Xvvvedb/po1a9SlS5dTQvK1117TxIkT1bVrV40bN0433XTTGff+ \n CgoKJEk//PCDPvroIyUnJ0uSbrvtNn311Vd67733lJ6efi7tkiQVFRXpwQcf1O233y5J2rx5s44d \n O3bO8/k1i8WiAQMGaNKkSerVq1e1oD8hKipKeXl51TZqdu/ercaNGys2NrbauNOmTdOxY8c0ZcqU \n asO7du2qJUuWyOv1yuVy6aGHHtJrr71W5/oBf2MPGheVtm3bat68eXr66af1ww8/KCIiQtHR0Xri \n iSd01VVXSTp+qDg9PV02m00pKSm+aU+cWz5Z9+7dNW3atGp7bL8er1+/fhozZozvq0WhoaGaN2+e \n pk+frmeffVbHjh3T6NGj1blzZ23YsKHa/Pv06aONGzfqD3/4gyIiInTllVdq6NChp103t9utPn36 \n qKqqSjk5Ob4ACw0N1W233aaDBw+qadOmZ+zNmfYqx44dq9GjR+uyyy5Tq1at1LNnT+3evfuUaU7X \n n1/P+9fvp6Wl6cknnzzjle//+Z//qZycHD322GM6cuSIQkJC1LJlSz3//POKjo72zW/Tpk1avny5 \n 2rdvr759+/o2dKZPn67Jkydr+vTp6t27t9xut7p06aIRI0acsQ+AKSw8bhIIbkePHtWgQYM0derU \n 8/6etL/885//1FtvvaWFCxcGuhTAOLXuQS9YsEDr16+X2+3WoEGDlJiYqOzsbFmtVsXHxys3N1cW \n i0XLly/XsmXLFBISolGjRlXb8wAQGB9++KHGjRun9PR048J58ODBKi8v1zPPPBPoUgAj1bgHvWHD \n Br300kuaP3++jh49qsWLF+urr77S8OHDlZSUpNzcXN10003q1KmThg8froKCAlVWViozM1Nvvvnm \n ac8pAQCA2tW4B11UVKR27drpwQcflMPh0IQJE/TGG28oKSlJktStWzcVFRXJarUqMTFRoaGhCg0N \n VWxsrLZu3aqOHTs2yEoAABBsagzo8vJy7d27VwsWLFBpaalGjhxZ7SrTyMhI2e12ORwORUdHVxt+ \n Nt8pBQAAp1djQDdr1kxxcXEKCQlR27Zt1bhxY+3fv9/3vsPhUExMjKKioqrduMDpdComJqbGBXu9 \n Xr6LCADAGdQY0Ndff71efvllDRs2TPv27dPPP/+s3//+9yopKVHnzp1VWFio5ORkJSQkKC8vTy6X \n S5WVldqxY4fi4+NrXLDFYlFZmb1eVwanstmi6bOf0WP/o8f+R48bhs0WXftI/1+NAZ2SkqKNGzeq \n b9++8ng8ys3N1ZVXXqmcnBy53W7FxcUpNTVVFotFQ4YM0YABA+TxeJSVlcUFYgAA1EFAvwfN1pr/ \n sVXsf/TY/+ix/9HjhnE
2015-06-11 19:17:52 +08:00
" text/plain " : [
2015-07-08 10:50:52 +08:00
" <matplotlib.figure.Figure at 0x1132fcd90> "
2015-06-11 19:17:52 +08:00
]
} ,
" metadata " : { } ,
" output_type " : " display_data "
}
] ,
" source " : [
" # Get the unique values of Embarked and its maximum \n " ,
" family_sizes = np.sort(df_train[ ' FamilySize ' ].unique()) \n " ,
" family_size_max = max(family_sizes) \n " ,
" \n " ,
" df1 = df_train[df_train[ ' Survived ' ] == 0][ ' FamilySize ' ] \n " ,
" df2 = df_train[df_train[ ' Survived ' ] == 1][ ' FamilySize ' ] \n " ,
" plt.hist([df1, df2], \n " ,
" bins=family_size_max + 1, \n " ,
" range=(0, family_size_max), \n " ,
" stacked=True) \n " ,
" plt.legend(( ' Died ' , ' Survived ' ), loc= ' best ' ) \n " ,
" plt.title( ' Survivors by Family Size ' ) "
]
} ,
{
" cell_type " : " markdown " ,
" metadata " : { } ,
" source " : [
" ## Normalized Plots "
]
} ,
{
" cell_type " : " code " ,
2015-07-08 10:50:52 +08:00
" execution_count " : 5 ,
2015-06-11 19:17:52 +08:00
" metadata " : {
" collapsed " : false
} ,
" outputs " : [
{
" data " : {
" text/plain " : [
2015-07-08 10:50:52 +08:00
" <matplotlib.text.Text at 0x113ccbc50> "
2015-06-11 19:17:52 +08:00
]
} ,
2015-07-08 10:50:52 +08:00
" execution_count " : 5 ,
2015-06-11 19:17:52 +08:00
" metadata " : { } ,
" output_type " : " execute_result "
} ,
{
" data " : {
2015-07-08 10:50:52 +08:00
" image/png " : " iVBORw0KGgoAAAANSUhEUgAAAe8AAAFpCAYAAAC1YKAIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz \n AAALEgAACxIB0t1+/AAAIABJREFUeJzt3WtAVOXe9/HfMCAeBg8YsjPFbWZkWaRp6a0WmpkksjUJ \n ySTdpVlt85D2pI+GJhq4PZTHtLq1Mguz1Ipyp4aHtpk3Klp2eyrLc4qCCgPqwKznhY+zJcABbRgW \n fj+vZh3mWv81XPqba806WAzDMAQAAEzDx9sFAACAsiG8AQAwGcIbAACTIbwBADAZwhsAAJMhvAEA \n MBlfbxcAlMb27ds1ffp0nT59WoZh6C9/+Ytefvll3XLLLX9K+8nJyTp79qyeeeaZMr938+bNmjhx \n or744osiy2677TY1bdpUVqtVFotFeXl5stlsGj9+vJo3b37FdpcuXSqHw6E+ffqUupZly5bpq6++ \n 0jvvvFPm/ZAu7svAgQN18803y2KxyDAMWa1WDR48WB07dryqNs3gl19+0RtvvKEDBw7IYrGoZs2a \n GjZsmO655x4dPnxY3bt3V3p6urfLBFwIb1R4Fy5c0KBBg/Tuu++qWbNmkqTPP/9cAwcOVGpqqiwW \n yzVvIzY29prbKMmiRYtUu3Zt1/SCBQs0ceJEJScnX/F9W7du1a233uqxukrSqFEjrVixwjW9e/du \n Pf7440pNTVWdOnXKvR5P279/v/r376+kpCS1a9dOkrRp0yY9++yzSk5Olr+/v5crBIoivFHh5eXl \n KScnR3a73TUvKipKAQEBys/P17Zt2wqNfC8fCc+aNUvbt29XRkaGmjZtqq1bt2r27NmuUe/w4cN1 \n 77336uTJkzp9+rQ6deqkpKQkV1tnz55V586d9c0332jLli2aP3++HA6HMjMz1aNHDw0dOtRt/Zff \n Byk/P19Hjx51hfnJkycVHx+vzMxMZWRkqH79+poxY4a2bt2qtWvX6rvvvlPVqlXVp08fvfnmm1q9 \n erWcTqduuukmjRs3TvXq1SuyvVOnTmngwIE6fvy46tevr4kTJ+rChQuKjIzUhg0bZLPZZBiGunbt \n qpkzZyo0NPSK9d92222qVq2ajh49qoKCgmLrDQwM1IcffqglS5bIz89P/v7+mjBhgpo0aVLi/OPH \n jyshIUFHjx5Vfn6+unXrpkGDBunw4cPq37+/wsPDtWPHDp05c0bDhg3TI488ory8PI0bN047duxQ \n zZo11aRJE1ksFiUmJl6xvSeeeEK33HKLDh8+rMWLF+uGG25w7d/bb7+tXr16uYJbktq2bavp06er \n SpUqhT6Lkv5ef+b+5+fnKyEhQdu2bZOfn58aNmyoxMREVa9e3W1fw3XEAExg4cKFRlhYmPHggw8a \n L730kvHJJ58YeXl5hmEYxvfff29ERka61r18eubMmUZERIRRUFDgmp4wYYJhGIZx+vRp49577zWy \n s7ONWbNmGQkJCYZhGEanTp2MH3/80TAMw1i8eLHx0ksvGYZhGHFxccaBAwcMwzCM33//3bj99tuN \n rKysItu/XGhoqBEZGWlERUUZ7du3Nx588EFj4sSJxqlTpwzDMIz33nvPePvtt13rDxw40FiwYIFh \n GIYxatQo1+vly5cbw4cPN/Lz8w3DMIzk5GRj4MCBRbb36aefGi1atDAOHjxoGIZhTJ8+3Rg2bJhh \n GIbx/PPPG4sXLzYMwzC+++47o3fv3kXeX9y+fP3110a7du2Mc+fOlVhvfn6+0bx5cyMjI8MwDMNY \n sWKF8fHHH5c4/9LnmZqaahiGYZw7d86Ii4szvvrqK+PQoUNGaGiosW7dOtf2O3bsaBiGYUydOtUY \n MWKEYRiGkZ2dbURFRRmjRo0qVXtbtmwp9m8UGRlprF+/vthlhmEYhw4dMu6++27DMEr+e/2Z+5+W \n lmZERES4tjFlyhQjPT29xPpwfWLkDVPo37+/YmJi9D//8z9KS0vT22+/rbfffluffPKJ2/eGhYXJ \n x+fiuZm9evVSdHS0Ro0apZSUFHXq1Mk1EjX+/wg5Ojpay5cvV/PmzbVs2TK9/PLLkqR58+Zp7dq1 \n +vzzz7V//34ZhqG8vDy327902HzXrl0aOHCgWrRoocDAQEnSk08+qS1btmjhwoX67bfftG/fPoWF \n hRVpY+3atfrxxx/Vq1cvSVJBQYHOnz9f7PbatWunhg0buvYlOjpakvTEE09oypQp6tOnj5YsWaLH \n H3+82PcfPHhQPXr0kHTxSMGNN96ouXPnyt/fv8R6rVarunbtqt69eys8PFzt2rVTeHi4fHx8ip2f \n m5urtLQ0nT17VjNmzJB08QjL7t27deedd8rX11cPPPCAJKlZs2Y6ffq0JGnDhg0aPXq0JMlms6ln \n z57as2eP8vLy3LbXokWLYvfXx8en0NGRKymP/W/fvr2sVqsee+wxtW/fXl26dNFdd91Vqvpw/SC8 \n UeFt3bpV6enpGjBggMLDwxUeHq4XX3xR3bt313fffafatWsX+s/X4XAUev/lhxvr16+v22+/XevW \n rdPy5cs1ZswYSSr0u/mjjz6qnj176rHHHlN2drZat26t3Nxc9ejRQ126dFGrVq0UHR2tNWvWlPo/ \n feliCI0ePVpjxoxRWFiYbrrpJk2ZMkU//vijoqOj1aZNGxUUFBTbpmEYeuaZZ1y/zV+4cMEVaH90 \n +b44nU75+l78Z962bVvl5eVp06ZN2rJli/75z38W+/6QkJBCv3lf7kr1TpkyRT///LM2btzo+mI1 \n d+7cYudf2vaSJUtcvylnZmaqatWqyszMlJ+fX6H9ubQNq9Va6PO5tK8FBQVu27v0Be6PwsLClJ6e \n 7vqycMns2bPVqFGjQqFfHvtfvXp1ffbZZ9q2bZu+//57DR8+XHFxcerfv3+x9eP6xKViqPACAwM1 \n b948paWlueYdP35ceXl5uvXWWxUYGKijR48qMzNThmFozZo1V2wvJiZGb731ls6fP+/6j/nyQAgO \n DtZdd92l+Ph4xcTESJIOHDggu92uoUOHKjw8XJs3b9aFCxdcoVFa3bp1U4sWLfTaa69JkjZu3Kh+ \n /fopKipKgYGB+u677+R0OiVdDKpLX0Tat2+vjz/+WDk5OZIuBsuoUaOK3cbmzZt19OhRSdJHH32k \n +++/X9LFoOvTp4/GjBmj7t27F/k9tzRKqjcrK0vh4eGqVauW+vXrp6FDh2rPnj0lzrfZbAoLC9OC \n BQskSdnZ2XriiSeUmpp6xe2Hh4fr008/dR31SElJkcViuer2JGnAgAFaunSpNm7c6Jq3YcMGLVq0 \n yHWCZHnu/7p169SvXz+1aNFCgwcPVo8ePbRnz54y/Z1Q+THyRoXXuHFjzZkzRzNmzNDRo0dVrVo1 \n BQQEKCEhQX/9618lSb1791avXr0UFBSk8PBw13stFkuRs9E7deqkV199VQMHDixxvZiYGA0dOlTz \n 5s2TdPGkrfDwcD3yyCMKCgpSy5Yt1bx5cx08eLDQKPGPijsT/pVXXlFUVJQ2btyof/zjH/rnP/+p \n +fPnKzAwUA8//LAOHDggSbr//vs1YcIESXKdgNa7d29ZLBbVr19fSUlJxW4vNDRUY8aM0cmTJ9Wk \n SRNXG5LUo0cPTZ48+arPri+p3jp16ui5555T//795e/vL19fX02cOLHE+ZI0bdo0JSQkqHv37nI4 \n HIqMjFRkZKQOHz5c5HO7ND1o0CBNmDBB3bt3l81mU926dVWtWrUyt3e5kJAQzZs3T2+88YYmT54s \n p9OpunXrav78+a6T3C69vzz23+l0asOGDYqMjFT16tVVu3ZtJSQkXNXfC5WXxSjLcT8Apvbll1/q \n s88+01tvveXtUq7KV199pRo1auiBBx6Q0+nUkCFD1L59e49e6gdURB4/bL5jxw7FxcUVmZ+amqro \n 6GjFxsZq6dKlni4DuO7FxcVp7ty5rhPwzKhp06aaN2+eevTooe7duys4OFiPPfaYt8sCyp1HR95v \n v/22Pv/8c9WoUaPQDSk
2015-06-11 19:17:52 +08:00
" text/plain " : [
2015-07-08 10:50:52 +08:00
" <matplotlib.figure.Figure at 0x113b53b90> "
2015-06-11 19:17:52 +08:00
]
} ,
" metadata " : { } ,
" output_type " : " display_data "
} ,
{
" data " : {
2015-07-08 10:50:52 +08:00
" image/png " : " iVBORw0KGgoAAAANSUhEUgAAAe8AAAFxCAYAAABa5SD+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz \n AAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl8jXf+///nyUkiOLFEMbUWVVo1SFFapmgsUaUqItOK \n pbSd0doq8xPDBFUStXQQSjfTKg2mpNP0Yyyl9KPqo0MUpRSNPUJiyUnESc71/cOvZ5omkQQnJ1c8 \n 7reb2y3Xkvf1uk7eN8/zvlaLYRiGAACAaXh5ugAAAFA8hDcAACZDeAMAYDKENwAAJkN4AwBgMoQ3 \n AAAm4+3pAnB3aNq0qRo3biyr1eqa17x5c02bNs2t242MjNQDDzygF154oci/k56erpiYGO3du1de \n Xl7y8vLSc889p/79+9+RmpKTkzV69GjFxcXd0u936dJFCxYsULNmzXLNj4yM1DfffKOAgABJktPp \n VEZGhsLCwjR8+PCbtnny5EnNmjVL8+fPL1YtTZs21fbt21WtWrXi7cT/r0uXLvL19ZWfn58sFosc \n Docef/xxRUZGymKx3FKbpV1WVpbefvttbd26VYZhKCcnR71799aLL74oSQoPD9fAgQPVvXt3D1eK \n 0ozwRolZtmyZqlSpUqLbtFgsxQ6BOXPmyGaz6fPPP5cknT9/XgMGDFDt2rX12GOP3XZNNWvWvOXg \n vhmLxaKhQ4dq6NChrnlnz55Vz5499eSTT6pBgwYF/u6ZM2d0/PjxW9ru7T4qYs6cOa4vIg6HQ+Hh \n 4VqxYoWef/7522q3NDIMQyNGjFDDhg21cuVK+fr66tKlS3r55ZeVmZmpUaNGSVKZ/eKCO4fwRokp \n 6D/5o0ePasaMGUpLS5PT6VR4eLj69eunnTt3au7cuapZs6aOHDmi8uXLa+TIkVq2bJmOHz+ubt26 \n acKECXI6nZoxY4a+//572e12GYahN954Q4GBgbm2W9B2fuvChQuqVq2aHA6HfHx8VKNGDcXGxqpy \n 5cqSbowW58+fr4cfftg1vWDBAlWuXFnPP/+87r//fp06dUqBgYGqUKGC/va3v0mStm3bptjYWL31 \n 1lvq1auXdu/erU6dOmnhwoWutsaOHatHH31UQUFBioqKUmpqqlJSUlSrVi3NmzfPNaou6md89uxZ \n SVLFihUlSYsXL9aXX36prKwsZWZmavz48erSpYsmTZqk8+fPa/jw4Xrvvfe0e/duzZkzR5mZmbJY \n LBo5cqQ6deqU7zbnzZunAwcOyOl0asyYMerUqZOGDh2q4OBghYaGSpLefvttXbp0SRMmTLhp/T4+ \n PgoMDHR9kciv3qCgIB09elQTJ07U9evXJUkhISF67rnnCpz/Sw0bN26U0+lU7dq1NXnyZNWoUUPh \n 4eFq1aqVdu/erTNnzqh169aaOXOmLBaL1qxZo3fffVd+fn569NFHtWzZMh04cKDQ9qpUqaJjx47p \n ueeey/UlZNeuXTp+/Ljee+89V0BXqVJFb775ps6cOZPn87iT+48yxgBKQJMmTYxevXoZffr0cf27 \n ePGi4XA4jJ49exoHDhwwDMMwrly5YvTs2dNITEw0vv32W+Ohhx4yDh48aBiGYQwfPtwYMGCA4XA4 \n jNTUVKNZs2bG+fPnjd27dxujR492bWvJkiXGyy+/bBiGYURGRhoffPCBkZ2dnWc7wcHBRmJiYp5a \n Dx06ZHTr1s0IDAw0hg0bZixcuNA4fvy4a3nnzp2N/fv355k+efKk0aRJE+O7774zDMMwTpw4YbRr \n 185wOByGYRjG6NGjjdWrVxsnT540WrZsaRiGYcyfP994/fXXDcMwjEuXLhlt27Y1rl69anz44YfG \n u+++69rGiy++aHzwwQf5bv8X48ePNzp27Gj06dPHCAoKMh599FFjxIgRxs6dOw3DMIxTp04ZgwcP \n NrKysgzDMIyEhASjV69ehmEYxs6dO10/X7p0yejevbtx+vRpwzAM49y5c8YTTzxhnDlzJt+/6y91 \n Hj582Gjbtq1x8eJFY+PGjUZISIhhGIaRk5NjdOnSJddn+OvPbt++fa7pc+fOGcHBwcaGDRuM06dP \n G4MGDcq33gkTJhhLliwxDMMwUlJSjNdee81wOp0Fzl+7dq0xduxYIzs72zAMw4iLizNefPFFwzAM \n Y+DAgcaYMWMMwzCM9PR0o2PHjsbOnTuNI0eOGI899phx7tw5wzAMY8GCBUbTpk0NwzAKbW/ixIl5 \n 9tUwDOP99993basgAwcONNavX39H9n/s2LGG0+m86fZgToy8UWLyO2z+008/6eTJk/rrX//qmpeV \n laWDBw+qYcOGqlOnjpo2bSpJqlevnvz9/eXt7a2qVavKZrPp8uXLatWqlapUqaIVK1bo5MmT+r// \n +z/ZbLZc2zl+/Hie7Vy/fl0HDx5UixYtcq3bpEkTrV+/XgcOHNCuXbu0fft2LV68WPPmzVPnzp1v \n uo/e3t5q1aqVJKlu3bpq2rSpvvzyS7Vr107ffvutoqOjdfHiRdf6zz77rPr376/IyEglJCSoS5cu \n stlsGjRokL777jstXbpUP//8s44cOZKnzt/69WHzzMxMjR07Vl5eXmrdurUkqXbt2oqJidFnn32m \n EydOKDExUZmZmZJyj9gTExOVkpKiESNGuOZ5eXnp8OHDu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x4/Q///M/6tmzp6KiomSz2XT2 \n 7Nl85587d04dOnTQqlWrlJ6eLkmKjY1VZGSka1u//WJksVjUoUMH7dixQ8nJyZKk1atXu5YXt71f \n tGzZUg0aNFB0dLTrvPSFCxc0bdq0XAFrGMYd3X+UPYy8USIKOnTn6+urRYsWafr06XrvvfeUnZ2t \n 0aNHq1WrVtq5c2eR2g0LC1NERISeeeYZVapUSU8++aSWLl0qwzBc2/Xx8SlwO781f/58zZo1S927 \n d1eFChXkdDrVtWtXvfL
2015-06-11 19:17:52 +08:00
" text/plain " : [
2015-07-08 10:50:52 +08:00
" <matplotlib.figure.Figure at 0x113c19f10> "
2015-06-11 19:17:52 +08:00
]
} ,
" metadata " : { } ,
" output_type " : " display_data "
} ,
{
" data " : {
2015-07-08 10:50:52 +08:00
" image/png " : " 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 \n K1a49sHFixfldDo1a9a
2015-06-11 19:17:52 +08:00
" text/plain " : [
2015-07-08 10:50:52 +08:00
" <matplotlib.figure.Figure at 0x113cc3d90> "
2015-06-11 19:17:52 +08:00
]
} ,
" metadata " : { } ,
" output_type " : " display_data "
}
] ,
" source " : [
" pclass_xt = pd.crosstab(df_train[ ' Pclass ' ], df_train[ ' Survived ' ]) \n " ,
" \n " ,
" # Normalize the cross tab to sum to 1: \n " ,
" pclass_xt_pct = pclass_xt.div(pclass_xt.sum(1).astype(float), axis=0) \n " ,
" \n " ,
" pclass_xt_pct.plot(kind= ' bar ' , \n " ,
" stacked=True, \n " ,
" title= ' Survival Rate by Passenger Classes ' ) \n " ,
" plt.xlabel( ' Passenger Class ' ) \n " ,
" plt.ylabel( ' Survival Rate ' ) \n " ,
" \n " ,
" # Plot survival rate by Sex \n " ,
" females_df = df_train[df_train[ ' Sex ' ] == ' female ' ] \n " ,
" females_xt = pd.crosstab(females_df[ ' Pclass ' ], df_train[ ' Survived ' ]) \n " ,
" females_xt_pct = females_xt.div(females_xt.sum(1).astype(float), axis=0) \n " ,
" females_xt_pct.plot(kind= ' bar ' , \n " ,
" stacked=True, \n " ,
" title= ' Female Survival Rate by Passenger Class ' ) \n " ,
" plt.xlabel( ' Passenger Class ' ) \n " ,
" plt.ylabel( ' Survival Rate ' ) \n " ,
" \n " ,
" # Plot survival rate by Pclass \n " ,
" males_df = df_train[df_train[ ' Sex ' ] == ' male ' ] \n " ,
" males_xt = pd.crosstab(males_df[ ' Pclass ' ], df_train[ ' Survived ' ]) \n " ,
" males_xt_pct = males_xt.div(males_xt.sum(1).astype(float), axis=0) \n " ,
" males_xt_pct.plot(kind= ' bar ' , \n " ,
" stacked=True, \n " ,
" title= ' Male Survival Rate by Passenger Class ' ) \n " ,
" plt.xlabel( ' Passenger Class ' ) \n " ,
" plt.ylabel( ' Survival Rate ' ) "
]
} ,
{
" cell_type " : " markdown " ,
" metadata " : { } ,
" source " : [
" ## Scatter Plots, subplots "
]
} ,
{
" cell_type " : " code " ,
2015-07-08 10:50:52 +08:00
" execution_count " : 6 ,
2015-06-11 19:17:52 +08:00
" metadata " : {
" collapsed " : false
} ,
" outputs " : [
{
" data " : {
" text/plain " : [
2015-07-08 10:50:52 +08:00
" <matplotlib.text.Text at 0x113f4d710> "
2015-06-11 19:17:52 +08:00
]
} ,
2015-07-08 10:50:52 +08:00
" execution_count " : 6 ,
2015-06-11 19:17:52 +08:00
" metadata " : { } ,
" output_type " : " execute_result "
} ,
{
" data " : {
2015-07-08 10:50:52 +08:00
" image/png " : " iVBORw0KGgoAAAANSUhEUgAAAmgAAAJoCAYAAADS7x1JAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz \n AAALEgAACxIB0t1+/AAAIABJREFUeJzs3XlclOX6x/HPsAkIShjapmYezTweLbc0l8yDuyiILC64 \n 5ZLl0dxNBcXllJp5TO1nVqZpCRVoZprr6VBqLpV5bNVOuaShpSIoyDLz+2OGQRhcAJ0Zm+/79ZqX \n zjXMw8UF+lzcz3Pft8FkMpkQEREREafh5ugERERERKQwNWgiIiIiTkYNmoiIiIiTUYMmIiIi4mTU \n oImIiIg4GTVoIiIiIk5GDZqI3LADBw7Qr18/unXrRkhICEOGDOHIkSM37fgJCQksW7bsph3vRrRt \n 25aDBw+W6Rg//PADderUuSW5T5o0idatWxMaGkpYWBghISE8/fTTnD17FjDn/80331zzGAcPHmTa \n tGk3PTcRuXU8HJ2AiNwesrOzGTZsGCtWrOChhx4CYP369QwZMoQdO3ZgMBjK/Dmio6PLfIzSKOty \n kGvWrCEkJIR33nmHJ598End395uUGRgMBgYOHMjAgQOtsTlz5jB9+nRefvnlGzrGkSNHSE1NvWk5 \n icitpxE0EbkhmZmZZGRkcPHiRWusW7duxMXFkZuby549ewgJCbG+duXzRYsW8eSTT9KtWzfGjh1L \n mzZtOHTokPVjR48ezZo1a1i0aBEzZ85k586dhY514cIFmjZtSnp6OocPHyYmJoZu3brRvXt31q1b \n Z/183bp1Izo6mtDQUDIyMhg5ciShoaH06NGD2NjYqzZiCQkJ9OjRg65du5KUlATA1KlTWbBggfVj \n 1q9fz4gRI2zem5GRwYcffshTTz2Fv78/H3/8caGaTZgwgQ4dOhAREcGkSZN47rnnAEhNTWXEiBH0 \n 6NGDbt268eqrr97w96JZs2b8/PPPNvHExERCQkLo3r07Tz75JL/88gunTp3i5ZdfZv/+/UyePPmG \n P4eIOJYaNBG5IRUrVmT8+PEMHjyY4OBgJkyYQFJSEs2bN8fT0/O67z916hTr1q1j/vz5hIeHs3bt \n WgDS0tLYtWsXISEhGAwGDAYDLVq04NKlS9YmbsOGDbRp0wZfX1+GDx9O//79Wb9+Pa+99hoLFizg \n wIEDgHmkaMGCBaxbt45t27Zx6dIl1q1bx/vvvw/AiRMnis3Nx8eH5ORkli9fzvz58zly5Ah9+/Yl \n OTkZo9EImJufXr162bx3/fr11KhRg5o1axIaGsrKlSutr73yyisYjUY2b97Mm2++yXfffWd9bfz4 \n 8YSHh5OcnMx7773Hzp072bRpU7H5XdlYZmVlsW7dOh599NFCH7N7927eeOMN3nrrLT744AO6du3K \n M888w913382oUaNo3Lgx//znP6/9TRIRp6EGTURu2IABA9i1axdTp04lKCiI1157zTpadT0NGjTA \n zc38X054eDibNm0iJyeHDRs20LZtW/z8/DCZTNZmpGfPntYmLjk5mYiICH7++Weys7MJDg4GoHLl \n yrRv355PP/0Ug8HAXXfdxd133w1A48aNOXLkCDExMSxbtoz+/ftTtWrVYnOLioqyHq9ly5bs3r2b \n OnXqcN999/Hvf/+bn376iTNnztCiRQub965Zs4bQ0FAAQkJC+Oabb6wNY0pKCj179gTAz8+PsLAw \n wDyytm/fPhYuXEhoaChRUVGkpqby/fff2xzfZDKxYsUKQkNDCQ0NJSIigsDAQMaOHVvoYz799FM6 \n d+7MHXfcAUBYWBipqamcOHGizJdwRcT+dA+aiNyQL774gq+++orBgw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OOPYzQaGTlyJC1btnTYciIicvvQJU4RkWJ8 \n +umnPPHEEzRr1qxUzRlArVq1WLp0KaGhoYSEhFClShUiIiJucqYi8mekETQRERERJ6MRNBEREREn \n owZNRERExMnclrM4c3PzOHfukqPTuG3dcYev6lcGql/pqXZlo/qVjepXeqpd2QQF+Zf4PbflCJqH \n x83biNgVqX5lo/qVnmpXNqpf2ah+pafa2d9t2aCJiIiI/JmpQRMRERFxMmrQRERERJyMGjQRERER \n J6MGTURERMTJqEETERERcTJq0EREREScjBo0ERERESejBk1ERETEyahBExEREXEyatBEREREnIwa \n NBEREREnowZNRERExMmoQRMRERFxMmrQRERERJyMGjQRERERJ6MGTURERMTJqEETERERcTJq0ERE \n REScjIe9P6HRaGTKlCn88ssvuLm5MXPmTNzd3Zk0aRJubm7UqlWLadOmYTAY7J2aiIiIiFOwe4P2 \n 2WefkZmZyZo1a9i1axcLFiwgNzeXMWPG0KRJE6ZNm8b27dsJDg62d2oiIiJyhaysLBISUvD396ZL \n l6Z4e3s7OiWXYfdLnN7e3qSnp2MymUhPT8fT05NvvvmGJk2aANC6dWt27dpl77RERETkCllZWURF \n rWXChG4MH96eqKi1ZGVlOTotl2H3Bq1hw4ZkZ2fTsWNH4uLiiImJwWQyWV/39fUlPT3d3mmJiIjI \n FRISUti9eyDgCXiye/cAEhJSHJ2Wy7D7Jc7XX3+dhg0bMnr0aH777Tf69etHbm6u9fWLFy9SoUKF \n 6x4nKMj/Vqb5p6f6lY3qV3qqXdmofmWj+t04f3/by5n+/t6qoZ3YvUHLzMykfPnyAFSoUIHc3Fzq \n 1q3L3r17adq0KSkpKTRv3vy6xzlzRqNspRUU5K/6lYHqV3qqXdmofmWj+pVMly5Nad78TXbvHgBA \n 8+Yr6NIlTDUshdI0tQbTldcX7eDChQs899xznDt3jtzcXPr3789f//pXYmNjycnJoWbNmsyaNeu6 \n szj1A1J6+k+qbFS/0lPtykb1KxvVr+Q0SeDmuC0atJtF/8hKT/9JlY3qV3qqXdmofmWj+pWealc2 \n pWnQtFCtiIiIiJNRgyY
2015-06-11 19:17:52 +08:00
" text/plain " : [
2015-07-08 10:50:52 +08:00
" <matplotlib.figure.Figure at 0x113b53250> "
2015-06-11 19:17:52 +08:00
]
} ,
" metadata " : { } ,
" output_type " : " display_data "
}
] ,
" source " : [
" # Set up a grid of plots \n " ,
" fig, axes = plt.subplots(2, 1, figsize=figsize_with_subplots) \n " ,
" \n " ,
" # Histogram of AgeFill segmented by Survived \n " ,
" df1 = df_train[df_train[ ' Survived ' ] == 0][ ' Age ' ] \n " ,
" df2 = df_train[df_train[ ' Survived ' ] == 1][ ' Age ' ] \n " ,
" max_age = max(df_train[ ' AgeFill ' ]) \n " ,
" \n " ,
" axes[1].hist([df1, df2], \n " ,
" bins=max_age / 10, \n " ,
" range=(1, max_age), \n " ,
" stacked=True) \n " ,
" axes[1].legend(( ' Died ' , ' Survived ' ), loc= ' best ' ) \n " ,
" axes[1].set_title( ' Survivors by Age Groups Histogram ' ) \n " ,
" axes[1].set_xlabel( ' Age ' ) \n " ,
" axes[1].set_ylabel( ' Count ' ) \n " ,
" \n " ,
" # Scatter plot Survived and AgeFill \n " ,
" axes[0].scatter(df_train[ ' Survived ' ], df_train[ ' AgeFill ' ]) \n " ,
" axes[0].set_title( ' Survivors by Age Plot ' ) \n " ,
" axes[0].set_xlabel( ' Survived ' ) \n " ,
" axes[0].set_ylabel( ' Age ' ) "
]
} ,
{
" cell_type " : " markdown " ,
" metadata " : { } ,
" source " : [
" ## Kernel Density Estimation Plots "
]
} ,
{
" cell_type " : " code " ,
2015-07-08 10:50:52 +08:00
" execution_count " : 7 ,
2015-06-11 19:17:52 +08:00
" metadata " : {
" collapsed " : false
} ,
" outputs " : [
{
" data " : {
" text/plain " : [
2015-07-08 10:50:52 +08:00
" <matplotlib.legend.Legend at 0x113175ed0> "
2015-06-11 19:17:52 +08:00
]
} ,
2015-07-08 10:50:52 +08:00
" execution_count " : 7 ,
2015-06-11 19:17:52 +08:00
" metadata " : { } ,
" output_type " : " execute_result "
} ,
{
" data " : {
2015-07-08 10:50:52 +08:00
" image/png " : " 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brmF0NBQevfuzTvvvAO458rHjx9PWlpa \n nWU88sgjfPPNN1x33XXMmDGD0NBQTpw4Ue0eg8GA3W73/nzbbbfx/vvvoygKvXr1avBndDb9+/fn \n ww8/BMBms/HJJ5941wsYjcZqzz3Tnj172LVrF+D+otO3b19vAL3ttttYuHAhvXv3JjY21uc6bdiw \n gdGjR3PTTTfRsWNH0tLScLlcOJ1OhgwZQnl5OePGjWPGjBkcOHAAu91e6+v9+/fn3XffRVEUbDYb \n f/vb3/joo49qfbZOp2PQoEF8+eWX2Gw2HA4H//73v71/Xnwtz+OWW25hy5YtfPXVV94vWRkZGbzy \n yis1djGo0f7MzMxqX96EqIv09EWzs2zZMu66665qPRuLxcKECRN47733uPnmm7nlllsIDAykS5cu \n BAYGAnDfffexYMECRo8ejcvlonv37kybNq1G+Tqdjp9//tk7JK3T6YiPj+edd97xTge88MILzJo1 \n ixtuuAG73c7111/P9ddfz9GjR2v0uDw/33fffUyfPp3ly5djMBgYNmwYl19+OVu2bPHeM3DgQO+C \n xEmTJpGSkkJERES1Ff5nq29DTJ8+3Vtnm83GwIED+X//7/8BkJqayoIFC7Db7d52e8pOSkpi0aJF \n HDlyhNjYWBYsWOC9PnjwYKZPn86tt97aqPrdfffdzJgxgy+++ILIyEiGDh3K+vXrMRgM/OMf/+CR \n Rx7BZDKh0+mYO3cuAQEBtb4+ffp05syZw4033ojdbufqq6/2Dn3X9jv585//zMGDBxk9ejTBwcG0 \n a9fO++fFl/LOFB4eztK
2015-06-11 19:17:52 +08:00
" text/plain " : [
2015-07-08 10:50:52 +08:00
" <matplotlib.figure.Figure at 0x113175d50> "
2015-06-11 19:17:52 +08:00
]
} ,
" metadata " : { } ,
" output_type " : " display_data "
}
] ,
" source " : [
" # Get the unique values of Pclass: \n " ,
" passenger_classes = np.sort(df_train[ ' Pclass ' ].unique()) \n " ,
" \n " ,
" for pclass in passenger_classes: \n " ,
" df_train.AgeFill[df_train.Pclass == pclass].plot(kind= ' kde ' ) \n " ,
" plt.title( ' Age Density Plot by Passenger Class ' ) \n " ,
" plt.xlabel( ' Age ' ) \n " ,
" plt.legend(( ' 1st Class ' , ' 2nd Class ' , ' 3rd Class ' ), loc= ' best ' ) "
]
}
] ,
" metadata " : {
" kernelspec " : {
" display_name " : " Python 2 " ,
" language " : " python " ,
" name " : " python2 "
} ,
" language_info " : {
" codemirror_mode " : {
" name " : " ipython " ,
" version " : 2
} ,
" file_extension " : " .py " ,
" mimetype " : " text/x-python " ,
" name " : " python " ,
" nbconvert_exporter " : " python " ,
" pygments_lexer " : " ipython2 " ,
" version " : " 2.7.10 "
}
} ,
" nbformat " : 4 ,
" nbformat_minor " : 0
}