1
0
mirror of https://github.com/gsi-upm/sitc synced 2024-11-24 23:42:29 +00:00
sitc/ml1/2_3_1_Advanced_Visualisation.ipynb

807 lines
957 KiB
Plaintext
Raw Normal View History

2016-03-15 12:55:14 +00:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![](files/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](2_0_0_Intro_ML.ipynb)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Table of Contents\n",
"\n",
"* [Advanced Visualisation](#Advanced-Visualisation)\n",
"* [Install seaborn](#Install-seaborn)\n",
"* [Transform Data into Dataframe](#Transform-Data-into-Dataframe)\n",
"* [Visualisation with seaborn](#Visualisation-with-seaborn)\n",
"* [References](#References)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Advanced Visualisation"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In the previous notebook we developed plots with the [matplotlib](http://matplotlib.org/) plotting library.\n",
"\n",
2016-03-28 10:26:20 +00:00
"This notebook introduces another plotting library, [**seaborn**](https://stanford.edu/~mwaskom/software/seaborn/), which provides advanced facilities for data visualization.\n",
2016-03-15 12:55:14 +00:00
"\n",
"*Seaborn* is a library for making attractive and informative statistical graphics in Python. It is built on top of *matplotlib* and tightly integrated with the *PyData* stack, including support for *numpy* and *pandas* data structures and statistical routines from *scipy* and *statsmodels*.\n",
"\n",
2016-03-28 10:26:20 +00:00
"*Seaborn* requires its input to be *DataFrames* (a structure created with the library *pandas*)."
2016-03-15 12:55:14 +00:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Install seaborn"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You should install the SeaBorn package. Use `conda install seaborn`."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Transform Data into Dataframe"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"*Seaborn* requires that data is represented as a *DataFrame* object from the library *pandas*. \n",
"\n",
"A *DataFrame* is a 2-dimensional labeled data structure with columns of potentially different types. We will not go into the details of DataFrames in this session."
]
},
{
"cell_type": "code",
2016-03-28 10:26:20 +00:00
"execution_count": 2,
2016-03-15 12:55:14 +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>sepal length (cm)</th>\n",
" <th>sepal width (cm)</th>\n",
" <th>petal length (cm)</th>\n",
" <th>petal width (cm)</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>5.1</td>\n",
" <td>3.5</td>\n",
" <td>1.4</td>\n",
" <td>0.2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>4.9</td>\n",
" <td>3.0</td>\n",
" <td>1.4</td>\n",
" <td>0.2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>4.7</td>\n",
" <td>3.2</td>\n",
" <td>1.3</td>\n",
" <td>0.2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>4.6</td>\n",
" <td>3.1</td>\n",
" <td>1.5</td>\n",
" <td>0.2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>5.0</td>\n",
" <td>3.6</td>\n",
" <td>1.4</td>\n",
" <td>0.2</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" sepal length (cm) sepal width (cm) petal length (cm) petal width (cm)\n",
"0 5.1 3.5 1.4 0.2\n",
"1 4.9 3.0 1.4 0.2\n",
"2 4.7 3.2 1.3 0.2\n",
"3 4.6 3.1 1.5 0.2\n",
"4 5.0 3.6 1.4 0.2"
]
},
2016-03-28 10:26:20 +00:00
"execution_count": 2,
2016-03-15 12:55:14 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from sklearn import datasets\n",
"from pandas import DataFrame\n",
"\n",
"# iris data set from scikit learn (it is a Bunch object)\n",
"iris = datasets.load_iris()\n",
"\n",
"# transform into dataframe\n",
"iris_df = DataFrame(iris.data)\n",
"iris_df.columns = iris.feature_names\n",
"\n",
"iris_df.head()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"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>sepal length (cm)</th>\n",
" <th>sepal width (cm)</th>\n",
" <th>petal length (cm)</th>\n",
" <th>petal width (cm)</th>\n",
" <th>species</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>5.1</td>\n",
" <td>3.5</td>\n",
" <td>1.4</td>\n",
" <td>0.2</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>4.9</td>\n",
" <td>3.0</td>\n",
" <td>1.4</td>\n",
" <td>0.2</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>4.7</td>\n",
" <td>3.2</td>\n",
" <td>1.3</td>\n",
" <td>0.2</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>4.6</td>\n",
" <td>3.1</td>\n",
" <td>1.5</td>\n",
" <td>0.2</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>5.0</td>\n",
" <td>3.6</td>\n",
" <td>1.4</td>\n",
" <td>0.2</td>\n",
" <td>0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" sepal length (cm) sepal width (cm) petal length (cm) petal width (cm) \\\n",
"0 5.1 3.5 1.4 0.2 \n",
"1 4.9 3.0 1.4 0.2 \n",
"2 4.7 3.2 1.3 0.2 \n",
"3 4.6 3.1 1.5 0.2 \n",
"4 5.0 3.6 1.4 0.2 \n",
"\n",
" species \n",
"0 0 \n",
"1 0 \n",
"2 0 \n",
"3 0 \n",
"4 0 "
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"iris_df['species'] = iris.target\n",
"iris_df.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Visualisation with seaborn"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The following examples are taken from [a kaggle tutorial](https://www.kaggle.com/benhamner/d/uciml/iris/python-data-visualizations/notebook) and [the seaborn tutorial](https://stanford.edu/~mwaskom/software/seaborn/tutorial/axis_grids.html).\n",
"\n",
2016-03-28 10:26:20 +00:00
"To plot multiple pairwise bivariate distributions in a dataset, you can use the *pairplot()* function and *PairGrid()*."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Scatterplot"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2016-03-15 12:55:14 +00:00
"A **scatterplot matrix** (*matriz de diagramas de dispersión*) presents every pairwise relationship between a set of variables."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
2016-03-28 10:26:20 +00:00
"collapsed": false
2016-03-15 12:55:14 +00:00
},
"outputs": [
{
"data": {
"text/plain": [
2016-03-28 10:26:20 +00:00
"<seaborn.axisgrid.PairGrid at 0x7f316d1da390>"
2016-03-15 12:55:14 +00:00
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
2016-03-28 10:26:20 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA4IAAAN9CAYAAADGzcetAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz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EXwB4Wkr5\nkhBiRAixH8ASgH1Syl8V0k8icoZWhl6z945BpvsQuWj/gTGek+Qqfi5QufPDOZD3QHBlDcD/AuCf\nAdwGYGjlrl4ANwH4sRDiv0spv5atnZU5fztStv8+5d+fyrdfROQerQx96rbXLnZE5WToxIxum+ck\nOY2fC1Tu/HAOFPKL4OUArpBSLii3HwRwUAjxFQB/Z7lnROQbRiWSDwxN25KWRkT5W9sR0W3znKRi\nU1NB/VA6n6iY/HAO5D0QlFJ+Qvu3EOIKABGkTFCUUj4L4BMGuxJRiVLLgFcEgS9809vpEESlbPNA\nO89JcpSaBvfJXYNcHoLKWjAIbBvsxLnzi1hVU4mKoNs9SldwsRghxA+x/OvgaMrNCQDbrHaKiPxF\nLQP+xH79NGEvpkMQlbJgkOckOUtNgzt6IoabN3czzqhsHT0Rw7OvXBwmtTfWoa/bW+eDlaqhHVLK\n9bb1hIhKhh/SIYjKCc9JKjbGGJGeH84JKwPBXwkh1kopj9rVGSIqDWqqaH9PBAeGpjH2ymjGEspm\nl6DIxOr+RH6lxn4wCPz0lVGEaqswO3cBa1pC6OuNME2PCmbm+trXE8GenQMYHouhp70e/b2RDK3Z\n369sny1Ebrm0K4K7b+nH6GQMXdEwhAPnRL6sDAT/HcDrQogxAItYnieY4K+ERKSmih4Yms5ZQtlq\nmWU/lGkmKgY19rcNdib
2016-03-15 12:55:14 +00:00
"text/plain": [
2016-03-28 10:26:20 +00:00
"<matplotlib.figure.Figure at 0x7f316d1da240>"
2016-03-15 12:55:14 +00:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"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",
"%matplotlib inline \n",
"\n",
"sns.pairplot(iris_df)\n"
]
},
2016-03-28 10:26:20 +00:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## PairGrid"
]
},
2016-03-15 12:55:14 +00:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**PairGrid** allows you to quickly draw a grid of small subplots using the same plot type to visualize data in each. In a PairGrid, each row and column is assigned to a different variable, so the resulting plot shows each pairwise relationship in the dataset. This style of plot is sometimes called a “scatterplot matrix”, as this is the most common way to show each relationship"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
2016-03-28 10:26:20 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA4IAAAN9CAYAAADGzcetAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3XucHFWdN/5Pp6fnPmEmcXKBQBiQnLgBCQ9mFZEgFxFB\nhcC6yxJZwdVHgz93FTYuv30eg2bV126yrPjjEnh4CYgIUSAXfbhlXSAgKuCaIJMlXxIIkAtJhiQT\n5trTM+nfHz3VU3W6uru6u67dn/frxYtUV9XpU9Xfqu4z9T3nxNLpNIiIiIiIiKh2TAq6AkRERERE\nROQvNgSJiIiIiIhqDBuCRERERERENYYNQSIiIiIiohrDhiAREREREVGNYUOQiIiIiIioxtQF8aZK\nqRYA9wHoAFAPYLmIbDCtTwF4DkAMQBrAeSLCeS6IiIiIiIhcEEhDEMDVALaKyP9SSs0E8BSAD5jW\nHxKRcwOpGRERERERUZULKjX0XQBTx/89BUCPtj7mb3WIiIiIiIhqRyydDibjUin1OID3A2gHcLGI\nvGha1wdgPYDZANaIyA8DqSQREREREVEVCuSJoFJqMYC3ROQkAOcBuE3b5HoA/xPAJwEsVkr9D5+r\nSEREREREVLWC6iN4JoAnAUBE/qSUOlopFTMGhBGR/2NsqJT6TwCnAPhjvsLS6XQ6FmM2KbnC80Bi\nvJKLGK8UJYxXihLGK0VJWYEUVENwO4CPAFirlJoNoM9oBCql5gC4UUQWK6XqkGk0PlSosFgshp6e\nvrIr09nZVtH+bpRRDXWolmPwWqXxaseNc88yo1mm19yKVzeP362ywlaOm2WFtU5e4/2VZbpZpte8\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 +00:00
"<matplotlib.figure.Figure at 0x7f31664d8940>"
2016-03-15 12:55:14 +00:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# PairGrid\n",
"g = sns.PairGrid(iris_df)\n",
"g.map(plt.scatter);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2016-03-28 10:26:20 +00:00
"A very common way to use this plot colors the observations by a separate categorical variable. For example, the iris dataset has four measurements for each of the three different species of iris flowers.\n",
2016-03-15 12:55:14 +00:00
"\n",
2016-03-28 10:26:20 +00:00
"We are going to color each class, so that we can easily identify **clustering** and **linear relationships**."
2016-03-15 12:55:14 +00:00
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
2016-03-28 10:26:20 +00:00
"<seaborn.axisgrid.PairGrid at 0x7f31643557b8>"
2016-03-15 12:55:14 +00:00
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
2016-03-28 10:26:20 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA68AAAN9CAYAAAB8bk/NAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3Xuc21Wd+P9XJpO5Ze7tTK9QSm0PyEXQoqsoqCig4H4t\nrpflIrIIUnC9AcJjXVl0cR9AAQGFViriYhUVbcEfdy/cROWy0GWLcFpKaTst7Uw7M5lmJpNJMvn9\nkUkmn5N78sl13s/Hgwc9+XxycvLJ+XwyJ5/3OW9HOBxGCCGEEEIIIYSoZHXlboAQQgghhBBCCJGJ\nDF6FEEIIIYQQQlQ8GbwKIYQQQgghhKh4MngVQgghhBBCCFHxZPAqhBBCCCGEEKLiyeBVCCGEEEII\nIUTFqy/Hiyql3MDdQBfQAHxXa/1Y3PYA8DTgAMLASVpryekjhBBCCCGEEDNUWQavwBeA17TW31JK\nzQP+BBwet31Ia/3hsrRMCCGEEEIIIUTFKVfY8D5g1tS/u4EBY7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eOZaueVcPLca5b1gk1Lqd0Tuwu6KezgMnFBoo4QQ1SdZ\nigMJjRGiMrja2mLn5/ZrriY0NBjbJuelKAazX4U8Qyz896vL0xghKkjIM5S2LNIrZLXheVrrQ21r\niRCi5iQLJRZClJecl6IUpJ8JkZycG4UpZPD6glLqEK31m3Y1RghRW8xQ4u4VZ7B7ze3sSrE8vB1z\nZGWerZjJzP7fveJTDG5Yz679/YwPj1DX6qZh1mxa3nEsIc+QhG+KvGW61nav+BS+rVuZHPVS526l\ne8UZJW1Xqu8ZIcqt9f0
2016-03-15 12:55:14 +00:00
"text/plain": [
2016-03-28 10:26:20 +00:00
"<matplotlib.figure.Figure at 0x7f316455b978>"
2016-03-15 12:55:14 +00:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"g = sns.PairGrid(iris_df, hue=\"species\")\n",
"g.map_diag(plt.hist)\n",
"g.map_offdiag(plt.scatter)\n",
"#names = {i: name for i,name in enumerate(iris.target_names)}\n",
"#g.add_legend(legend_data=names)\n",
"g.add_legend()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"By default every numeric column in the dataset is used, but you can focus on particular relationships if you want."
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
2016-03-28 10:26:20 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAWAAAAFhCAYAAABOPXDpAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzsvXmcHFXV///u6dn3bJOEsAUkh11E4gLIqoIKQnDjIaAo\ngoCKCiJ8VRB90B8gkU0ggKBg2HeURfawKBIeQBblBCRkJWSdSWaf6enfH9U9U13TS/X0Pn3erxcv\n5tate+t0pvrMrVPnfk4gHA5jGIZh5J+KQhtgGIZRrpgDNgzDKBDmgA3DMAqEOWDDMIwCYQ7YMAyj\nQJgDNgzDKBCVuZxcRBqAm4AJQDXwK1V91NU/ADwLBIAwcLCqWl6c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a3nslvGFDPs0ZlyR9CRdx\nsPdF/jPGCe5Hy6Cnbyho70LHK6myGKKbb6JiPKHaKqq6RpzwUAAqXD442DIhn+aPS/xkQRjjDPej\nJTjxH3Cc75QzflwYo4yckyqLIXbzzX9p3GknOpe/OxwDbpqxLQOqw+cHAvbHOlPMAZch3kfLUDDA\nLtekLG5tlDjrejYkbXs3XgR7etj90muG216xnsF2C0FkijngMmHxU39h6Oa7CcCosEOorroQJhlZ\nwBs2SKazO6luIss2j8h6T66bGNMfbood11cT5G/nf4/6TX10N9fwoaZtYvtXruTtU0+ioqGBGT8+\ni9qp07L0qcoHP0U5jwHOZqQqcrQixtY5ts3IIkM33z287zyAE3YIBQOE6qrZ8gyrZFyqeMMGyXR2\nj541hwDOyndy3cRRWS4ru1fj1izbvOxdZvZEgr4bBnh3qyXsstfHGFi3hr6VK2FggDAQ6u9n5cUX\nsf1vf5flTzf+8bMC/gX
2016-03-15 12:55:14 +00:00
"text/plain": [
2016-03-28 10:26:20 +00:00
"<matplotlib.figure.Figure at 0x7f31669f2080>"
2016-03-15 12:55:14 +00:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"g = sns.PairGrid(iris_df, vars=['sepal length (cm)', 'sepal width (cm)'], hue=\"species\")\n",
"g.map(plt.scatter);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Its also possible to use a different function in the upper and lower triangles to emphasize different aspects of the relationship."
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false,
"scrolled": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
2016-03-28 10:26:20 +00:00
"/usr/lib/python3/dist-packages/matplotlib/axes/_axes.py:519: UserWarning: No labelled objects found. Use label='...' kwarg on individual plots.\n",
2016-03-15 12:55:14 +00:00
" warnings.warn(\"No labelled objects found. \"\n"
]
},
{
"data": {
2016-03-28 10:26:20 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA30AAAN9CAYAAAAnihC5AAAABH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nVfdtzGmqp8hEQqlxR3o8UY+Xe9l7KR9tTbXsYeza2tZcW8De5F7agz5r7RdD/zbGnA20EDF50Fr7\nPPDFOIeKiEQJlUfeuvs4Hq8fjzcQTrVQepBI0E1XLaW2tooDXf30uYfp6ffS0+9VqqcUVGxqXENt\nFWd0Ti/7svdSPpyYOjqFLG6ZD5Mu5GKM+QXBu34HIx52gEsz7ZSITA2hcsmr7tsYdSej3FMsRNLR\nVF/DVz61nO7uflbdt5Gefm94n35XpFBiY29WW72+gJCS0jswnHS73GRSvXOOtfbkrPVERKas2PQ1\npQeJxKffFSkWikUpdVMthjMZ9L1qjFlkrd2Trc6IyNQUSgfq7h2ktakGf2CEL35vQ7iEMg4Jl3YI\nSbb8g0ipCcVz13E3Jzw+vD4/LlycPGcay06ZQe/AcDjORXIt3vX12ks72XmwD/egj8a6aq69rDMr\n7eq6LflyyVmzeXXbERyC89Teu2x2obuUU5kM+jYD240xhwE/wZ+Xo7t/IpKuUJonwJp1W8aVUAYm\nLFmvsvZSTuKVEgfYsqeH5afO4rablxegVzJVxbu+AuFU4+EBL49t2J32NVfXbSmkHzy6JTyrzwHu\nfGQLP155eSG7lFOZDPq+DHwAOJClvoiIpFRCOZXHNNdJSlmy+FVsS75N9rqcjXZFcsUXcJJul5tM\nBn2vW2s3ZK0nIiLEL6F
2016-03-15 12:55:14 +00:00
"text/plain": [
2016-03-28 10:26:20 +00:00
"<matplotlib.figure.Figure at 0x7f316472ee80>"
2016-03-15 12:55:14 +00:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"g = sns.PairGrid(iris_df)\n",
"g.map_upper(plt.scatter)\n",
"g.map_lower(sns.kdeplot, cmap=\"Blues_d\")\n",
"g.map_diag(sns.kdeplot, lw=3, legend=True);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2016-03-28 10:26:20 +00:00
"## Pairplot"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"PairGrid is flexible, but to take a quick look at a dataset, it may be easier to use pairplot(). This function uses scatterplots and histograms by default, although a few other kinds will be added (currently, you can also plot regression plots on the off-diagonals and KDEs on the diagonal)."
2016-03-15 12:55:14 +00:00
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
2016-03-28 10:26:20 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA68AAAN9CAYAAAB8bk/NAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3XmYXEd96P1vz9bds/RIo9l7mdFi1YwWy7JHsmxZssFm\nCQackBgCjpcIQ7brm4uAJM+9b0hCknuTvAHC6/BmcWKwMRgwAZzEbIEg2whvigWyLam8odk3jSTP\n2j0zPX3/6OmePqf36X3m93keP1b1OV1dfaZOnT7dv6qfJRAIIIQQQgghhBBCFLOyQjdACCGEEEII\nIYRIRm5ehRBCCCGEEEIUPbl5FUIIIYQQQghR9OTmVQghhBBCCCFE0ZObVyGEEEIIIYQQRU9uXoUQ\nQgghhBBCFL2KQryoUqoGeBDYCFQBn9Rafz9i+wLwJGABAsCNWmvJ6SOEEEIIIYQQ61RBbl6Bu4Cz\nWuv/pZRqA/4T6I7YflFr/eaCtEwIIYQQQgghRNEpVNjweWDT8r8bgHHTdkt+myOEEEIIIYQQophZ\nAoHCROMqpb4DbAM2ADdrrZ+N2DYFPAp0AN/QWn+mII0UQgghhBBCCFEUCvLLq1LqNqBXa30ZcCPw\nOdMuHwU+DLwNuE0pdWWemyiEEEIIIYQQoogUas7rQeB7AFrrU0qpdqWUJbQok9b6H0M7KqV+COwG\nno9XWSAQCFgsEmkssibnnUn6rMiBnHYo6bMiB2SsFaVG+qwoNWuuMxXq5vVV4ADwTaVUBzAVunFV\nSm0H/khrfZtSqoLgje4jiSqzWCyMj09l1KCmprqM6sj0+dKG7Dw/W23ItWz0WbNsHLt81St15ubv\nlEvZ7LPZOgbZPJbFWNd6aFOulcpYK3WWzrUr13LRZyPl6njLa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QcHpRaNIHxXogn4UyU+hfXu8GvhDj8Y8CDy3/+wml1ONa6+fz1ioh\nRG7ECBMTQhQJCacXhSZ9UKwH8lkoI5ZAoHDrICmlzgK7tNaLCfb5S+C01vqBBFXJYk4im/IRti59\nVmRbrvut9FmRbTLWilIjfVaUmjU3FbNgv7wqpdqAKfONq1JqO/BHWuvblFIVwEHgkVh1RMr0m4um\nprqM6sj0+dKG7Dw/W23Ih2x/25aNY5dRvaYUB5Xdu8ASe3GXXLR1PdcZqjfXstXubB2DbB7LYqwr\nm21qbKhm6MdPp3R+5qtNMtauszrjXCMKfu1Ks858yOWvcbk63vIaaVg+F/wjg1S0Olc9HqciX302\nn1Z186qUchEM7X07wXmpAOeA7wKf0VqnkjW6DQjPdVVK/T5wTGv9jFKqXyn1LOAHHtVan1hNO4UQ\n+ROV4uDoUQn9EqJIXHjuhJyfoqDkGiFEkJwLmUn75nU5R+vHgb8DfhnoXd7UAdwEfE8p9f9qrT+f\nqJ7lOaw3R5T/MuLff5Buu4QQhRWV4qC/XwZjIYrETG+voSznp8g3uUYIESTnQmZW88vrLuByrfWC\n6fHTwGml1N8Df5Fxy4QQJSXm0u9phBILIXKnpqPTUK6sr2Pqe4/JeSlyxzT+S3oQIYKizgWXq0At\nKU1p37xqrY+G/q2UuhyoJ2IysNb6CeBojKcKIdawWCkOJDRGiOLQsL8nfH5W1tcx+PBX8M/MAnJe\nityIGv8//jFJgyMEECgvo/HQdfi9XsptNqgoL3STSsqqF2xSSv0rwV9hByMeDgCHM22UEKIExUhx\nIKExQhQHS9nK+Tn1vcfCN64g56XIjajx/1wvdW+7WfqaWPd853o5/+SPw+XK1jaqlHyZk6pMVhtu\n01pvyVpLhBBrjoSJCVF85LwU+SD9TIjY5NzITCY3ryeUUp1a63PZaowQYm2JCiXu2sn86VP0xVse\nPhtzZGWerVjPzP2/ayf
2016-03-15 12:55:14 +00:00
"text/plain": [
2016-03-28 10:26:20 +00:00
"<matplotlib.figure.Figure at 0x7f31647346a0>"
2016-03-15 12:55:14 +00:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.pairplot(iris_df, hue=\"species\", size=2.5);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can also control the aesthetics of the plot with keyword arguments, and it returns the PairGrid instance for further tweaking."
]
},
{
"cell_type": "code",
2016-03-28 10:26:20 +00:00
"execution_count": 16,
2016-03-15 12:55:14 +00:00
"metadata": {
2016-03-28 10:26:20 +00:00
"collapsed": false
2016-03-15 12:55:14 +00:00
},
"outputs": [
{
"data": {
2016-03-28 10:26:20 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA68AAAN9CAYAAAB8bk/NAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzsvXt0W9d95/sBQYAASYAEQIBP8SHH2rJlRw4tKZadsZ3E\ntd3UbR69STPx6iOdaSa963Z6p53edjqTTNNpZ7Uz7XQ6nd6mybrJTG5v606aOG5TJ3YffsSOH3Gc\n+BV725ZkSRQlPiESIgE+gHP/AAHiHLzfAPn7rKUlbpxzNn44+O19sM/5/X5fm2EYCIIgCIIgCIIg\nCEIr09FsAwRBEARBEARBEAShGLJ4FQRBEARBEARBEFoeWbwKgiAIgiAIgiAILY8sXgVBEARBEARB\nEISWRxavgiAIgiAIgiAIQssji1dBEARBEARBEASh5elsxpsqpXqALwE+wAn8ptb64YztW8C3ABtg\nAO/VWoumjyAIgiAIgiAIwj6lKYtX4GeA17TW/1YpNQz8I3BNxvaw1vo9TbFMEARBEARBEARBaDma\nFTa8CAR2/vYDC5bttsaaIwiCIAiCIAiCILQyNsNoTjSuUuobwNuAfuBHtNbPZmyLAA8AE8BXtdZ/\n0BQjBUEQBEEQBEEQhJagKU9elVL3Ame11lcD7wX+2LLLLwOfAO4C7lVKTTfYREEQBEEQBEEQBKGF\naFbO6y3AQwBa6xeVUiNKKVuqKJPW+nOpHZVS/wBcDzyfrzPDMAybTSKNhZpRd2cSnx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sEQRhz5ErlFgQhOYi41JoBOJngpAbGRvVUc3i9Tml\n1KTW+q1aGSMIwt7CGko
2016-03-15 12:55:14 +00:00
"text/plain": [
2016-03-28 10:26:20 +00:00
"<matplotlib.figure.Figure at 0x7f315f49c9e8>"
2016-03-15 12:55:14 +00:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
2016-03-28 10:26:20 +00:00
"g = sns.pairplot(iris_df, hue=\"species\", palette=\"Set2\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Violin Plots (boxplot)"
2016-03-15 12:55:14 +00:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[**Box plots** or **boxplot** ](https://en.wikipedia.org/wiki/Box_plot) (*diagramas de caja*) are a convenient way of graphically depicting groups of numerical data through their quartiles."
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
2016-03-28 10:26:20 +00:00
"<matplotlib.axes._subplots.AxesSubplot at 0x7f2758563ef0>"
2016-03-15 12:55:14 +00:00
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
2016-03-28 10:26:20 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYEAAAESCAYAAAAbq2nJAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAGjVJREFUeJzt3X+UXGWd5/F3/yDSHRLoYLsEEAj++LCMzO6IGRxwQYFR\ndiGiccg4tIi6jiuOgoOTUdkDRMAswgEVlllWzuIMCwsGRcIOAUEhEAaIcdk5qJivMLCABKRJCkg6\nv7tr/7i3SKVJV99u+tbt6vt5nZOTqntvPfXtTqc/9Tz33udpq1armJlZObUXXYCZmRXHIWBmVmIO\nATOzEnMImJmVmEPAzKzEHAJmZiXWmWfjkqYD1wE9wDTggoi4q25/H3AWMAhcExHX5lmPmZntLO+e\nwKeA1RFxLHAK8N3aDkndwLnAscAHgL+WtFfO9ZiZWZ28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TfDfgOvovYzKzlNRoOmg18nGSx+PPq\ntg+RLDlpZmYtrtFw0EPAQ5KWRYQ/9ZuZTUFZLhH9mKT5w7ZtBwK4KiI2THxZZmbWDFkujF0DHAj8\nM8nCMvsBFZJlJq/LrzQzM8tblp7AvwGOi4jtAJKuAm6JiA9Lum+0F0vqAxYC24DzaktTpvuOB75J\n0rO4IyIuGsfXYGZm45SlJ7APyQLz9Q5I1xee2eiFkmaRnFQ+kmRRmpOHHfJd4KPA+4APpktWmplZ\nk2TpCdwMPC7p5yRXBh0O3EaytORto7z2eODuiNgIbAQ+X9shaQ6wNiLWpM+XkaxXvHqsX4SZmY3P\nqCEQEd+U9AOSYaF24MKI+KWkjogYHOXlBwHTJS0F9gK+UTfdxD5Af92xL5Lcl2BmZk2SZSrp3YE/\nIBn6aQPmSpobEddmaL+
2016-03-15 12:55:14 +00:00
"text/plain": [
2016-03-28 10:26:20 +00:00
"<matplotlib.figure.Figure at 0x7f27580d7198>"
2016-03-15 12:55:14 +00:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# We can look at an individual feature in Seaborn through a boxplot\n",
"sns.boxplot(x=\"species\", y=\"sepal length (cm)\", data=iris_df)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
2016-03-28 10:26:20 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXgAAAESCAYAAAD38s6aAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XeYXNWZ5/HvvRU6tzqolZBQIBxJ5CBLBBuMwUQD4wAm\nOQ0M45zG3jXrBYw92OO8zOKZtWc8YxtswDgQTDRYBGNARCOEDsICIaGsbrU6Vrp3/6jq6q6O1VLf\nqq7q34eH56k6N70ttd46de6573F830dERMqPW+wAREQkGErwIiJlSgleRKRMKcGLiJQpJXgRkTKl\nBC8iUqbCQZ7cGFMD/BxoBKLAddbaB4K8poiIpAXd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kBlZkJkHHgaTz6PoZW4DJ9UHJP4eMCHunZN6vxeW3YQZzSpQQvInmrqakh\nEo8V9UEnfJ+qPR05TQ4Oqeoq2sP9Ke1wx+HwzOvajk4Y9IRorLIyPcPGcQglkxwELAyHszdli+Wm\n9laiNTUTci4leBEpLY5DynUJD0jYPpAcJTknImFCsXhOW3VvjGQiiedANJkCwHMcOmtr8ItYimEi\nlcdPISJTSndNNUnXxSedlLuqq0fteccqKuitiOIN2iecSmWTO4Dr+1QM+iAoZWP24I0xhwNnkF6d\nCeAN4D5r7V+DC0tEZGS+69JVVzvKDj6RRIJQyiMZDpOMhIlVVuL4UBEfPYE7AVfYLaQRE7wxZjbw\nn8As4I/Ay5lN84H/NsZsAS631m4JPEoRkXGo6uklmkgvtF0Rj9NTWUm8Iko8GiEaj+fcbh1c6iBe\nRk+1jtaDvx24xlr7x+E
2016-03-15 12:55:14 +00:00
"text/plain": [
2016-03-28 10:26:20 +00:00
"<matplotlib.figure.Figure at 0x7f2758662240>"
2016-03-15 12:55:14 +00:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# One way we can extend this plot is adding a layer of individual points on top of\n",
"# it through Seaborn's striplot\n",
"# \n",
"# We'll use jitter=True so that all the points don't fall in single vertical lines\n",
"# above the species\n",
"#\n",
"# Saving the resulting axes as ax each time causes the resulting plot to be shown\n",
"# on top of the previous axes\n",
"ax = sns.boxplot(x=\"species\", y=\"petal length (cm)\", data=iris_df)\n",
"ax = sns.stripplot(x=\"species\", y=\"petal length (cm)\", data=iris_df, jitter=True, edgecolor=\"gray\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[**Violin plots**](https://en.wikipedia.org/wiki/Violin_plot) (*diagramas de violín*) are a method of plotting numeric data. A violin plot is a box plot with a rotated kernel density plot on each side. A violin plot is just a histogram (or more often a smoothed variant like a kernel density) turned on its side and mirrored."
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
2016-03-28 10:26:20 +00:00
"<matplotlib.axes._subplots.AxesSubplot at 0x7f2758c08588>"
2016-03-15 12:55:14 +00:00
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
2016-03-28 10:26:20 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXgAAAESCAYAAAD38s6aAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl8XGd97/HPrNp3ybIl79vjOI5JQjZnb6gTyEIgJECA\nJNCG4l7SDW5v29tCy9KWFy200Feo0/RSbtkhlwAhCYlDnNVZyWonfuIttiVvkrVYy2i2c+4fM5Jl\nW8vI1pmRjr7v10svzxydOeenKPrNM7/znN8TcF0XERHxn2ChAxAREW8owYuI+JQSvIiITynBi4j4\nlBK8iIhPKcGLiPhU2MuDG2PKgP8GaoAo8EVr7cNenlNERDK8HsF/HNhqrb0CuAn4hsfnExGRLK8T\nfDtQl31cC7R5fD4REckKeH0nqzHmQWApUA1cY6193tMTiogI4PEI3hjzUWC3tXYZ8C7gTi/PJyIi\nR3l6kRW4CHgIwFr7mjGmyRgTsNaO+LEhlUq74XDI45BERHwnMNJGrxP8duAC4F5jzAKgZ7TkDtDZ\n2e9xOCIi/tPQUDHidq8T/F3At40xjwEh4FMen09ERLI8v8g6EW1tPVMnGBGRaaKhoWLEEo3uZBUR\n8SkleBERn1KCFxHxKSV4ERGfUoIXEfEpJXgREZ9SghcR8SkleBERn1KCFxHxKSV4ERGfUoIXEfEp\nJXgR8TXHcejs7Cx0GAWhBC8ivvb973+Hz37202zf/lahQ8k7JXgR8bWNGx8BoKVlb4EjyT8leBGZ\nEaZSa/R8UYIXkRkhHo8XOoS8U4IXkRmhr6+30CHknRK8iPjW8LJMd3d3ASMpDCV4EfGt/v6+ocdd\nXTNvqqSni24bY34PuAVwgQDwTmttpZfnFBEZdPhw+7DHbQWMpDA8TfDW2m8D3wYwxlwK3OTl+URE\nh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8dhvvSlv2HDhgcL\nHYoAsVimZ1U0h7bA9fX1rF27FoC1a9dSX18/7msGjzswoAQv4nvbt7/Frl07+eEPv1voUITMRVbI\nlFPG097ezoYNGwDYsGED7e3jt8IaPO7geaYzz1sViEx3PT1HCh2CnKREIsH69eu55557aG9vJ5FI\nQHFZocPKGyV4kXEMv+nFcRyCkzw1TyYmmO0744zSiuB4iUSCffv25Xz8wdbCfvg9j5vgjTGrgXeT\nWZ0J4G3g19ba17wLS2TqGD6jorOzg7q68eu44p1QKJN4HY+OP1iYCeU4S2cqGzXBG2PmAP8HmA08\nAmzJfmsB8B1jzH7gdmvtfs+jFCmgvXv3HPNYCb6wQtneM14l+MHjhiapx00hjfUT3AP8rbX2kZG+\naYxZC/wUuNiLwESmgp6eIxw8eHQEv2PHW5x55tkFjEgGSyejrdJ0qgaPO/hJYTob6ye4erTkDmCt\n3QBcM/khiUwdW7a8DkDJ8moIBti8WZXJQhssnXg1gh982/B1Dd5a2w1gjLkF+AxQSWYR7QDgWmsX\nD+4j4lcvvvg8ANF55aS64uze/TZtbYdoaJhV4MhmLq8T/NEa/PQv0eTyFvV54E+BK4G1wO9m/xXx\nte7uLl599SVClVFClRGi88oBePLJxwob2AwXyTYES3tUokm7LqFQyN8j+GHetNb6pwO+SI5+85uH\nSafTlC2qJhAIUNRcRv/rh9m48RGuvvq9FBdPXi9yyV1JSSkACY8SfNx1KSkZeZWo6SaXBH+XMeZh\nMgtnDy1Jbq394ngvNMZcRuZC7GYypZ3XrLV/cpKxiuTNkSNH2PDIrwkWhShaUAFAIBykeHElfVu7\neOSRX3Ptte8rcJQzU3V1NQC9zuQXaVzXpd91aKiumfRjF0IuCf6fyST3ABA5iXM8Zq394Em8TqRg\nfvazHxMfGKD0HXX0v5m
2016-03-15 12:55:14 +00:00
"text/plain": [
2016-03-28 10:26:20 +00:00
"<matplotlib.figure.Figure at 0x7f2758c13ac8>"
2016-03-15 12:55:14 +00:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# A violin plot combines the benefits of the previous two plots and simplifies them\n",
"# Denser regions of the data are fatter, and sparser thiner in a violin plot\n",
"sns.violinplot(x=\"species\", y=\"petal length (cm)\", data=iris_df, size=6)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2016-03-28 10:26:20 +00:00
"## Kernel Density Estimation (KDE)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Another useful representation is the [Kernel density estimation (KDE)](https://en.wikipedia.org/wiki/Kernel_density_estimation) plot. KDE is a non-parametric way to estimate the probability density function of a random variable. The kdeplot represents the shape of a distribution. Like the histogram, the KDE plots encodes the density of observations on one axis with height along the other axis:"
2016-03-15 12:55:14 +00:00
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
2016-03-28 10:26:20 +00:00
"<seaborn.axisgrid.FacetGrid at 0x7f275899eb00>"
2016-03-15 12:55:14 +00:00
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
2016-03-28 10:26:20 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAdUAAAGpCAYAAADbWaxNAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3XecXGd99v/Pmba9a9WrLemWbMkV9woy2AaDA6abEEgg\nCSGVB55fSEISEpLwMoFQ8iQkhFBDCxiMgzGG4G65N1nllmT1uqvV9tndaef3x8ysVkKrnZ05s2fm\n7PV+xUHanTnz1ay0197lfG/HdV1ERESkdCG/CxAREQkKhaqIiIhHFKoiIiIeUaiKiIh4RKEqIiLi\nEYWqiIiIRyKFPMgYcwdwNRAGPmmt/eGEz+0G9gEZwAVut9YeLkOtIiIiFW3KUDXGXA+cY6290hjT\nDjwH/HDCQ1zgJmvtSHlKFBERqQ6FTP8+CLwl9+s+oN4Y40z4vJP7T0REZFabcqRqrXWB/Cj0fcA9\nuY9N9EVjzArgYWvtn3lco4iISF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u3/V+1dExDsK1YBKFdBM\nf+LnNf0rIlI6hWpApdKFhWpE078iIp5RqAZUIce+Tfy8QlVEpHQK1YBKFnBCDTB+H6umf0VESqdQ\nDahkgdO/GqmKiHhHoRpQ+ZCcqqOSzlMVEfGOQjWgCl1Tjaj3r4iIZxSqAVVoqIZDDo6jkaqIiBcU\nqgFV6Jqq4zhEI6Hx+1pFRKR4CtWAKnT3b/4xGqmKiJROoRpQhTZ/gOxB5VpTFREpnUI1oMZ3/xYQ\nqtFwSPepioh4QKEaUIVuVMo/RiNVEZHSKVQD6sSaanjKx2qkKiLiDYVqQBW6+xe0pioi4hWFakCd\nGKk6Uz42O1J1ybhuucs
2016-03-15 12:55:14 +00:00
"text/plain": [
2016-03-28 10:26:20 +00:00
"<matplotlib.figure.Figure at 0x7f275899e630>"
2016-03-15 12:55:14 +00:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# A final seaborn plot useful for looking at univariate relations is the kdeplot,\n",
"# which creates and visualizes a kernel density estimate of the underlying feature\n",
"sns.FacetGrid(iris_df, hue=\"species\", size=6) \\\n",
" .map(sns.kdeplot, \"petal length (cm)\") \\\n",
" .add_legend()"
]
},
2016-03-28 10:26:20 +00:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Choosing the right visualisation"
]
},
2016-03-15 12:55:14 +00:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Depending on the data, we can choose which visualisation suits better. the following [diagram](http://www.labnol.org/software/find-right-chart-type-for-your-data/6523/) guides this selection.\n",
"\n",
"\n",
"![](files/images/data-chart-type.png \"Graphs\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## References"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* [Feature selection](http://scikit-learn.org/stable/modules/feature_selection.html)\n",
"* [Classification probability](http://scikit-learn.org/stable/auto_examples/classification/plot_classification_probability.html)\n",
"* [Mastering Pandas](http://proquest.safaribooksonline.com/book/programming/python/9781783981960), Femi Anthony, Packt Publishing, 2015.\n",
"* [Matplotlib web page](http://matplotlib.org/index.html)\n",
"* [Using matlibplot in IPython](http://ipython.readthedocs.org/en/stable/interactive/plotting.html)\n",
"* [Seaborn Tutorial](https://stanford.edu/~mwaskom/software/seaborn/tutorial.html)\n",
"* [Iris dataset visualisation notebook](https://www.kaggle.com/benhamner/d/uciml/iris/python-data-visualizations/notebook)\n",
"* [Tutorial plotting with Seaborn](https://stanford.edu/~mwaskom/software/seaborn/tutorial/axis_grids.html)\n",
"* [Choose the Right Chart Type for your Data](http://www.labnol.org/software/find-right-chart-type-for-your-data/6523/)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Licence\n",
"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",
2016-03-28 10:26:20 +00:00
"version": "3.5.1+"
2016-03-15 12:55:14 +00:00
}
},
"nbformat": 4,
"nbformat_minor": 0
}