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

858 lines
1.1 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": [
2019-02-28 10:32:00 +00:00
"Department of Telematic Engineering Systems, Universidad Politécnica de Madrid, © Carlos A. Iglesias"
2016-03-15 12:55:14 +00:00
]
},
{
"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",
2019-03-06 16:44:30 +00:00
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\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": 1,
"metadata": {},
"output_type": "execute_result"
}
],
2016-03-15 12:55:14 +00:00
"source": [
"from pandas import DataFrame\n",
2019-02-28 11:26:33 +00:00
"from sklearn import datasets\n",
"\n",
2016-03-15 12:55:14 +00:00
"\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",
2019-03-06 16:44:30 +00:00
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\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": 2,
"metadata": {},
"output_type": "execute_result"
}
],
2016-03-15 12:55:14 +00:00
"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",
2019-03-06 16:44:30 +00:00
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<seaborn.axisgrid.PairGrid at 0x7f0d3508add8>"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA3sAAAN8CAYAAADhyLNbAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzsvX+cFNWd7/2pqv4xMzDAKAMxJhGNsUCEXUwYUCZxH3HZR42ij/uEMdnIJAK7sip34yZhwL1grjrG3OxGk2AuEkWzuxnvXq/BX/cuEaMREgGVuxqEihpEkyi/HHBgZrq6q+r+0VNNV9epmerp6u7q6s/79ZoXzJmqU+fU+Z7vqVP1/SFZlgVCCCGEEEIIIdFCrnYDCCGEEEIIIYQEDzd7hBBCCCGEEBJBuNkjhBBCCCGEkAjCzR4hhBBCCCGERBBu9gghhBBCCCEkgnCzRwghhBBCCCERhJs9QgghhBBCCIkg3OwRQgghhBBCSAThZo8QQgghhBBCIgg3e4QQQgghhBASQWp1sxcDMGXoX0LCDuWV1AqUVVJLUF5JLUF5JVWhVgXuYwD2HTlyHKZpVbstoaGlpQm9vf3VbkYo8bo3ra3NUgUu70teozh+7FNwhElWy0UtyQvbOjzVktdaGhe/RK1PYetPhWQVqONnAb+w7yP3fTTyWqtf9oiAWEypdhNCSy3cm1poY7GwT6QYaunesq3hJIp9jVqfotafoKnn+8O+lwdu9gghhBBCCCEkglTdjFNV1b8C0DX06//SNO3vq9keQgghhBBCCIkCVf2yp6pqE4B7AVwE4E8AfFZV1Uuq2SZCCCGEEEIIiQLVNuNUhtowBkB86Gegqi0ihBBCCCGEkAhQ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"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
2016-03-15 12:55:14 +00:00
"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",
2019-03-06 16:44:30 +00:00
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA3sAAAN8CAYAAADhyLNbAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzs3X2YHNV9J/pvd89oNHoZJLWH1Y6xRDw4R0IXIbCzeXRle4TjWBYP4I0SJ0sSEGC4vsE4doi1Jglev+EErIQkYMuxBRgsb9g1jpwY2VhJLJgYobVjJCFW0hxfzRJeMp4gj6QMEqPWzHTfP1o1qq4+p/pU13vV9/M8JFZNv5yqOudUna7z+51CrVYDERERERERZUsx7gIQERERERFR8DjYIyIiIiIiyiAO9oiIiIiIiDKIgz0iIiIiIqIM4mCPiIiIiIgogzjYIyIiIiIiyiAO9oiIiIiIiDKIgz0iIiIiIqIM4mCPiIiIiIgogzjYIyIiIiIiyqC0DvY6AFx49v8TJR3rK6UF6yqlCesrpQnrK8UirR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nEiXd6hWLtcuhAOx3yZyXPtRPfxtWfB2vAZQGaVl6wXIH6vF6nubkSSkfAPAAAAghVgD4WwCfCqhMFAP73HvV4r0A581nndd4Ca6HRHkRRV1nvBK5SVp/y/pKwLl6abI2b5ZEVf+DGuzNlVK+3ednfAnAH0opfxZEgSh6zrVtVAM9zpvPvg0D/Q31ANCfd66HRHkRVV1Xtb+uzhL7XUpkf+vlekHZlMR6GZWo6n9QCVqkEGJlu28WQrwbQLeU8rG
"text/plain": [
"<Figure size 900x900 with 25 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
2016-03-15 12:55:14 +00:00
"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",
2019-03-06 16:44:30 +00:00
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<seaborn.axisgrid.PairGrid at 0x7f0d31c2f240>"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA60AAAN8CAYAAACzx0xVAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzs3X+cXFV9P/7XnZndySa7yybLxhj5JQs9G8BI8sVQEuOCWhNEo4aWX5YmtVg/H6Xtt1XUVvy2av2BoP3UKlhESgpNAEusEYTQSkhjEogx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scIlUZHS/49bhEUbdk3mJtKSoDwD+9/ZZgO0Sx52Y8rWXs9Sv/lOcD8htzp/3l1aT108jns7pKDpBS3gXgLgAQQpwP4D8A/J1HfSKiELnJIRp/YQfGf/oQzNFBGK2daH7LlWg+d2kQ3SQKRRAxrzsGO2fOUdyaGlXUxl/mn5LFis2jo0dgtM4JPTarYez6y6tJ6ywp5VtrfIw7APyNlPKwFx0ionCt6l5ZUhcPUOcQjb+wA5lt9wCT+eUz5uhg/mcg0icnoukKKuZ1x+C1C9/n2XNQvEVx/HV67qD6FsXYrIax6y+vNmKSQoiF072zEOKdAFqklN/zqD9EFLIl8xbjup4rMTvdAQP5vzRe13Nl2fKs8Z8+VDgpFUyO59uJ6lBQMV98DAInj8HlZy7x9HkovqI4/urilkt7G0sUY7Map997aHq8utJ6BoDdQojfAMggnzJjSimdTmQ/AuDrbp+0s7PV7V0aQld
"text/plain": [
"<Figure size 945.725x900 with 30 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
2016-03-15 12:55:14 +00:00
"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",
2019-03-06 16:44:30 +00:00
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAV8AAAFgCAYAAAAcmXr5AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzsnXucG2W5+L+T7G667XabdttSKl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stlreFj4L+NGHrqycQIorwyk8brW0uSpgq6Ut67VXhlszEWL9fXQ2RBjXn6C3sYntDLje6/QHziaCxcFTD+CTMxYW8c7qj5JtvsaYlcAxIjIO2Atn87TWGLO51LmVypBWvF5fG22bg1r2qKxQyhCGW3i8ab9FWTZfwDVSZWZDnMd3bBpiYthhD9CdTCfvbIwSSfQTjUQY8PielMDmkTefAFAFnIegoh1IKtung5pPqRyeite2sYCDWvbgUwd8qeJyKdnkKzyeV/km7bqFoh1e3PwKNAwNK7NzhhIRi+b+AUaNmZDXKffYmytV+eYhMOWr1B7bH1nCwJrlsGeb5zlqaqgeSik83jR97hBlmxt+1rmT/7D/7qjFVckiSl794BJFBarVH0ElWSg1xvZHljDw0oNgJ8IWRfGJV4Hx4RQeT4WfpWzBdlcH8X7/ayHz3IhHPpXXuOKgyrdOGVizPP372GSBnCxsm7G53zeVUHHruzbcanJu4WfzO7pozEmZjiZsIjljjQmbY2K7pV8fPPUA13t4jSsOQbWOPxgn4mEyGWnFher5KpXlu8u/y9v9yXz3PduY3NPPN97
"text/plain": [
"<Figure size 360x360 with 4 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
2016-03-15 12:55:14 +00:00
"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",
2019-03-06 16:44:30 +00:00
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/cif/anaconda3/lib/python3.7/site-packages/scipy/stats/stats.py:1713: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result.\n",
" return np.add.reduce(sorted[indexer] * weights, axis=axis) / sumval\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA3EAAAN8CAYAAAD26iOSAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzs3Xl8VPW5P/DPzGTfSAiBEFYJcBKjLOKGaEGrInWrdPFqL2hpvb3Xavu7t9dWq73dbIvS2lbvpbe1pSqterV1qQviAkbFiIggGMhXCTshEAIhJGSf+f0xnMnM5Kwzc+acM/N5v16+JGdmznxn5pkz853zPM/XEwgEQERERERERO7gtXsAREREREREZBwncURERERERC7CSRwREREREZGLcBJHRERERETkIpzEERERERERuQgncURERERERC7CSRwREREREZGLcBJHRERERETkIpzEERERERERuQgncURERERERC7ixElcBoCJp/5P5HSMV3ILxiq5CeOV3IKxSrZwYsCNBbCrtbUDfn8g4TsvKcnDsWMnE77fZHDz2IHkjr+srNCTlDuyOF4B57/uTh8f4PwxJileLYlVpz+3yZJOz4Ob49WodHo9laTK40+HWNWTKq9lojj5+TAbr048E2epjAyf3UOImZvHDrh//HZx+vPm9PEB7hijW/G5DeLzkFrS/fVM98efSvhaRkql5yPtJnFERERERERuZmk6pSRJ/wzgrlN/rhJC/KeV90dERERERJTqLDsTJ0lSHoAHAcwFMB3ARZIkXWrV/REREREREaUDK9Mpfaf2nw8g89R/XRbeHxERERERUcqzbBInhDgB4AcAGgDsB7AbwLtW3R8REREREVE68AQC1rRDlSRpGoBHAcwHcBzAXwC8L4RYpnPTiQB2WTIoSifJWmJgIhivtnlz4z48tmo7jhzrwoiSXCxeUI15s8bZPaxYJCNeJ4Kx6lgui2XGa4pyWRwawVglAK6JbVPxamVjk/kA3hBCHAYASZIeAXArAL1JHADAqvU2ysoK0dJyIuH7TQY3jx1I7vjLygqTcj8yK9eHcfrrbtf46uqb8eiqB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x6zyckqSnNNbXcL3TNxAD4B0Gb1QIjIPfTa9UanX5pNEYv39kROIsftn17cpngWBACWXHU645sSRusYOnlsse6x9bFV21Vr3JTilMdscrKePuWaZLXtbmFkEvcggFpJktYiuMQAAEAI8ROtG0mS9HUAt4VtOg3ASiHEbSo3ISKXMFL/EJ5+GYt4b0/kJLNryvHwC9s0LydKJLVjqJFj65FjyqtHaaUF85hNTpWqNZtGJnF3IlgPV2xmx0KIPwL4IwBIklQD4DkAPzI5PiJyICP1D1wziFJRPHHNuiGyghXH2hEluWhRmMgxVsksJ3wXSNVjr5FJXL4Q4sI47+d3AL4vhDgS536IyAEWzq2MWBMIiKx/4JpBlIq04vqaeYW6t9d73xCZZdWxdvGCajz01GbGKsXFKd8FUvXYa6SxiZAkaVqsdyBJ0qUAcoUQT8e6DyJyltk15bhpQRVKi7LhQfDXrJsWVEXURXDNIEo18cZ1+PsGGPq+ITLLqmPtvFnjGKsUN6d8F9D7zuJWRs7EjQfwgSRJuwD0APAACAghjE7svgHgAbMDKy0tMHsTw8rK9H8xdSo3jx1w//jVWBmvgDOft2vmFeKaeVNCf9/zu3c0a34A4Gh7j22PxYnPoR2siNV0eW6PatRV3PiDl9Fxsg8jSnJxTtVIbGg4jCPHuhT/vvmqGsybNS7Jo3cnq4+tWtwQ11ox+b3f12HxguqYY62oMAdenxceAF6fF0WFOSgrK8Tv/rYZr6zfC78/AK/XgyvOG49/++KMOB5FarA
"text/plain": [
"<Figure size 900x900 with 30 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
2016-03-15 12:55:14 +00:00
"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",
2019-03-06 16:44:30 +00:00
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/cif/anaconda3/lib/python3.7/site-packages/statsmodels/nonparametric/kde.py:488: RuntimeWarning: invalid value encountered in true_divide\n",
" binned = fast_linbin(X, a, b, gridsize) / (delta * nobs)\n",
"/home/cif/anaconda3/lib/python3.7/site-packages/statsmodels/nonparametric/kdetools.py:34: RuntimeWarning: invalid value encountered in double_scalars\n",
" FAC1 = 2*(np.pi*bw/RANGE)**2\n",
"/home/cif/anaconda3/lib/python3.7/site-packages/numpy/core/fromnumeric.py:83: RuntimeWarning: invalid value encountered in reduce\n",
" return ufunc.reduce(obj, axis, dtype, out, **passkwargs)\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA60AAAN8CAYAAACzx0xVAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzsnXmcHHWZ/99V1ffcM5kkhEMChELAQJRjZQgmCMilrBsQlzu6JpjF3ZUQXNZFIxFRIOyuKCI/VxBYViCsguCBmkRCgEAgMIikEkNAzDmZe6anr6r6/dHTPX1Uz/RM90z3TD/v14sX6eo6vl3zfL9V36rn83wU27YRBEEQBEEQBEEQhHJELXUDBEEQBEEQBEEQBCEXMmkVBEEQBEEQBEEQyhaZtAqCIAiCIAiCIAhli0xaBUEQBEEQBEEQhLJFJq2CIAiCIAiCIAhC2SKTVkEQBEEQBEEQBKFskUmrIAiCIAiCIAiCULbIpFUQBEEQBEEQBEEoW2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MJ4Iv1QmAg0TYnrpgdjyqVoYskhCOOEWN5kU7m/vAiYlkVnb9jR7iZBtd9NV1/lvsoXpjZOJdmXtyzl/i2P8k+/upmV61fTTafcMAvCOKJFPdw4/4vSD4VxI6GvW7l+dTKmQlZYLDkEYZxwW16WtyzNGtfdVuUWdi1KISZd15uB8wEdMIGtwC8Mw+gpxv7Llc7eMJZtUzvMpLXK76ZbJq3CFCXLzkBVuX/Lo2ze3QoMaTBWLlhe4pYKwtTFNG0ObZiVXz803SVurTAZMd2RZEEYiMfUbc/dzaozV4idjSCMA1E1zJr
"text/plain": [
"<Figure size 945.725x900 with 30 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
2016-03-15 12:55:14 +00:00
"source": [
2019-02-28 10:32:00 +00:00
"sns.pairplot(iris_df, hue=\"species\", height=2.5);"
2016-03-15 12:55:14 +00:00
]
},
{
"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",
2019-03-06 16:44:30 +00:00
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA60AAAN8CAYAAACzx0xVAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzsvXt0XNWV5/8559ZLKj1sSzI2xsQg4wuxwzNgOoZYDrRt0jGME/NI8ptfBqYfM0D/ptPd02Fm/R695plMz3T39CQ93T3TSfeaWd2TQEKMewImEEyDiQkvEzBwARnH+IEfsqSSS6rXvef3R6lK9bgllaSSqqTan7W8rLq6j1NX+5x79j17768yxiAIgiAIgiAIgiAIjYiudwMEQRAEQRAEQRAEoRLitAqCIAiCIAiCIAgNizitgiAIgiAIgiAIQ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zQLXeMQyCdonKbLUaoUYSctKq7A48S3JvqWXfS8e5TuPvskjT75L2kMmzIIwh3gZlzs+s1b6oTBn5PLrHnny3bxNZTIeO7aIJIcgzAXK+PSvLb0o05z5rFCjQky2bfcAnwVswAXeAfY4jhOrxfkblVgmgYfx1WjN0WoFGZHwYGGRUipnoLVi34tH6T82DEzkYOzauq6+DRWERYzrenR3t1XVD5u1gIcwO3TAyheEgaxNPfr0+9y1fZ3I2QjCHGCU5sDBD+m7YTWRUIBEKsOBgyfYfP1qsq5W8zErp9W27TDwb4AvAy8BHwBpYCfwddu2/wb4fcdxFmUlorzczSROa4sV4lxiaL6aJAjzTqGcQSAczE+Uc0RbgiitiJ1PEgwHyyY11Ug
"text/plain": [
"<Figure size 945.725x900 with 30 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
2016-03-15 12:55:14 +00:00
"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",
2019-03-06 16:44:30 +00:00
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7f0d2ac0e6d8>"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYoAAAEPCAYAAABcA4N7AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmc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raoxHkjQGtbULG91WZwPLgbsotv+4KCKujYiDGi2Nk4GrKPaO6gA+X1c8kqSxqbNFQaNbafi+UIc33b8cuLzOGCRJz8+IiSIi5lPMfNqFpq07PI9CkqaGKi2Kr1GspbidYtaTJGkKqZIonm7sGCtJmoKqDGbfExEH1R6JJKktle319EuKrqYZwC0RcR9N6xwco5CkqaGs62nxuEUhbcGll36T1atXtTqMUXnwwSLes846o8WRVDd37jyOOebNrQ5Dbapsr6ebASLi65n51uZ7EXEZcHPNsUmsXr2KB+69h12n1zqTe6vagQEANj58b4sjqebhDZtaHYLaXFnX03nAXwCviog5Tbe6gb3rDkwasuv0bThx/xe0OoxJ66I7/9TqENTmyj6mfR34G+ClPHdR3CbgX+oMSpLUPsq6nn4O/DwifpSZvxvHmCRNIv29z0yYbcYHNhYbOnZu19XiSKrr730GZtf7HlU6fpdHRPNCu0HgSeBXwPszc00tkUma8ObOndfqEEZlaCLCHrMnUNyz6/85V0kUP6SYIvtloB84qfH6TooV20fUFp2kCW2izaQamqm2ZMnSEUpOLVUSxasys3nB3Xsi4l8z88SIOLGuwCRJ7aHKyuyZEfHs0Uk
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
2016-03-15 12:55:14 +00:00
"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",
2019-03-06 16:44:30 +00:00
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAEPCAYAAABLIROyAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzt3XmcnFWd7/HP8zy19JZ0d/a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sethCHAWUoAIjKm+U5AIp6kt3z3OdW4HUAklduuHxDg95/sM4Bod/nMAFosSgAiMqalImly5mxzTxXmkZSbN/dPKuITeLk1gGi3SyQvK4x/SgAiMqYFA3yr7/qDTww30PkDTRBXCZQARGRM89Ie6UifqaH7TeSW8nyS0RSBA17aJZJySEU4NQ4ggO5opuM4kq6sWoA+AxWRMS2SdoklIngph0jSJZ6I5k4DEUtlmoiczKAw34V4IoKT7hkWDLjQHRv/I3/7Uw1ARMa8SNolks5/n/Xd/MnffNcnmoriBj7pvl8DZSeAc9OV0xykBCAiY1ba9UlF0oBDNOnmreDl+k7+tA/Zzzxd3yFnJeEAvAoq/GGIBGCMiQMfBN4MGCANbAXuBH5srQ13wUoRkUGk3eykbw5AQNrzqe6M5nToOjhEu72cNQDSER8/5RNJuQROQCri4wQQTUYqrjN40D4AY8wVwBPA2cC/AtcAfwl8A7gAeNIYc2UxghQR6S/t+XmLuPSfFK5nf/55Qe96AjWdMaq7YgM2IY13p6sBrAVWW2t
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
2016-03-15 12:55:14 +00:00
"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",
2019-03-06 16:44:30 +00:00
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7f0d300c4f60>"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAEPCAYAAABLIROyAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzt3Xd0VOed8PHvnT7qQkKoAhLlAWOajTFxd2zjTuwkG/t47ZRNHG/JJtk39X2TPWmbTTa76ySbXpy+iWvixB0MMcaG2MYGm9jwUIQEqKEujaQZTbnvH3ckY0DSCOnOjGZ+n3PmaO7Mfe79geD+7n2qYZomQgghso8j1QEIIYRIDUkAQgiRpSQBCCFElpIEIIQQWUoSgBBCZClJAEIIkaUkAQghRJaSBCCEEFlKEoAQQmQpSQBCCJGlJAEIIUSWcqU6gNPwAucBLUA0xbEIIcRM4QQqgJeAUCIF0jEBnAdsS3UQQggxQ10MPJfIjumYAFoAursHiMVkplIhhEiEw2FQXJwL8WtoItIxAUQBYjFTEoAQQkxewlXn0ggshBBZShKAEEJkKUkAQgiRpSQBCCFElpIEIIQQWUoSgBBCZClJAEKIrDAwEODJJx9jcHAg1aGkDUkAQoissG3bVu6//3957rlnUx1K2pAEIITICiN3/kNDgymOJH1IAhBCiCwlCUAIkRVMMwZANCqTDI+QBCCEyAoDAwNv+SkkAQghskR/f3/8Z1+KI0kfkgCEEFmhp6fb+tnbneJI0ockACFEVujs6gCgq6szxZGkD9vWA1BKfQj4yAkf1QK/1lp/ZIwiQghhi0gkQm9PDwDd3d1EIhFcrnRcDiW5bPsb0Fr/FPgpgFJqGfAw8EW7zieEEGPp6GjHNE1cpT4iHUE6OzuYM6c81WGlXLK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EkdVisRif/MQ/MX9+HR/7+KdTHU7WGx62Lj+Gc+L6fzMcY/36a7jzzjsxTZPHNj8xYZmR42byIjFjJgCl1KXAd7Dm8vkf4DAQBmqBa4CdSqmPa623JCNQIVItGAzS29fHq6/tTnUoAt6sm0+gAdhwO9i4cSOmabJp0yYMbwKVH/HjRqPRqYSZ1sZ7ArgRuEhr3XfS568DjyqlCoAvAJIARFbo7z/5v4JIpdHrfgI1cobbQbA3yCOPPAKAKy+RBWPM+Hkyt6Z8zASgtf7keAXjieET0x6REGmqp+fNBe1CoRBerzeF0QiHI35htqlNxow/YDidWZgARiilyoH3A7NO/FxrLZWgIqu0tx8ffd/R0U5VVXUKoxFOp3X5sq1RPn5ch8OeXkbpIJHU9ieslbyMk15CZJXm5mOj75uajo2zp0iGN58AbDpB/LhOZ+YmgETGT3u01u+0PRIh0tzhw/XMyXXTMRShsfEwa9euS3VIWW30wmzX0rHxJ4BMTgCJPAG8rJQ62/ZIhEhj4fAw9YcOUFvopjLPhd73eqpDynp2PwGMtAGMnicDJfIE8DywWynVgtUNFACtdZ1tUQmRZvbt20s4EqGuOA+fy2BrQz19fb0UFBSmOrSsNXJhtr8NILsTwKeA24BDNsciRNp68cUdeF0Oaos8FHgdPHNkgJdeeoErrlif6tCyltvttt7YNVVPvGrJ5bJ15dyUSuRP1qO1vt/2SIRIU4ODA+x86S8sK/XidhjMyXExJ9fNtme38Pa3XzXtM1GKxHg8VjdcM2JPBjAjVgLI5O6+iSSALUqp/wIeAkIjH2qtX7EtKiHSyNatWwgND7OmwuoJbRgG51X4ePTgEbTey5IlZ6U4wuzk8/lwOJ3Ehu0ZqRsbjuJ0uUYTTSZKJAHcFv/5rhM+MwFpAxAZLxgM8uQTj1JX5OH4QITjAxFWzfGzsszPM0cG+eMfH0K
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
2016-03-15 12:55:14 +00:00
"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",
2019-03-06 16:44:30 +00:00
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<seaborn.axisgrid.FacetGrid at 0x7f0d3005aba8>"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAdgAAAGoCAYAAADl+/RYAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzs3Xl8XPV97//XObNqtWVZ3ndjH4N3MKvZAgYCCVkJSUjTJmlIk6Ztcpumt03b5N7+btrHbZvlpk2z0zRNaBYIWSCEzRCzGfCGN3zA+ybZ8q5tljPn/P4YjSyMZM1oZnRGc97Px4MHlmbOzOfIlt767obneYiIiEhpmX4XICIiUo0UsCIiImWggBURESkDBayIiEgZKGBFRETKQAErIiJSBgpYERGRMlDAioiIlIECVkREpAwUsCIiImXgd8CGgVm9/xcREakafgfbNGDP8eOduG7590Ruaqrl5Mnusr/PSKmm+9G9VCbdS2Wq1ntpaWkwfC6npPxuwY6ocDjkdwklVU33o3upTLqXyqR7GR0CFbAiIiIj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BFRIJMAVugdJ57EQPEwgpYEZGgUsAWwMm4uJ6X117E0NtFrHWwIiKBpIAtQG7TiEImOTkZF9f1ylmWiIhUIAVsAdK5w9YLGIMFtNmEiEgAKWALkOqdERwpYC/i/teJiEhwKGALkAvKaAF7EYPOhBURCSIFbAFyXcSF7OQE6iIWEQkiBWwBzk5yyrOLuDeIdaKOiEjwKGALkO4bg1UXsYiInJ8CtgC
"text/plain": [
"<Figure size 477.725x432 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
2016-03-15 12:55:14 +00:00
"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",
2019-02-28 10:32:00 +00:00
"sns.FacetGrid(iris_df, hue=\"species\", height=6) \\\n",
2016-03-15 12:55:14 +00:00
" .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",
2019-02-28 10:32:00 +00:00
"© Carlos A. Iglesias, Universidad Politécnica de Madrid."
2016-03-15 12:55:14 +00:00
]
}
],
"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",
2019-03-06 16:44:30 +00:00
"version": "3.7.1"
2019-02-28 10:32:00 +00:00
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
"autocomplete": true,
"bibliofile": "biblio.bib",
"cite_by": "apalike",
"current_citInitial": 1,
"eqLabelWithNumbers": true,
"eqNumInitial": 1,
"hotkeys": {
"equation": "Ctrl-E",
"itemize": "Ctrl-I"
},
"labels_anchors": false,
"latex_user_defs": false,
"report_style_numbering": false,
"user_envs_cfg": false
2016-03-15 12:55:14 +00:00
}
},
"nbformat": 4,
2019-02-28 10:32:00 +00:00
"nbformat_minor": 1
2016-03-15 12:55:14 +00:00
}