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

764 lines
1.0 MiB
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",
"This notebook introduces another plotting library, [**seaborn**](https://stanford.edu/~mwaskom/software/seaborn/), that provides advanced facilities for data visualization.\n",
"\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",
"*Seaborn* requires that the data is provides as *DataFrames* (a structure created with the library *pandas*)."
]
},
{
"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",
"execution_count": 19,
"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"
]
},
"execution_count": 19,
"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",
"To plot multiple pairwise bivariate distributions in a dataset, you can use the *pairplot()* function and *PairGrid()*.\n",
"\n",
"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": {
"collapsed": false,
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"<seaborn.axisgrid.PairGrid at 0x7fb8581e7198>"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAs8AAALJCAYAAABLK86qAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3Xt8XHd95/+XZEm2Nbr4otHFusXg5KuJ8Q/UODYhRUnc\ntNCYJG3TQgOFupQAu7S7bPJrS+iP3W37aB+0QFrY0nYX0wDbkNJtukmLIQRoiElIc2HdLrGdby4k\nlu1YF9uyZEm2ZUnz+2Nm5DlHczkzc2bmjOb9fDzyiM+cc77zPWe+5ztfzfmcz7cmGo0iIiIiIiLZ\n1Za7AiIiIiIilUKDZxERERERjzR4FhERERHxSINnERERERGPNHgWEREREfFIg2cREREREY/qSv2G\nxpg64MvAZcA8cIe19oWk9R8FPgCMxV/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dSD58NKf5trn+hFaF7R+vpDB82D8/z+R9FqU2HTaIiLU1sZuI5+7MM/a\n1XWscj2inCrdXa78KEOkUiTa+wtHzzA5M8c3f/AKQ4PdrG9eQ/v6NczMXuSu2wd1HUhevPSnufa5\nfoRcJN5z5PQsnRsay96+8x48W2tvMMa0W2vHjDGNwCZr7Ute9jXG/Cqwh9hgey3wRqDTWjsVX38z\n8Ali037fa63dm289RaR8Xj0xzf4Dx5eWO9c3MtB7qdNMle4uV36UIVIpEu396Og0//T4KwDsP3Cc\n97zNcE2ko8y1k0rnpT/Ntc/1I+Qi8Z7Xb+9jfPxsTvsWQ96p6owxvwk8HF8MA/9kjPmgl32ttV+2\n1t5grd0F/BD4zaSBcx1
"text/plain": [
"<matplotlib.figure.Figure at 0x7fb8581e70f0>"
]
},
"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"
]
},
{
"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": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA4MAAAN9CAYAAAApD6yTAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3Xu8XFV9///XcO63cAKcXCAUwm2FL/AlFFMfVkmUUv2J\nQgnoF+TSAtpiQPtF+IYvtD/tT36P9meJqFUh+GsoWORiFRO0UUlFDJdaLpbwI5SsJBAgCZCEkJOc\n+y3z+2POzJm9zj4zc2b27L1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nkpYdN3g0j8z4NpdwattWsKeM7DxTVHqln22IHO9kbOOPEI9vUMaTrpKuBOD7508XxWrtkYyFgl\nESnOsotOZ2hoVOelhMYdI7h0yXxAS0dIbVu6eD5bd+6nf3CE1uaGzHkRF0VPIGOMuR74CnDo+EMJ\nIGmtrQuiYVJ93JzpRQtm8ZUrF0XYIgmKOz34yjUbNU5EJGIz2nReSrg0RlBkstVPbGNfzxAAQyND\nrF6/LVbnRSmziV4PLLTWvhlUY6S6xT1nWoKjz1okfnReSrkpxkQmi/t5UUpn8L+AXUE1RKrTqzu6\nue3BFxgZS05a/CRuOdMSHL/8+HxTK09neYqpBFGHSKWZlJq3eD6rn9jG3gOD7DswRHtLPXMOb6Oz\n3Xsu6Bos01HI9dWNMbdcznaVe9p+kWI1NyRylqNWSmfw28BLxpj/AEbTD1prry65VVI10h1BSK2q\nmgCOmdOhsQNVzh1DeMXHTuK+R3NPrRxEepFSlKQWuXG/def+TEoSwL7eIbbv6eOME49g0YJZGr8l\nRSnk+ppIJHKWy92uNF3
"text/plain": [
"<matplotlib.figure.Figure at 0x7f4f76a815f8>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# PairGrid\n",
"g = sns.PairGrid(iris_df)\n",
"g.map(plt.scatter);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"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 three different species of iris flowers so you can see how they differ.\n",
"\n",
"We are going to color each class, so that we can identify easily **clustering** and **linear relationships**."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<seaborn.axisgrid.PairGrid at 0x7f4f749f4320>"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA7AAAAN9CAYAAACqy5WoAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJRE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2AaEgEXAicA6pdQvtda3ZKtHa73KVL4/6f/vA+4rtG1C\niMoyp+Awl4UQlSHHpqgG0g+FmCbHQ/GKuQPbp7X+UJrHX5n6d5tS6szSmiWEqEWyJLwQ1UmOTVEN\npB8KMU2Oh+IVPIDVWj+cxz4PFtccIUQtM6c/6F5+Bm/fcXvOObFCiPLqXXE2Ho97ag6sHJvCHuY5\nr93Lz0RS5AgR0738TAJbthD1+3C0eOlefkalm1Qzil7ESSl1KfCvQMfUQw4gqrV2WtEwIUTtMac/\nePuO22W+kxBVwNXayiFXXpZYjESOTWEHmfMqRGaD6x4iMjQYKwQnGFz3kBwfeSplFeJLgSO11tut\naowQor7I/A4hqpMcm8IO0s+EyEyOj+KVMoB9BdhtVUOEEPXHPL/D2dHF23fcTl+WJePzTcWTjRV1\nCFGr0oVt7v3lL9iyWTMZjdJ88BKcHZ2G58jcK1GMXOdacz9zdnTZ2q5s1xohKi3qacpaFpmVMoC9\nBfiHUuovQDj+oNb6yyW3SghRF8xzYqPhcM4l460IOZOwNTGTmft/YMuW6TA1wP/iBrxHvpvWo98j\ncxFFSXKdax2OBsP+DofD9nZJehJRrSbe2JK1LDIrdQC7llgaHSGESGGeE7vte98xbE8XLmNFSI2E\n5YiZzNzfJ8d8KfuEhwd
"text/plain": [
"<matplotlib.figure.Figure at 0x7f4f749f4dd8>"
]
},
"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": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAWEAAAFhCAYAAACh/xvXAAA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taKR4d4h9r9vWepamb4pyp5/74X9\ngrSw/HG7E55pjHkMy/k+C6zB0o7YDitH+Djgfg9zuOkJnws8hiWPuVBE3h3TWSgFURVLD/FXx+Di\nT15Q1DsEpTypHhhOazuvlfimTeNpzoTETdT9F8aYu4GzgLuAnYEY1lrGh4DjRCSnuloOPeHFwOKx\nma4Ui5HqUNqHa6R6PEq1KeVArKGWcO/oe3nntaIZM4XjGhMWkfXA/yb+KROItFhfuApGYlTFrQ/Z\n1PO+E7R5ik/kSjFLrpJMCvjMOPNbvHvdglRMuOOkU+hbdBcjfb1UNTUz+ZjPBXg2E4NxKXmvlB5p\nsb5YjMHmOva86saArVL8JleKWfoqyX/TTCjtunjnhuuIbbZCELHhTWy6/z5dgFEgVUEboASDM9bn\nbCsTk40Dm1zb+Qr2qAhP4eidcAWx4qmHGFl0LyHAWSAw1lAbhElKEXCGENx0erdqmMzbPWtS7SkN\n6QI98Zb0fkN11fzxp9+ksXuI/tY6dmrZLm1/VXML/z7/3ER4ooltvjOP+mnTi3RmlYEX7YgdsJYu\nT8HKYgC0skY5MrLo3tSjTwgYAWLVIWINtWx7nlZILlecIQQ3nd7jZx1DCOsOeErD5C1SENf2v8dU\nW7vn7TeZOZB4EbcpwpsfWMVu+x2QEuEZWLmCWJeV3h8bHmbt5Zey42VXFvX8Jjpe7oTvBR4HniPP\n5cpKaeHMeQgBu914axC
"text/plain": [
"<matplotlib.figure.Figure at 0x7f4f749f0d30>"
]
},
"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": [
"/home/cif/anaconda3/lib/python3.5/site-packages/matplotlib/axes/_axes.py:519: UserWarning: No labelled objects found. Use label='...' kwarg on individual plots.\n",
" warnings.warn(\"No labelled objects found. \"\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA4MAAAN9CAYAAAApD6yTAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3XmcXFWd//9XdXX13kln6SwQSEIgJ8iWANFBBQRZRrYv\nARVlGREXBMRx4BuEmdEZ8/195+cQt9HB4BiGKCLgQgIOKBlZEmAUgyZIIDlZSUggezrpvaq66/tH\ndVWqbldXVde9tfb7+XjwILdu3XPPrfrU6Tp1P+ccXyQSQUREREREREaWqmJXQERERERERApPnUER\nEREREZERSJ1BERERERGREUidQRERERERkRFInUEREREREZERSJ1BERERERGREai60Cc0xlQDPwam\nAWHgc9baDQn7vwx8Ftgz8NDN1tqNha6niIiIiIhIJSt4ZxC4BPBbaz9gjLkA+Bfgown7zwBusNau\nLkLdRERERERERoRipIluAKqNMT5gNBB07D8DuMcY86Ix5u6C105ERERERGQEKEZnsAOYDqwHfgh8\nz7H/EeALwHnAB40xlxS2eiIiIiIiIpWvGGmifwf81lr7D8aYo4HnjTEnW2tjdwj/zVp7GMAY8xQw\nB3g6XYGRSCTi8/nyWmkZMfIeSIpX8ZhiVsqJ4lXKieJVyklOgVSMzuABIDTw77aBOvgBjDGjgLXG\nmFlAN3A+8ECmAn0+H3v3tuentgNaW5vzeo58l1+Ic1TKNeRbPuI1H69Lvl7rcqlrOZWZb/luYyul\n7dA1ZHeOfHMbr168Dm7LKPbxpVCHUrmGfPOqffXy8+tVWapT4cvJRTHSRL8LnGGMWQn8Dvh74Epj\nzGcH7gjeA7wArADWWmt/W4Q6ioiIiIiIVLSC3xm01nYC16TZ/zDwcOFqJCIiIiIiMvJo0XkRERER\nEZERSJ1BERERERGREUidQRERERERkRFInUEREREREZERSJ1BERERERGREUidQRERERERkRFInUER\nEREREZERSJ1BERERERGRE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1n4vXTnW2m86th9J+PfDwMPDrZuIFIdzenvntoi4o8+YlDLF\np4wklRbvudwZ3Gmt/XCKx98c+O8+Y8zV7qolIuWk0qZZFik1+oxJKVN8ykhSafE+7M6gtXZZFs/5\nVW7VEZFy5Jw+fN4501m0bG1WYwhFJLMbLp5JbW012989RHt3mF37O1m0bK0+W1IUzjGC886dDmgJ\nCRkZ5p0znU07D9HVE6KhLhCP/3KV8wQyxpgvA18DRg885AMi1lq/FxUTkfLhnD580bK1Gt8k4qGm\n+hq+8jdzWfCj37N9/R4Otvfy9t5OQJ8tKTyNYZWRbOnKrRxs7wWgN9TL0hVbyzr+3cwm+mVgtrV2\nu1eVEZHKUGn59CKlQp8tKQWKQxnJKi3+3XQG3wR2e1UREakcqfLpM03FPJzlKYbiRRkipSAxlsc0\n1RLq62PrrnZ6evqSnlfuY1WktA3VprY0Jberzm0vzunVtP0iXqsL+NJulxs3ncHvAa8bY/4AhGMP\nWmtvcl0rESlrzjGEN1w8k4eeST8VsxdpR0pdkkqRFMsMXn+qodbPSdPHaWyW5NVQbarPl/zl17nt\n1Tlj1I5LKdn8Tnva7XLjtjP4U6JLS4iIxDnHEELmtAov0i4qLXVDRq5MsTthTIO+IEveDdWmxsZL\nxTi383FOkVIR6ouk3S43bjqDPdbaBZ7VREQq2pim2qQ7HGOaa5P2ezFVc6VN9ywjlzOWU+0Xybeh\n2tRs29pcUvfVjkupC/h9SR3AgH/kpon+zhjzLeA3QDD2oLV2petaiUjFiZD8y1kkkrydKrV0uLwo\nQ6QUxGL3ja0H6OqNj8T
"text/plain": [
"<matplotlib.figure.Figure at 0x7f4f748b53c8>"
]
},
"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": [
"PairGrid is flexible, but to take a quick look at a dataset, it can 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)."
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA7AAAAN9CAYAAACqy5WoAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3Xl4Y1eZ4P+vLduSF8lV3m1Zsms9di2pVMq1JLVko6E7\nQIDQBU1DEiYE6PnRdDdFb5n+MTPd80w/3Q90GJpm+jdDgA4QMkCzd1gypMlWkJBAICRVOZVKUmVb\n5aV2r5Jdkn5/yJJ1r/Zdst/P89STHN+royP5vffqWu85b1UwGEQIIYQQQgghhCh31aUegBBCCCGE\nEEIIkQ65gRVCCCGEEEIIURHkBlYIIYQQQgghREWQG1ghhBBCCCGEEBVBbmCFEEIIIYQQQlQEuYEV\nQgghhBBCCFERaor9hEqpGuB+oB+4Arxfa30iavufAHcDk0s/+qDW+uVij1MIIYQQQgghRHkp+g0s\ncAtg0VrvV0q9Dvhb4Hejtu8CbtdaP1eCsQkhhBBCCCGEKFOlSCE+AdQopaqAZmDBtH0XcI9S6gml\n1F8WfXRCCCGEEEIIIcpSKW5gZ4B1wEvA/wL+0bT9QeAPgBuBA0qpW4o7PCGEEEIIIYQQ5agUKcQf\nAX6otf4rpZQT+IlSapvWOvxN7Ke01lMASqmHgJ3A95N1GAwGg1VVVQUdtFh1Ch5QErcizyRmRSWS\nuBWVRmJWVKIVFVCluIG9ACwu/f+lpTFYAJRSDuAFpdQAMA/cBHwuVYdVVVWcPTud06Da2+059ZHr\n42UM5TeGQstH3Jrl47VLn4Xvt1B9Flo+YzZf70E+38uVPKZ89pXvMRWanGtX93lxtZ9rEylUbBTz\nOVbCayjmc6wkpUgh/h/ALqXU48CPgf8EvFUpdffSN6/3AI8CjwEvaK1/WIIxCiGEEEII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/Ck1np7nG2OqPmw/xFo0Vr/9yTdleZF\niJWsqgjPIXEr8kliVlQiiVtRaSRmRSUqRtwWTSm/gT0EPGL+oVLKAbyglBoA5oGbgM+l6izXv1y0\nt9tz6iPXx8sYym8MxZDvv7jl47Xn1OdSCY5w+YPawW1QFbvgS8nHWeJ+C9VnMeRr3Pl6D/L5Xq7k\nMREMUP3qS1w++VrSY7OoY6Ly4jasks4LZXVeTHKNqJTXX6kxa1ao2Cjmc1T8a1g6HvzjHmq6nDmd\nl1MpVtwWS1Y3sEqpNuAPgVuBjUAAOAl8B/hnrfW5dLoBXo3q811Ao9b6PqXUPcCjgBd4RGv9w2zG\nKYQornAJjrD+I0ckDUyIMiDHpigHEodCLJPjIXsZ38AqpT4E3AZ8E7gTOA0sAuuAG4FvKaW+rrX+\nx2T9aK0/YWo/GPX/DwAPZDo2IURphUtwRLflZCxE6cmxKcqBxKEQy+R4yF4238B6tNY3x/n5saV/\nn1FKvT23YQkhKpEsCS9EeZJjU5QDiUMhlsnxkL2Mb2C11t9OY59vZDccIUQliyl/MLCVhWPPp5wT\nK4QorNrBbQzc8+dcPvmaHJuieMxzXge2SokcIZbUDmzFffdd+EZGsbl6qRvYWuohVYysF3FSSv0J\n8J+B5qUfVQFBrbUlHwMTQlQgU/mDhWPPy/wOIcpBVTWt+/YS2LAFkGNTFEeiOX4Sa0LAwksvMnzf\n5yPtfscaOTbSlMufW/8EuFprbVn6Vy03r0KIaPHmdwghSk+OTVEMEmdCJCbHR/ZyKaNzDJjI10CE\nECtPzPyOPjcLx55nONmS8WmW4kkqH30IUanipG0uHH+BV195mZomOzVOJ7b+PsNDZO6VyEqKc62t\nz03bwQP4vV4s9Tasprgr9LiSXmuEKDHbun5c73on3vEJbN1dWPr6Sz2kipHLDew/Ar9RSj0FXAn/\nUGt9V86jEkKsCOY5sfg
"text/plain": [
"<matplotlib.figure.Figure at 0x7f4f749a94e0>"
]
},
"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",
"execution_count": 10,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA7AAAAN9CAYAAACqy5WoAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3XmUI9d92PtvYUejge7GNr3N0jPk3OEyJjkcUhqSIrWZ\nlOWxjuNVduI4cWzKeXbyHDs5sZLn5Dg5yfE7TuzYL07yEiqKXqLIsS2bckRFUkRLpChKpEaUaC4z\nl+RwODM909P7gu7Gjnp/YGmgGg2gATSWnt/nHB5OoVBVF9W3Luqifvf+DNM0EUIIIYQQQgghep2t\n2wUQQgghhBBCCCEaIR1YIYQQQgghhBB9QTqwQgghhBBCCCH6gnRghRBCCCGEEEL0BenACiGEEEII\nIYToC9KBFUIIIYQQQgjRFxydPqBSygF8CjgCZIBf0Fq/Ubb+V4CfB+YKL31Ma/1mp8sphBBCCCGE\nEKK3dLwDC3wYsGutH1RKfRD4l8CPla2/F/gZrfV3u1A2IYQQQgghhBA9qhshxG8ADqWUAQwBKcv6\ne4GPK6W+rpT69Y6XTgghhBBCCCFET+pGB3YdmAIuAP8v8PuW9Z8BfhF4H/CQUurDnS2eEEIIIYQQ\nQohe1I0Q4r8HfFFr/Y+VUhPAV5VSd2qti09if09rvQaglHoKuAf4Qq0dmqZpGoaxp4UWN509r1BS\nb0WbSZ0V/Ujqreg3UmdFP9pXFaobHdglIF3490qhDHYApVQAeFUpdQKIA+8HPlFvh4ZhMD8f25vS\nFkQi/r4/xn74DJ08xl5rtd624zy0ug8pQ2+VYa+1o63dL+daytC+Muy1dt0jtPO7p137kjJ1fl/9\nVGdr2Q/3a/vhM3TyGPtJN0KI/w1wr1LqWeArwD8Cflgp9fOF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XIBsC5PYEUfqJW6o9Y6AwM1FSSdzuJ0\n2vdsxm1JLSL2o2MHh2vW62K45qDXyek7D5BIZAgNe/G6bAR8ToJ+D8cODrOwsN6lTyD2G2tKEMOA\nLz6/FTL8oQcOW+qsC9vpSRZX44SGvByKSgdW3FyGfA4euHuclViSYb+bYZ90yxrVlTOllPpZ4G8A\nJuAF7gJGtdZrhfW/Avw8MFfY5GNa6ze7UNQ9s5ZJ4LE5cNm2/wl8xRDirHRgRT+olbpj53WLa4nS\nWDyAgM9JZHgvfn2U1CJi/zGM2vW6GK65Hk9z7tVZ7rvzQGl8YWTYW9qHEO1TmRLkwpWVirWLawlO\nHBquqLOHoj4Z9ypuWnPLCb796mxp+b47D0iUWIO60oHVWn8K+BSAUurfAk8UO68F9wI/o7X+bjfK\n1wlr6UTVp6+wNYmThBCL/UxCe4XYO3J9iW6TOihEbXKNNK+rz6qVUqeB27XWv2xZdS/wcaXUGPCU\n1vq3Ol+6vZPOZYnn0ow7hqqu99qdGEgIsdjfrOFmEtorRPtI6LzoNqmDQtQm90HN63aw9ceB36zy\n+meAPwDWgCeVUh/WWn+hoyXbQ1sTOFUf72E3bAzYXRJCLPa5ynAzIUQ7Sei86Dapg0LUJvdBzTJM\n0+zKgZVSQ8BzWuuTVdYFysbD/m0gqLX+FzV2150P0aQ3Vmb51688zQ8cvIMfPnJX1ff85neeYiUV\n53fP/FiHSycKOjE4rK/qreh5UmdFP5J6K/qN1FnRj/bVpAfdfAL7MPC09UWlVAB4VSl1AogD7wc+\nUW9ne/3LRSTib9sxrqzmJ65xpGwV+yw/hhsHm5kUM3OrOIz2pOtt52e4GY7RCa18jnach1b3UW/7\nYiqPYhqF6LAbaxu612XoxD56pQyd0AufU8oAodAg599aqHlt7XUZ2nUeOqEd3xnt/O5p1766XaZq\nbXwkEui589TOffVTna1
"text/plain": [
"<matplotlib.figure.Figure at 0x7f4f6e91ccf8>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"g = sns.pairplot(iris_df, hue=\"species\", palette=\"Set2\", diag_kind=\"kde\", size=2.5)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we are going to show other representions.\n",
"\n",
"[**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": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7f4f6df755f8>"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYEAAAERCAYAAACdPxtnAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAGV1JREFUeJzt3X+UXGWd5/F3upuwSZtAZ2hHGMVfrF9gjwcwZBhZNw6M\nriNjdFzXoAP+hBV2UWRwMxJ2UHB3OWpcWVh/jQZZXCNrZlhByQwioPJDZaKDjgh8CSOjs8qahrQk\ndBLyo3v/uNWkaDuVm1C3KtX3/TqnT/reW/XUtzt96lPPfe59nlkTExNIkuqpr9sFSJK6xxCQpBoz\nBCSpxgwBSaoxQ0CSaswQkKQaG6iy8YgYAK4GngfsAP5dZj7QdHwJcBGwHbgqM1dWWY8k6amq7gmc\nAvRn5r8E/jNw6eSBRkB8HHgF8PvAuyJiuOJ6JElNqg6BB4CBiJgFHARsazp2FLAuMzdm5nbgDmBx\nxfVIkppUejoIeBx4PnA/8FvAa5qOzQcea9reRBEUkqQOqbon8KfAjZkZwDHAFyJiduPYRoogmDQP\n+HXF9UiSmlTdE9hAMegLxRv8ANDf2L4POCIiDgY2U5wKWtGqsR07dk4MDPS3eogk6TfN2u2BKieQ\ni4hB4PPAocABwOWNYgYzc2VE/BHwwca+KzPzM63aGxnZ5Gx3krSXhofndScE2s0QkKS91yoEvFlM\nkmqs6jEBSWqL1atXsXbtXW1vd2xsDIDBwcG2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cUhmPgJspAiCSfOA\nlityDA3NZWDAKYtmuv7+3pnIq5f19/cxPDyv22V03eTfW11/F2V6Av8aiMzcsg/t3wGcC1wWEYcB\ncymCAeA+4IiIOBjYTHE
"text/plain": [
"<matplotlib.figure.Figure at 0x7f4f6e645908>"
]
},
"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": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXgAAAERCAYAAABxZrw0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XmcXFWZ//HPrbWr13SSTgjZA8kJgRC2kLCLM6AgouIM\nMgMigrgxOjoDjOAw6m9Gxm3GZXR03DdUEEFkEVH2RSAgBALhQEIIIWt3utPppbq2e39/VKXTld6q\nk75V3be/b1++6Lp17r1PQ/LUqXPPeY7jeR4iIhI8oUoHICIi/lCCFxEJKCV4EZGAUoIXEQkoJXgR\nkYBSghcRCaiInxc3xkSAnwDzgCxwubX2ZT/vKSIieX734M8Gwtbak4B/B673+X4iIlLgd4J/GYgY\nYxygAUj7fD8RESnwdYgG6ATmAy8BU4BzfL6fiIgU+N2D/yRwt7XWAMuAnxpjYj7fU0RE8L8H3wpk\nCj/vKtwvPFjjbDbnRSKDvi0iIgNzBjzoZ7ExY0wN8ENgBhAFvmatvXGw9s3NHap8JiIyQk1NdeVP\n8COlBC8iMnKDJXgtdBIRCSgleBGRgFKCFxEJKCV4EZGAUoIXEQkoJXgRkYBSghcRCSgleBGRgFKC\nFxEJKCV4EZGAUoIXEQkoJXgRkYBSghcRCSgleBGRgFKCFxEJKCV4EZGAUoIXEQkoJXgRkYBSghcR\nCSgleBGRgIr4eXFjzPuASwAPSADLgIOstbv9vK+IiIDjeV5ZbmSM+Sbwj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KORAWfdjGelJPhvGGN+DtwHZPccVNKXiWB71w5ueOlmNna8wcJJC7jo\nsL9lUryh0mHJPhzXJZF
"text/plain": [
"<matplotlib.figure.Figure at 0x7f4f6f19cf60>"
]
},
"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": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7f4f6ed5ee10>"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXgAAAERCAYAAABxZrw0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl8XGd97/HPLBrtu+R9l+0ncRwncQx2dqfUlFASmrSk\nhEDIUhrT3lJ6e6HQFlou0AttXyFtaeo00DahUBazZCMJTuwsJDEmTpzN9pN4t+RV1r7Mes79Y0aK\nbGsZ2Toz0tH3/Xr55ZnRmXN+wuQ7zzznWQKu6yIiIv4TzHcBIiLiDQW8iIhPKeBFRHxKAS8i4lMK\neBERn1LAi4j4VNjLkxtjwsD9wDwgCXzCWv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mUTSfTfwFfAvZ7W4rI+PPSS78CIDKzFKc7wdFDR2hsPMCsWXPyXNnk\n1deC92oQ42Tpg+/TZK19wPNKRMaZnp5utm7dQrA0TLi6kMjsMuKHenj22af5yEduyXd5k1ZBQXpB\nsJRHTfi+82Yz63W8yybg/9kY89/ARqB/x1qFvvjdpk1PEY/HKVlcQyAQIDK9lGBRiOd++TQf/OAN\nlJaW5bvESamkJL3/atyjgI+5LuFwmHB4crTg/yjz9xUDXnOBrALeGLMVaM883WutvSP78kTyo6en\nh8cff4RAQZDC+RUABIIBihZW0vNGC48//gi/+7sfznOVk1NlZRUA3a4342h6HIeq2lpPzp1r2QT8\ndGvtuWdycmNMIeiGrEw8Dz30Y7q7uyg5r5renemJTqXn11K0oILo7g6e+MVjXHHF1UyZMjXPlU4+\nNTW1hMNhWj1YSiDmOnS
"text/plain": [
"<matplotlib.figure.Figure at 0x7f4f6fee19b0>"
]
},
"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": [
"Another useful representation is the kde (kernel density estimate) plot. [Kernel density estimation (KDE)](https://en.wikipedia.org/wiki/Kernel_density_estimation) 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:"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<seaborn.axisgrid.FacetGrid at 0x7f4f6f1c2400>"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAdUAAAGpCAYAAADbWaxNAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3XeYXPV99v/3mbq9N3UJhA7qCIkiJAMCmQ42btgJNuBC\niZ0EO/GTkMTpJM7PsZ/4MY4bNsY2BowNNhhMBwsEkhBVAnHUu1ba3qef3x8zs1pAaGd3z8yZ2b1f\n18WFdmfmzOfsSnvvtxu2bSMiIiJj53G7ABERkfFCoSoiIuIQhaqIiIhDFKoiIiIOUaiKiIg4RKEq\nIiLiEN9wTzBN0wP8CDCBBHCjZVlvDXn8cuBrQBS4w7Ks27NUq4iISF7LpKV6OWBblrWSZHj+R/oB\n0zR9wLeA1cC5wPWmadZnoU4REZG8N2yoWpb1O+D61IczgY4hD88FtlmW1W1ZVhR4Hjjb6SJFREQK\nwbDdvwCWZSVM0/wp8GHgY0MeqgC6hnzcA1Q6Vp2IiEgByShUASzLutY0zQZgg2macy3LGgC6SQZr\nWjnQebzr2LZtG4YxqmJFRGTcK+iAyGSi0tXAVMuyvg6EgDjJCUsAW4DZpmlWAf0ku36/cbzrGYZB\nS0vPmIp2W319ue4hD+ge8oPuIT+Mh3uA5H0UskwmKt0PLDFN84/AH4CbgY+Ypvl5y7JiwFeAx4G1\nwO2WZR3KWrUiIiJ5bNiWqmVZ/cBVx3n8YeBhJ4sSEREpRNr8QURExCEKVREREYcoVEVERByiUBUR\nEXGIQlVERMQhClURERGHKFRFREQcolAVERFxiEJVRETEIQpVERERhyhURUREHKJQFRERcYhCVURE\nxCEKVREREYcoVEVERByiUBUREXGIQlVERMQhClURERGHKFRFREQcolAVERFxiEJVRETEIQpVERER\nhyhURUREHKJQFRERcYhCVURExCEKVREREYcoVEVERByiUBUREXGIQlVERMQhClURERGHKFRFREQc\nolAVERFxiEJVRETEIQpVERERhyhURUREHKJQFRERcYhCVURExCEKVREREYcoVEVERByiUBUREXGI\nQlVERMQhClURERGHKFRFREQcolAVERFxiEJVRETEIQpVERERhyhURUREHKJQFRERcYhCVURExCEK\nVREREYcoVEVERByiUBUREXGIQlVERMQhClURERGHKFTzyKPr9/I/973OkY5+t0sREZF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Pfv+38L/DpT\nVUSkoAwXqr8i2RJNPzc65LG5wDbLsroty4oCzwNnO1/i+JTJOtWgzlQVESkox+3+tSyrH8A0zXLg\nPuDvhzxcAXQN+bgHqHS6wPEqHMtsnSpoSY2ISKE4bqgCmKY5DbgfuM2yrHuHPNRNMljTyoHOTN60\nvr58JDXmpbHeg42BYcDkSZUYhnHM59TWlABQVOzPytdM34f8oHvID7oHccJwE5UagceAL1qW9cy7\nHt4CzDZNswroJ9n1+41M3rSlpWcUpeaP+vryMd9Db1+EgM9La2vv+z4nPJDsbW9t73P8a+bEPbhN\n95AfdA/5YTzcAxT+LwbDtVRvAaqAr5mm+Y+ADfwIKLUs63bTNL8CPA4YwO2WZR3KarXjSDgaP+4k\nJRgy+1djqiIiBWG4MdWbgZuP8/jDwMNOFzURRGLx4y6ngSHrVDX7V0SkIGjzB5eEI/HjTlIC7f0r\nIlJoFKouCUcTmbdUY2qpiogUAoWqCxIJm1g8MfyYqk9jqiIihUSh6oJMzlIF8GtMVUSkoChUXRCJ\nDr+ZPkBQY6oiIgVFoeqCTFuq6dCNqvtXRKQgKFRdkG55Dtv9m2qphtX9KyJSEBSqLggPdv8e/8vv\n83rwegzN/hURKRAKVRd
"text/plain": [
"<matplotlib.figure.Figure at 0x7f4f6f1c2240>"
]
},
"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()"
]
},
{
"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",
"version": "3.5.1"
}
},
"nbformat": 4,
"nbformat_minor": 0
}