{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Seaborn demo per Jake VanderPlas below" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from __future__ import print_function, division\n", "\n", "%matplotlib inline\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import pandas as pd" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt.style.use('ggplot')\n", "x = np.linspace(0, 10, 1000)\n", "plt.plot(x, np.sin(x), x, np.cos(x));" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import seaborn as sns\n", "sns.set()\n", "plt.plot(x, np.sin(x), x, np.cos(x));" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "data = np.random.multivariate_normal([0, 0], [[5, 2], [2, 2]], size=2000)\n", "data = pd.DataFrame(data, columns=['x', 'y'])\n", "\n", "for col in 'xy':\n", " plt.hist(data[col], density=True, alpha=0.5)\n", " # old Matplotlib would be plt.hist(data[col], normed=True, alpha=0.5)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "for col in 'xy':\n", " sns.kdeplot(data[col], shade=True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sns.distplot(data['x']);" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sns.kdeplot(data.x, data.y); # formerly sns.kdeplot(data)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "with sns.axes_style('white'):\n", " sns.jointplot(\"x\", \"y\", data, kind='kde');" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "with sns.axes_style('white'):\n", " sns.jointplot(\"x\", \"y\", data, kind='hex')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "iris = sns.load_dataset(\"iris\")\n", "iris.head()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "tips = sns.load_dataset('tips')\n", "tips.head()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "tips['tip_pct'] = 100 * tips['tip'] / tips['total_bill']\n", "\n", "grid = sns.FacetGrid(tips, row=\"sex\", col=\"time\", margin_titles=True)\n", "grid.map(plt.hist, \"tip_pct\", bins=np.linspace(0, 40, 15));" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "with sns.axes_style(style='ticks'):\n", " g = sns.factorplot(\"day\", \"total_bill\", \"sex\", data=tips, kind=\"box\")\n", " g.set_axis_labels(\"Day\", \"Total Bill\");" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "with sns.axes_style('white'):\n", " sns.jointplot(\"total_bill\", \"tip\", data=tips, kind='hex')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sns.jointplot(\"total_bill\", \"tip\", data=tips, kind='reg');" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "planets = sns.load_dataset('planets')\n", "planets.head()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "with sns.axes_style('white'):\n", " g = sns.factorplot(\"year\", data=planets, aspect=1.5)\n", " g.set_xticklabels(step=5)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "with sns.axes_style('white'):\n", " g = sns.factorplot(\"year\", data=planets, aspect=4.0,\n", " hue='method', order=range(2001, 2015), kind=\"count\")\n", " g.set_ylabels('Number of Planets Discovered')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Scikit-learn tutorial from pycon 2015 Jake VanderPlas [here](http://nbviewer.ipython.org/github/jakevdp/sklearn_pycon2015/blob/master/notebooks/Index.ipynb)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "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.4" } }, "nbformat": 4, "nbformat_minor": 1 }