mirror of
https://github.com/donnemartin/data-science-ipython-notebooks.git
synced 2024-03-22 13:30:56 +08:00
1c34b46258
Source: https://github.com/jakevdp/PythonDataScienceHandbook unmodified
257 lines
46 KiB
Python
257 lines
46 KiB
Python
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"<!--BOOK_INFORMATION-->\n",
|
|
"<img align=\"left\" style=\"padding-right:10px;\" src=\"figures/PDSH-cover-small.png\">\n",
|
|
"*This notebook contains an excerpt from the [Python Data Science Handbook](http://shop.oreilly.com/product/0636920034919.do) by Jake VanderPlas; the content is available [on GitHub](https://github.com/jakevdp/PythonDataScienceHandbook).*\n",
|
|
"\n",
|
|
"*The text is released under the [CC-BY-NC-ND license](https://creativecommons.org/licenses/by-nc-nd/3.0/us/legalcode), and code is released under the [MIT license](https://opensource.org/licenses/MIT). If you find this content useful, please consider supporting the work by [buying the book](http://shop.oreilly.com/product/0636920034919.do)!*\n",
|
|
"\n",
|
|
"*No changes were made to the contents of this notebook from the original.*"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"<!--NAVIGATION-->\n",
|
|
"< [Simple Scatter Plots](04.02-Simple-Scatter-Plots.ipynb) | [Contents](Index.ipynb) | [Density and Contour Plots](04.04-Density-and-Contour-Plots.ipynb) >"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Visualizing Errors"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"For any scientific measurement, accurate accounting for errors is nearly as important, if not more important, than accurate reporting of the number itself.\n",
|
|
"For example, imagine that I am using some astrophysical observations to estimate the Hubble Constant, the local measurement of the expansion rate of the Universe.\n",
|
|
"I know that the current literature suggests a value of around 71 (km/s)/Mpc, and I measure a value of 74 (km/s)/Mpc with my method. Are the values consistent? The only correct answer, given this information, is this: there is no way to know.\n",
|
|
"\n",
|
|
"Suppose I augment this information with reported uncertainties: the current literature suggests a value of around 71 $\\pm$ 2.5 (km/s)/Mpc, and my method has measured a value of 74 $\\pm$ 5 (km/s)/Mpc. Now are the values consistent? That is a question that can be quantitatively answered.\n",
|
|
"\n",
|
|
"In visualization of data and results, showing these errors effectively can make a plot convey much more complete information."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Basic Errorbars\n",
|
|
"\n",
|
|
"A basic errorbar can be created with a single Matplotlib function call:"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"metadata": {
|
|
"collapsed": true
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"%matplotlib inline\n",
|
|
"import matplotlib.pyplot as plt\n",
|
|
"plt.style.use('seaborn-whitegrid')\n",
|
|
"import numpy as np"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXIAAAD/CAYAAADsfV27AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAGjhJREFUeJzt3X1sVWcBx/HfraUMaQtIMmMbna9lYU2uWclCa4qViMIM\nUULV6jqIMVG3mJDRSeeYG8SQuiXbjAlEGDoJqGx2LINEnRDsQNqIbaQJEGBRErd7m8WheG+JBmqP\nf8y+33Nfzj1vzznfzz/reu859+nDub/73OftJCzLsgQAMFZF0AUAAJSHIAcAwxHkAGA4ghwADEeQ\nA4DhCHIAMFyl0wPHx8f12GOP6erVq6qoqNDOnTv10Y9+1M2yAQCK4LhFfvLkSSUSCf3yl7/Uli1b\n9Mwzz7hZLgBAkRy3yD/96U9r9erVkqRUKqVFixa5VigAQPEcB7kkVVRU6JFHHtGJEyf0ox/9yK0y\nAQB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agsewIAgADBffzmsAiAiCHAAMR5ADgOEIcgAwHEEOAIYjyAHAcAQ5ABiOIAcA\nw/0Pa4w4rypgtw8AAAAASUVORK5CYII=\n",
|
|
"text/plain": [
|
|
"<matplotlib.figure.Figure at 0x10bf54080>"
|
|
]
|
|
},
|
|
"metadata": {},
|
|
"output_type": "display_data"
|
|
}
|
|
],
|
|
"source": [
|
|
"x = np.linspace(0, 10, 50)\n",
|
|
"dy = 0.8\n",
|
|
"y = np.sin(x) + dy * np.random.randn(50)\n",
|
|
"\n",
|
|
"plt.errorbar(x, y, yerr=dy, fmt='.k');"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Here the ``fmt`` is a format code controlling the appearance of lines and points, and has the same syntax as the shorthand used in ``plt.plot``, outlined in [Simple Line Plots](04.01-Simple-Line-Plots.ipynb) and [Simple Scatter Plots](04.02-Simple-Scatter-Plots.ipynb).\n",
|
|
"\n",
|
|
"In addition to these basic options, the ``errorbar`` function has many options to fine-tune the outputs.\n",
|
|
"Using these additional options you can easily customize the aesthetics of your errorbar plot.\n",
|
|
"I often find it helpful, especially in crowded plots, to make the errorbars lighter than the points themselves:"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXIAAAD/CAYAAADsfV27AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAGjxJREFUeJzt3X9slWf9//FXC2tLoYOOsMYuUguEGSWZAbYsGswgVqGf\nLLqsmurKiCxRt5DgxmznWDexIRWSjsVQIhtTCTVWrSTjj2YLZGQ6wiI2jqVLJAondOM0TUdVTkGE\n0vP9g28PPeXc58d97l/XfT8fSZNyn3Pu++rFdb/P+75+3HdJMplMCgBgrFK/CwAAKA6BHAAMRyAH\nAM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aaWho0IkTJ9Tc3CxJkR7s3L9/vy5duqR9+/apu7tbJSUl\nOnDggMrKyvwumq9KSkr8LoKvHnroIf31r39VU1NTapZXVOtk06ZNev755/XYY4+lZrBEfTC8ra1N\n7e3tun79upYuXar169fn/AwLggDAcNHtvAaAkCCQA4DhCOQAYDgCOQAYjkAOAIYjkAOA4QjkAGA4\nAjkAGO7/AZgUo2sIozQmAAAAAElFTkSuQmCC\n",
|
|
"text/plain": [
|
|
"<matplotlib.figure.Figure at 0x10bec4d30>"
|
|
]
|
|
},
|
|
"metadata": {},
|
|
"output_type": "display_data"
|
|
}
|
|
],
|
|
"source": [
|
|
"plt.errorbar(x, y, yerr=dy, fmt='o', color='black',\n",
|
|
" ecolor='lightgray', elinewidth=3, capsize=0);"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"In addition to these options, you can also specify horizontal errorbars (``xerr``), one-sided errorbars, and many other variants.\n",
|
|
"For more information on the options available, refer to the docstring of ``plt.errorbar``."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Continuous Errors\n",
|
|
"\n",
|
|
"In some situations it is desirable to show errorbars on continuous quantities.\n",
|
|
"Though Matplotlib does not have a built-in convenience routine for this type of application, it's relatively easy to combine primitives like ``plt.plot`` and ``plt.fill_between`` for a useful result.\n",
|
|
"\n",
|
|
"Here we'll perform a simple *Gaussian process regression*, using the Scikit-Learn API (see [Introducing Scikit-Learn](05.02-Introducing-Scikit-Learn.ipynb) for details).\n",
|
|
"This is a method of fitting a very flexible non-parametric function to data with a continuous measure of the uncertainty.\n",
|
|
"We won't delve into the details of Gaussian process regression at this point, but will focus instead on how you might visualize such a continuous error measurement:"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 4,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"from sklearn.gaussian_process import GaussianProcess\n",
|
|
"\n",
|
|
"# define the model and draw some data\n",
|
|
"model = lambda x: x * np.sin(x)\n",
|
|
"xdata = np.array([1, 3, 5, 6, 8])\n",
|
|
"ydata = model(xdata)\n",
|
|
"\n",
|
|
"# Compute the Gaussian process fit\n",
|
|
"gp = GaussianProcess(corr='cubic', theta0=1e-2, thetaL=1e-4, thetaU=1E-1,\n",
|
|
" random_start=100)\n",
|
|
"gp.fit(xdata[:, np.newaxis], ydata)\n",
|
|
"\n",
|
|
"xfit = np.linspace(0, 10, 1000)\n",
|
|
"yfit, MSE = gp.predict(xfit[:, np.newaxis], eval_MSE=True)\n",
|
|
"dyfit = 2 * np.sqrt(MSE) # 2*sigma ~ 95% confidence region"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"We now have ``xfit``, ``yfit``, and ``dyfit``, which sample the continuous fit to our data.\n",
|
|
"We could pass these to the ``plt.errorbar`` function as above, but we don't really want to plot 1,000 points with 1,000 errorbars.\n",
|
|
"Instead, we can use the ``plt.fill_between`` function with a light color to visualize this continuous error:"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 5,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD/CAYAAAAKVJb/AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xt0lPWdP/D33G/JJJPJdRIIEAg3A0iAeoPqKShIL4LU\nn1q0HtlqbXVddS0qYOSibN2erruKla67awuuHI+2K56228oCQS4aCBAFCShGApnJZGYyl2fuz+33\nBz5PEsl1Mslc8nmdkyMJzzzz5evkPd/5XhWiKIoghBCSVZSpLgAhhJDko3AnhJAsROFOCCFZiMKd\nEEKyEIU7IYRkIQp3QgjJQupEHygIAtavX4+WlhYolUps3LgRLMviwQcfx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rJWpra/Hhhx8CAJxOJ6LRKCwWS4pLlRp5eXnydia5ubngOA6CIKS4VKk1\nY8YMHD16FABw4MCBAdcMjVq3zJIlS3Do0CHceeedADCmB1S3b9+OQCCAV199Fdu2bYNCocDrr78O\nrVab6qKllEKhSHURUurGG2/EsWPHsGrVKnl22Vitkx//+Md45pln8KMf/UieOTPWB9zXrl2LDRs2\ngGVZVFVVYenSpf1eT4uYCCEkC43dTm9CCMliFO6EEJKFKNwJISQLUbgTQkgWonAnhJAsROFOCCFZ\niMKdEEKyEIU7IYRkof8PKWVUtmMej+IAAAAASUVORK5CYII=\n",
|
|
"text/plain": [
|
|
"<matplotlib.figure.Figure at 0x10e55bba8>"
|
|
]
|
|
},
|
|
"metadata": {},
|
|
"output_type": "display_data"
|
|
}
|
|
],
|
|
"source": [
|
|
"# Visualize the result\n",
|
|
"plt.plot(xdata, ydata, 'or')\n",
|
|
"plt.plot(xfit, yfit, '-', color='gray')\n",
|
|
"\n",
|
|
"plt.fill_between(xfit, yfit - dyfit, yfit + dyfit,\n",
|
|
" color='gray', alpha=0.2)\n",
|
|
"plt.xlim(0, 10);"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Note what we've done here with the ``fill_between`` function: we pass an x value, then the lower y-bound, then the upper y-bound, and the result is that the area between these regions is filled.\n",
|
|
"\n",
|
|
"The resulting figure gives a very intuitive view into what the Gaussian process regression algorithm is doing: in regions near a measured data point, the model is strongly constrained and this is reflected in the small model errors.\n",
|
|
"In regions far from a measured data point, the model is not strongly constrained, and the model errors increase.\n",
|
|
"\n",
|
|
"For more information on the options available in ``plt.fill_between()`` (and the closely related ``plt.fill()`` function), see the function docstring or the Matplotlib documentation.\n",
|
|
"\n",
|
|
"Finally, if this seems a bit too low level for your taste, refer to [Visualization With Seaborn](04.14-Visualization-With-Seaborn.ipynb), where we discuss the Seaborn package, which has a more streamlined API for visualizing this type of continuous errorbar."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"<!--NAVIGATION-->\n",
|
|
"< [Simple Scatter Plots](04.02-Simple-Scatter-Plots.ipynb) | [Contents](Index.ipynb) | [Density and Contour Plots](04.04-Density-and-Contour-Plots.ipynb) >"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"anaconda-cloud": {},
|
|
"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.4.3"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 0
|
|
}
|