You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1420 lines
623 KiB

2 years ago
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"___\n",
"\n",
"<a href='http://www.pieriandata.com'><img src='../Pierian_Data_Logo.png'/></a>\n",
"___\n",
"<center><em>Copyright by Pierian Data Inc.</em></center>\n",
"<center><em>For more information, visit us at <a href='http://www.pieriandata.com'>www.pieriandata.com</a></em></center>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Distributions\n",
"\n",
"There are many ways to display the distributions of a feature. In this notebook we explore 3 related plots for displaying a distribution, the rugplot , the distplot (histogram), and kdeplot.\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"-----\n",
"\n",
"### IMPORTANT NOTE!\n",
"\n",
"**DO NOT WORRY IF YOUR PLOTS STYLING APPEARS SLIGHTLY DIFFERENT, WE WILL SHOW YOU HOW TO EDIT THE COLOR AND STYLE OF THE PLOTS LATER ON!**"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"----\n",
"## Data\n",
"\n",
"We'll use some generated data from: http://roycekimmons.com/tools/generated_data\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"import seaborn as sns"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [],
"source": [
"df = pd.read_csv(\"dm_office_sales.csv\")"
]
},
{
"cell_type": "code",
"execution_count": 37,
"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>division</th>\n",
" <th>level of education</th>\n",
" <th>training level</th>\n",
" <th>work experience</th>\n",
" <th>salary</th>\n",
" <th>sales</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>printers</td>\n",
" <td>some college</td>\n",
" <td>2</td>\n",
" <td>6</td>\n",
" <td>91684</td>\n",
" <td>372302</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>printers</td>\n",
" <td>associate's degree</td>\n",
" <td>2</td>\n",
" <td>10</td>\n",
" <td>119679</td>\n",
" <td>495660</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>peripherals</td>\n",
" <td>high school</td>\n",
" <td>0</td>\n",
" <td>9</td>\n",
" <td>82045</td>\n",
" <td>320453</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>office supplies</td>\n",
" <td>associate's degree</td>\n",
" <td>2</td>\n",
" <td>5</td>\n",
" <td>92949</td>\n",
" <td>377148</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>office supplies</td>\n",
" <td>high school</td>\n",
" <td>1</td>\n",
" <td>5</td>\n",
" <td>71280</td>\n",
" <td>312802</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" division level of education training level work experience \\\n",
"0 printers some college 2 6 \n",
"1 printers associate's degree 2 10 \n",
"2 peripherals high school 0 9 \n",
"3 office supplies associate's degree 2 5 \n",
"4 office supplies high school 1 5 \n",
"\n",
" salary sales \n",
"0 91684 372302 \n",
"1 119679 495660 \n",
"2 82045 320453 \n",
"3 92949 377148 \n",
"4 71280 312802 "
]
},
"execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"RangeIndex: 1000 entries, 0 to 999\n",
"Data columns (total 6 columns):\n",
" # Column Non-Null Count Dtype \n",
"--- ------ -------------- ----- \n",
" 0 division 1000 non-null object\n",
" 1 level of education 1000 non-null object\n",
" 2 training level 1000 non-null int64 \n",
" 3 work experience 1000 non-null int64 \n",
" 4 salary 1000 non-null int64 \n",
" 5 sales 1000 non-null int64 \n",
"dtypes: int64(4), object(2)\n",
"memory usage: 47.0+ KB\n"
]
}
],
"source": [
"df.info()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"-----"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Rugplot\n",
"\n",
"Very simple plot that puts down one mark per data point. This plot needs the single array passed in directly. We won't use it too much since its not very clarifying for large data sets."
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {},
"outputs": [],
"source": [
"import seaborn as sns"
]
},
{
"cell_type": "code",
"execution_count": 48,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<AxesSubplot:xlabel='salary'>"
]
},
"execution_count": 48,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYgAAAENCAYAAAAVPvJNAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAfQElEQVR4nO3df1TUZf738RcCosb3rGvOUGLZ2bvu2qSyI6lZ4WHJBhADQdcfJG219mM7m9pZCjXr2KqU2VptWZndddbQFS1hbQUtyjbFTN3aZNU2bTMBHQahHyAIjNf9R/dM/LhMGxmVu+fjnA7zua7r8/lc77lm5tXMwMcQY4wRAADtdDvTEwAAnJ0ICACAFQEBALAiIAAAVgQEAMCKgAAAWJ1SQKxdu1bJyckaOXKk8vLyOvTv3r1bGRkZcrlcmjVrllpaWiRJVVVVuvPOO5WWlqYJEyaovLz8VKYBAAiCgAP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M5WYmKh77rlH9fX1HcY0NTUpOztbSUlJGjNmjPbt2ydJqq+v19SpUzV69GiNHj1af//73wOvAAAQFAEHxJw5czRp0iQVFxcrJiZGixcv7jBm2bJl6tmzp4qKijRz5kzl5ORIkpYsWaJ+/fpp7dq1evXVV5Wbm6vq6urAqwAAdLqAAqK5uVnbtm2Ty+WSJKWnp6u4uLjDuI0bN+rmm2+WJF1zzTWqra1VZWWlhgwZosmTJ0uSzj33XPXu3ZuAAICzTFggO9XW1ioyMlJhYd/t7nA45Ha7O4yrqqqSw+H
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# The y axis doesn't really represent anything\n",
"# X axis is just a stick per data point\n",
"sns.rugplot(x='salary',data=df)"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<AxesSubplot:xlabel='salary'>"
]
},
"execution_count": 47,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYcAAAEJCAYAAAB/pOvWAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAeiElEQVR4nO3dfVTUZf7/8RcCasj36FIzZGhrbe52Ei2TwqxwDY0b8SY0bzBpK7V13VI8a6Juq5bm6lq6ndIyy/YYtt6k8MVVss3qJLqKdoeb+k3dKEQZFLYEQYfh+v3hj/kCFyaNjDfffT7O8TCf63Ndn8/15mLm5cwHZgKMMUYAANTR4lJPAABw+SEcAAAWwgEAYCEcAAAWwgEAYAm61BP4saqqqrR37145HA4FBgZe6ukAwGXP4/GopKREkZGRat26dZPGXFA4ZGdna+nSpXK73frVr36lUaNGNdpv6tSpio6OVnJysiQpMzNTCxcu1NVXXy1J+uUvf6m0tLQmnXPv3r3nPA8A4NwyMjIUF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7oPNqdPV9Y5Rd4zU+ANybVvt14YPvo09yBtj96t73h8KhnPNo67a2hr2PV8w1D13teeH62hsjrVtdc9Z9/a5jlF3vue63djc6+6vu137tXZM3XWs21a3vXZMw/Zaddtrvzd116zueereN87XVnvuxs7Z8P7Z8HwN22vvPw3v03XvZw2Pd777/w8d71K7mPPw+WWlXr16aceOHSotLVVlZaW2bNmimJgY7/6IiAi1atVKe/bskSR
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.rugplot(x='salary',data=df,height=0.5)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## displot and histplot() \n",
"The rugplot itself is not very informative for larger data sets distribution around the mean since so many ticks makes it hard to distinguish one tick from another. Instead we should count the number of tick marks per some segment of the x axis, then construct a histogram from this.\n",
"\n",
"The displot is a plot type that can show you the distribution of a single feature. It is a histogram with the option of adding a \"KDE\" plot (Kernel Density Estimation) on top of the histogram. Let's explore its use cases and syntax."
]
},
{
"cell_type": "code",
"execution_count": 49,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<seaborn.axisgrid.FacetGrid at 0x21e6bf8a7c8>"
]
},
"execution_count": 49,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAV0AAAFcCAYAAABr1G0SAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAA6HUlEQVR4nO3deXhU9aE38O+s2SZ7ZrITCAHCDrIvhiJKAgHFhFZBxaq32FuvV2lfKgqWti6o1Ze+tk+tWvW+txdfBWRRiuACIhBACEsIJKzZl8lkzySTZJbf+wcSZc8yc84s38/z8Dxmcmbmm2Pyzcnv/M7vKIQQAkREJAml3AGIiHwJS5eISEIsXSIiCbF0iYgkxNIlIpKQx5euzWZDeXk5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7ArtwyjEuNlmWthe7InDYAnVY7vjrM2/mQfFi65BSHT1ejsaUD6ZOT5I5yQ0kxwRjaPwLbc25+Ox+73SFhKvI1rr1pFfmMLw6VIiLEH+NSDXJHuSGVSomwYD8UFNdj7f87itiooOtutzg9VeJk5Et4pEt9Zmqw4GihEXdO7AeVyr2/pRKjg+GnVeF8eaPcUchHufdPCHmEr74rgUMAd03sJ3eUW1IpFRgQF4IKkxmWDi5wTtJj6VKf2B0CXx4uxZhBesREXv/PdXeTHBcKIYDiqma5o5APYulSnxw5XQ1TgwWz3fgE2tVCdX6ICvXHxYomLnBOkmPpUp9s+uY8DOEBbjk392aS40PR3NqJuqZ2uaOQj2HpUq8VFNXjdFE97pkxEGo3P4F2tX4xIVApFbwsmCT
"text/plain": [
"<Figure size 360x360 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.displot(data=df,x='salary',kde=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Focusing on the Histogram"
]
},
{
"cell_type": "code",
"execution_count": 50,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<seaborn.axisgrid.FacetGrid at 0x21e6c1f3108>"
]
},
"execution_count": 50,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAV0AAAFcCAYAAABr1G0SAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAdGklEQVR4nO3de3BU9d3H8U8uCxRTx4KbiECdscUyIIIDBWM0NFJJyEUhiUIQQ4UKFkoRO0iAII/KvTBxrINX5A+LI0mABDMYvIBIEkVIvRQJDlUIhMsmCIpJuGQ3v+cPh62AwiZkf7sJ79cMM+zZs7vfPcZ3Dmd3z4YYY4wAAFaEBnoAALiSEF0AsIjoAoBFRBcALCK6AGBRq4+u2+1WV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O5aaIi4tTSUmJTpw4IY/Ho61btyohIUF79+5VZWWlPB6PioqKFBsb26z7B4Bg5tOebs+ePbVgwQKNGTNGkvSvf/2r2R8N7tu3r/785z9r9OjRamhoUExMjDIyMnTjjTdqypQpOn36tAYPHqyEhIRm3T8ABDOfojt37lzNmzdPo0aNUmNjo+68807NmTOn2Q+anp6u9PT0c5ZFR0dr/fr1zb5PAGgNLnp44cyZM5oxY4Y++ugjLVq0SGVlZbrlllsUFhamiIgIWzMCQJtx0eg+++yzqq2tPeebf59++mmdOHFC//znP/0+HAC0NReN7vvvv69ly5apc+fO3mVRUVFasmSJ3n33Xb8PBwBtzUWj63A41KF
"text/plain": [
"<Figure size 360x360 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.displot(data=df,x='salary')"
]
},
{
"cell_type": "code",
"execution_count": 51,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<AxesSubplot:xlabel='salary', ylabel='Count'>"
]
},
"execution_count": 51,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYwAAAEJCAYAAACHRBAhAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAcHklEQVR4nO3de1DVdf7H8ReXg1Zs02oHLHWdadfW8ZI6uhphuOYmyKUUKG+FqZu1ua7ZjomIuZb31bFpG7uafzQ0K6JCMkaX1UygTNkuS2LjlqJ4AUzLAEE4fH5/9PPsmoofWL6Hgz0fM85wPufzPef98cvwOp/v93s+3wBjjBEAAFcQ2NYFAADaBwIDAGCFwAAAWCEwAABWCAwAgJXgti7gf1VbW6vi4mK53W4FBQW1dTkA0C54PB5VVlaqb9++6tixo9U27T4wiouLNWnSpLYuAwDapYyMDA0ePNiqr6OBUVVVpfHjx+vFF19Ut27dtGHDBr3++usKCA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IFTtcGAPAjTQbGuXPnNHfuXH300Udavny5CgsLddtttykoKEihoaG+qhEA4AeaDIznnntOVVVVGjhwoLftmWee0ZkzZ/S3v/3N8eIAAP6jycB4//33tXr1anXu3NnbFh4erpUrV+q9995zvDgAgP9oMjBcLpc6dux4UXtoaKhCQkIcKwoA4H+aDIzAwEBVVVVd1F5VVaWGhgbHigIA+J8mAyM+Pl7p6emqqanxttXU1Cg9PV2jRo1yvDg
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.histplot(data=df,x='salary')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Number of Bins"
]
},
{
"cell_type": "code",
"execution_count": 52,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<AxesSubplot:xlabel='salary', ylabel='Count'>"
]
},
"execution_count": 52,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYwAAAEJCAYAAACHRBAhAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAbq0lEQVR4nO3de1DVdf7H8Rc3NXJ3Wo1DpqwzlbtuaubopmTBmisgcPICeSMxbdPdzE1qTERcN1Mk07Fxu5fjH0WzKuYlxjAb0xLMjC1dSh03BcULeCsFBOHw+f3Ren5Lmn40vgeQ52OmGc7nfL983m8/jS+/l/M9fsYYIwAArsC/sQsAADQPBAYAwAqBAQCwQmAAAKwQGAAAK4GNXcDPVVVVpcLCQoWEhCggIKCxywGAZsHj8ej48ePq3r272rRpY7VPsw+MwsJCJSUlNXYZANAsZWVlqU+fPlbbNvvACAkJkfRD07fccksjVwMAzcOxY8eUlJTk/TvURrMPjAunoW655RZ16tSpkasBgOblak7lc9EbAGCFwAAAWHH0lNRLL72kDz74QJIUGRmpZ555RjNmz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x+sUvfqH+/ftrxIgRSkxMVP/+/fXLX/5SkydP9lWNAIAm4LKPBvH399dzzz2nSZMm6ZtvvpG/v7969Oih0NBQX9UHAGgirJ4l1alTJ3Xq1MnpWgAATdhVf0UrAKBlIjAAAFYIDACAFUcDo7y8XPHx8SopKZEk5efny+12KyoqSosXL/Zut3v3biUkJCg
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.histplot(data=df,x='salary',bins=10)"
]
},
{
"cell_type": "code",
"execution_count": 53,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<AxesSubplot:xlabel='salary', ylabel='Count'>"
]
},
"execution_count": 53,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYYAAAEJCAYAAACQZoDoAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAeKUlEQVR4nO3de1DVdf7H8RcComY7qQFZOv621t1m1XUczSRL1lwRuSgFqUjqaiW7q5K2U6LhupmSuTqWW9vVdaekWW+ZxphmmZTifcuWTR1XBSURVExElMvh8/vDOOvXQIHO91zg+Zhx5pzvuXzfH77n+OL7/Xz4fPyMMUYAAHyvhacLAAB4F4IBAGBBMAAALAgGAIAFwQAAsAjwdAH1dfnyZeXk5Cg4OFj+/v6eLgcAfILD4dDp06fVvXt3tWrVql6v8ZlgyMnJUVJSkqfLAACflJGRoT59+tTruT4TDMHBwZKuNO62227zcDUA4BtOnTqlpKQk5/+h9eEzwVBz+ei2225Tp06dPFwNAPiWhlyCp/MZAGBBMAAALAgGAIAFwQAAsCAYAAAWBAMAwIJgAABY+MzfMQAN9Y/M/6i4pFztfxKk38Z083Q5gM8gGNBkFZeU68x3lzxdBuBzuJQEALAgGAAAFgQDAMCCYAAAWBAMAAALggEA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WFpu+6wVBRUaFZs2Zp8ODBzj9Umzhxovz9/dW2bVu3FAjf0BQWs3F3G+oz+ogRSvCE615KWrJkiUpLS9WrVy/ntueff14lJSX661/
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.histplot(data=df,x='salary',bins=100)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Adding in a grid and styles\n",
"\n",
"You can reset to a different default style: one of {darkgrid, whitegrid, dark, white, ticks}.\n",
"\n",
"In a later notebook and lecture we will cover custom styling in a lot more detail."
]
},
{
"cell_type": "code",
"execution_count": 54,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<AxesSubplot:xlabel='salary', ylabel='Count'>"
]
},
"execution_count": 54,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYYAAAEJCAYAAACQZoDoAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAjq0lEQVR4nO3de3BTZfoH8G+aE0qhRUlNuwj9uajsOossw6AIou0i21B6gUorUMpFVKi7XAR3lIJlWREQWRiU1fWKOArOAuVqB0EUAWnlIqu4VWBYoIUKtiWBtmlLm8v7+wObzSkNTUrOyaXfzwwzpycn5zxPzglPct4376sRQggQERH9IszfARARUWBhYSAiIhkWBiIikmFhICIiGRYGIiKSYWEgIiIZFgYiIpKR/B2Aty5froXD0fpPL6KjI2EyWVSISB2hlE8o5QIwn0DX3vMJC9Oga9fOXh0j6AqDwyE8KgxN24aSUMonlHIBmE+gYz7e4a0kIiKSYWEgIiIZFgYiIpJhYSAiIhkWBiIikmFhICIimaDrrkrkKa1W41y220OruyKRklgYKCRptRps3n8W5qp66G+JwKj4niwORB5iYaCQZa6qR+WVen+HQRR02MZAREQyLAxERCTDwkBERDIs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Lg41Fh+M1vfuP1jnv16uVcLikpwY4dOzBhwgQYDAbn+piYGJSXl3u13+joSI+3NRiivNp3oFMznw8KfoC5ugG/7hYFSSdBp5NwW9fO2HqgxLm+urYR5uoG6LuE4/HU3tc
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.set(style='darkgrid')\n",
"sns.histplot(data=df,x='salary',bins=100)"
]
},
{
"cell_type": "code",
"execution_count": 55,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<AxesSubplot:xlabel='salary', ylabel='Count'>"
]
},
"execution_count": 55,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYYAAAEJCAYAAACQZoDoAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAeKUlEQVR4nO3de1DVdf7H8RcComY7qQFZOv621t1m1XUczSRL1lwRuSgFqUjqaiW7q5K2U6LhupmSuTqWW9vVdaekWW+ZxphmmZTifcuWTR1XBSURVExElMvh8/vDOOvXQIHO91zg+Zhx5pzvuXzfH77n+OL7/Xz4fPyMMUYAAHyvhacLAAB4F4IBAGBBMAAALAgGAIAFwQAAsAjwdAH1dfnyZeXk5Cg4OFj+/v6eLgcAfILD4dDp06fVvXt3tWrVql6v8ZlgyMnJUVJSkqfLAACflJGRoT59+tTruT4TDMHBwZKuNO62227zcDUA4BtOnTqlpKQk5/+h9eEzwVBz+ei2225Tp06dPFwNAPiWhlyCp/MZAGBBMAAALAgGAIAFwQAAsCAYAAAWBAMAwIJgAABY+MzfMQAN9Y/M/6i4pFztfxKk38Z083Q5gM8gGNBkFZeU68x3lzxdBuBzuJQEALAgGAAAFgQDAMCCYAAAWBAMAAALggEAYGHrcNWXX35ZmzZtkp+fnxISEjR+/HjNmDFD+/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2bVu3FAjf0BQWs3F3G+oz+ogRSvCE615KWrJkiUpLS9WrVy/ntueff14lJSX661/
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.set(style='white')\n",
"sns.histplot(data=df,x='salary',bins=100)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Adding in keywords from matplotlib\n",
"\n",
"Seaborn plots can accept keyword arguments directly from the matplotlib code that seaborn uses. Keep in mind, not every seaborn plot can accept all matplotlib arguments, but the main styling parameters we've discussed are available. "
]
},
{
"cell_type": "code",
"execution_count": 62,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<seaborn.axisgrid.FacetGrid at 0x21e6eaaf508>"
]
},
"execution_count": 62,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAV0AAAFcCAYAAABr1G0SAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAABZdElEQVR4nO29eXyU5dX//541kw1CQhJC2Izsi2CJCy5YxMouClRFKrhUbd21XyoqymOLu/6wrXVfqn3cABWUImpFedhEpBJkX7ORkJWss8/cvz8yiYlb7+uGGSaT8369eA3cMyfXmZvJmes61+c6x6RpmoYgCIIQEcwn2gFBEISOhARdQRCECCJBVxAEIYJI0BUEQYggEnQFQRAiSLsPun6/n+LiYvx+/4l2RRAE4b/S7oPukSNHGDt2LEeOHDnRrgiCIPxX2n3QFQRBaE+ENeg2NDQwefJkiouL21x/4403uPLKK1v+XVJSwqxZsxg/fjy///3vaWxsDKdbgiAIJ4ywBd28vDxmzpxJfn5+m+v79+/n+eefb3PtgQce4IorrmDVqlUMHTqUZ555JlxuCYIgnFDCFnQXL17MggULyMjIaLnm9Xq5//77ue2221qu+Xw+Nm/ezLhx4wCYNm0aq1atCpd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LllCqEHQ7W630Q029YKYpVyYfaCHakc+oEHV0s9s5CzWdbr+EBGYBQxSOGwvCiUCCrhB1uAIBqgCnYh1eQWgPSNAVoo7DXi8rgIMqeWC3m+UmE3sUcrpWk4nuKSlYDR7
"text/plain": [
"<Figure size 360x360 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.displot(data=df,x='salary',bins=20,kde=False,\n",
" color='red',edgecolor='black',lw=4,ls='--')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## The Kernel Density Estimation Plot\n",
"\n",
"**Note: Review the video for full detailed explanation.**\n",
"\n",
"The KDE plot maps an estimate of a probability *density* function of a random variable. Kernel density estimation is a fundamental data smoothing problem where inferences about the population are made, based on a finite data sample.\n",
"\n",
"Let's build out a simple example:"
]
},
{
"cell_type": "code",
"execution_count": 63,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 64,
"metadata": {},
"outputs": [],
"source": [
"np.random.seed(42)\n",
"\n",
"# randint should be uniform, each age has the same chance of being chosen\n",
"# note: in reality ages are almost never uniformally distributed, but this is just an example\n",
"sample_ages = np.random.randint(0,100,200)"
]
},
{
"cell_type": "code",
"execution_count": 87,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([51, 92, 14, 71, 60, 20, 82, 86, 74, 74, 87, 99, 23, 2, 21, 52, 1,\n",
" 87, 29, 37, 1, 63, 59, 20, 32, 75, 57, 21, 88, 48, 90, 58, 41, 91,\n",
" 59, 79, 14, 61, 61, 46, 61, 50, 54, 63, 2, 50, 6, 20, 72, 38, 17,\n",
" 3, 88, 59, 13, 8, 89, 52, 1, 83, 91, 59, 70, 43, 7, 46, 34, 77,\n",
" 80, 35, 49, 3, 1, 5, 53, 3, 53, 92, 62, 17, 89, 43, 33, 73, 61,\n",
" 99, 13, 94, 47, 14, 71, 77, 86, 61, 39, 84, 79, 81, 52, 23, 25, 88,\n",
" 59, 40, 28, 14, 44, 64, 88, 70, 8, 87, 0, 7, 87, 62, 10, 80, 7,\n",
" 34, 34, 32, 4, 40, 27, 6, 72, 71, 11, 33, 32, 47, 22, 61, 87, 36,\n",
" 98, 43, 85, 90, 34, 64, 98, 46, 77, 2, 0, 4, 89, 13, 26, 8, 78,\n",
" 14, 89, 41, 76, 50, 62, 95, 51, 95, 3, 93, 22, 14, 42, 28, 35, 12,\n",
" 31, 70, 58, 85, 27, 65, 41, 44, 61, 56, 5, 27, 27, 43, 83, 29, 61,\n",
" 74, 91, 88, 61, 96, 0, 26, 61, 76, 2, 69, 71, 26])"
]
},
"execution_count": 87,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sample_ages"
]
},
{
"cell_type": "code",
"execution_count": 88,
"metadata": {},
"outputs": [],
"source": [
"sample_ages = pd.DataFrame(sample_ages,columns=[\"age\"])"
]
},
{
"cell_type": "code",
"execution_count": 89,
"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>age</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>51</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>92</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>14</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>71</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>60</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" age\n",
"0 51\n",
"1 92\n",
"2 14\n",
"3 71\n",
"4 60"
]
},
"execution_count": 89,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sample_ages.head()"
]
},
{
"cell_type": "code",
"execution_count": 90,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<AxesSubplot:xlabel='age'>"
]
},
"execution_count": 90,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAENCAYAAAACHGKEAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAaaUlEQVR4nO3cf3BU1d3H8U8gIYC0MupuFKiohdFCRJyGH6KTNE3p5qeBBEdJStqqWJkOv+YxNRKRQYEgZspoFacqU6cYKLE/smKThRKlLYRakmkFBrTCU8QQ2N1IrCUkZHe5zx8O+yQka5bdaCTn/frr3nvOvfd79mzuZ+5u9sZYlmUJAGCsQf1dAACgfxEEAGA4ggAADEcQAIDhCAIAMBxBAACGiyoItm3bpszMTM2cOVMVFRXd2g8fPqz8/Hw5HA6VlpbK7/dLkjwejx566CHNmjVL9913nxobG6MpAwAQhYiDwO12a/369dq8ebOcTqe2bt2qI0eOdOlTXFys5cuXa/v27bIsS5WVlZKkn/3sZ0pNTVVVVZVyc3NVXl4e3SgAABGLOAjq6uo0ffp0jRw5UsOHD5fD4ZDL5Qq2nzhxQu3t7Zo8ebIkKS8vTy6XS6dPn9Z7772n++67T5KUn5+vJUuWRDUIAEDkYiPd0ePxyGazBdftdrv2798fst1ms8ntduujjz7SqFGjtGbNGr3zzjsaNWqUli9fHvZ529vbdfDgQdlsNg0ePDjS8gHAKIFAQF6vV4mJiRo6dGiXtoiDoKcnU8TExPTa7vf7dejQIS1cuFClpaV6/fXXVVJSok2bNoV13oMHD6qwsDDSsgHAaBUVFUpKSuqyLeIgSEhIUH19fXDd4/HIbrd3aW9ubg6ue71e2e122Ww2XX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HuvQpLi7W8uXLtX37dlmWpcrKSknSypUrVVBQIJfLpcTERG3YsCG6UQAAIhZxENTV1Wn69OkaOXKkhg8fLofDIZfLFWw/ceKE2tvbNXnyZElSXl6eXC6XfD6f9u3bJ4fD0WU7AKB/RBwEHo9HNpstuG632+V2u0O222w2ud1utbS0aMSIEYqNje2yHQDQPyIOAsuyum2LiYnptb23/QAAX66IgyAhIUHNzc3BdY/HI7vdHrLd6/XKbrfrqquu0pkzZxQIBLpsBwD0j4iDYMaMGdq7d69Onz6ttrY27dixQ8nJycH20aNHKz4+Xg0NDZKkqqoqJScnKy4uTklJSaquru6yHQDQP6K6I1i6dKmKioo0a9YsZWdna9KkSZo/f74OHDggSSovL1dZWZkyMjLU1tamoqIiSdKKFStUWVmpzMxM1dfXa8mSJX0yGADApYuxevrQ/iussbFRaWlpqq2t1ZgxY/q7HAC4LHzetZNfFgOA4QgCADAcQQAAhiMIAMBwBAEAGI4gAADDEQQAYDiCAAAMRxAAgOEIAgAwHEEAAIYjCADAcAQBABiOIAAAwxEEAGA4ggAADEcQAIDhCAIAMBxBAACGIwgAwHAEAQAYjiAAAMMRBABgOIIAAAxHEACA4QgCADAcQQAAhos4CJqamlRYWKj09HQtWLBAra2t3fp0dHSouLhYGRkZmj17to4ePSpJam1t1eLFi5WTk6OcnBz98Y9/jHwEAICoRBwEK1euVEFBgVwulxITE7Vhw4ZufTZt2qRhw4appqZGy5YtU0lJiSTppZde0qhRo7Rt2za9+uqrKisrU3Nzc+SjAABELKIg8Pl82rdvnxwOhyQpLy9PLperW79du3bp7rvvliRNmTJFLS0tampq0tSpUzVv3jxJ0tVXX62RI0cSBADQT2Ij2amlpUUjRoxQbOxnu9tsNrnd7m79PB6PbDZbcN1ms+nUqVO68847g9uqq6vV0dGhceP
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.rugplot(data=sample_ages,x='age')"
]
},
{
"cell_type": "code",
"execution_count": 67,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Data does not contain 9\n",
"Data does not contain 15\n",
"Data does not contain 16\n",
"Data does not contain 18\n",
"Data does not contain 19\n",
"Data does not contain 24\n",
"Data does not contain 30\n",
"Data does not contain 45\n",
"Data does not contain 55\n",
"Data does not contain 66\n",
"Data does not contain 67\n",
"Data does not contain 68\n",
"Data does not contain 97\n"
]
}
],
"source": [
"for age in range(0,100):\n",
" if age not in sample_ages:\n",
" print(f\"Data does not contain {age}\")"
]
},
{
"cell_type": "code",
"execution_count": 91,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<seaborn.axisgrid.FacetGrid at 0x21e6f883e08>"
]
},
"execution_count": 91,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"text/plain": [
"<Figure size 864x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAVwAAAFcCAYAAACEFgYsAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAXSklEQVR4nO3dbVBU5/3/8c/iLt7UpJla0LYaxxs6jqlRZ9JEQyqxDkizkDbKGNCRVGs1U8XGaRuVYG01UkLNMJMap2nH6RP9/asx9XaoMdZqApimMqmGGh1HRTQieG8QRXY5/wcZtxgXBHS/yy7v1xOWs7vnus6e9T3HXc6uy3EcRwCAkIsJ9wQAoKsguABghOACgBGCCwBGCC4AGImY4Pp8Pp0+fVo+ny/cUwGADomY4J49e1YTJkzQ2bNnwz0VAOiQiAkuAEQ6ggsARgguABghuABghOACgBGCCwBGCC4AGCG4AGCE4AKAEYILAEYILgAYIbgAYITgAoARggsARgguABghuABghOACgBGCCwBGCC4AGCG4AGCE4AKAEYILAEYILgAYIbgAYITgAoARggsARrpEcBt9TVE5FoDI4g73BCx43DHKX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6duzYEarhAaDTcYdqxStWrLjt99raWsXFxQV+j4+PV01NTaiGB4BOx+xNM8dx7ljmcrmshgeAsDMLbt++fXX+/PnA77W1tYGXGwCgKzAL7siRI3XixAmdPHlSfr9f27dv17hx46yGB4CwC9lruF/
"text/plain": [
"<Figure size 360x360 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.figure(figsize=(12,8))\n",
"sns.displot(data=sample_ages,x='age',bins=10,rug=True)"
]
},
{
"cell_type": "code",
"execution_count": 92,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<seaborn.axisgrid.FacetGrid at 0x21e6f9d82c8>"
]
},
"execution_count": 92,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"text/plain": [
"<Figure size 864x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAVwAAAFcCAYAAACEFgYsAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAn50lEQVR4nO3de3RU5b0+8GfuyWQm95ncJglJCESUS7wSUQJSLhrQChwEXNBqqXQtxJbVUxEaDz1SKKV2sVarXW3PYvWPSn8V9VCQg4gUuQZFUgwgEEPIldzvmcxkrvv3R2AaNAm5zTuXPJ9/Mtkzs9/vnj087Lz73e+WSZIkgYiIvE7u6wKIiMYKBi4RkSAMXCIiQRi4RESCMHCJiAQJmMB1Op2orq6G0+n0dSlERMMSMIFbV1eHOXPmoK6uztelEBENS8AELhFRoGPgEhEJwsAlIhKEgUtEJAgDl4hIEAYuEZEgDFwiIkEYuEREgjBwiYgEYeASEQnCwCUiEoSBS0QkCAOXiEgQBi4RkSAMXCIiQRi4RESCMHCJiARh4BIRCcLAJSIShIFLRCQIA5eISBAGLhGRIAxcIiJBGLhERIIwcImIBGHgEhEJMi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NSoFkow6jEsIhzEqFDKZDMcLq4fUFu/V5ltJBh1mPWDCyQs38en5Ksx9OCWoj3SDd8sooLncEprarKhr7kJdswUtHd0AAK1GiQxTBExGPQyRoTwBFgSMUVrk3m/Cp+ercPLCTcx+MDlox+sycMkv2BwulFS24mp5C66UteDLrxvgdEmQyYDYiFBMzohBQmzYkOaYpcBhiAxFzuQEnC6qwdl
"text/plain": [
"<Figure size 360x360 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.figure(figsize=(12,8))\n",
"sns.displot(data=sample_ages,x='age',bins=10,rug=True,kde=True)"
]
},
{
"cell_type": "code",
"execution_count": 93,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<AxesSubplot:xlabel='age', ylabel='Density'>"
]
},
"execution_count": 93,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAZAAAAEJCAYAAAC61nFHAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAA5i0lEQVR4nO3deViVdf7/8eeBc9hkXw4gLoggqICouBdmZrimqf2atKFlsvI7k+ZMTo626eTY4nesWWwaW2Ym7TuaU5qToak5pVgJpYCCCojK4mEH2c9y//4gmUhRRM65Wd6P6+q65L7Pwdc50Hl535/787k1iqIoCCGEEDfITu0AQgghuiYpECGEEO0iBSKEEKJdpECEEEK0ixSIEEKIdtGqHcAW6uvrSU9Px8/PD3t7e7XjCCFEl2A2mykuLiYyMhInJ6cr9veIAklPT2fhwoVqxxBCiC5py5YtxMbGXrG9RxSIn58f0PQmBAQEqJxGCCG6hosXL7Jw4cLmz9Af6xEFcvm0VUBAAH369FE5jRBCdC2tnfqXQXQhhBDtIgUihBCiXaRAhBBCtIsUiBBCiHaRAhFCCNEuUiBCCCHapUdcxitEd1ZWVc/Zgko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+/fJRGTn4lIUGt35td2I4UiFCd0WSmsKSGksp6SivqKK1qKoqSijrKKuspqayjqqaxxXN6OesI6+PJ3EmhDAvzY3Cwt0zu6+ZuHd6Htz4+wf7k84QEyWB6ZyAFImzuYmkNyRkG0nNKOX+xivziGiyWlndWdu/lgK+HM94eToT188TX0xkfdyd8PJ0J8HEh0KeXLFjYw7j3cmD0UH/+820eD80
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.kdeplot(data=sample_ages,x='age')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Cut Off KDE\n",
"\n",
"We could cut off the KDE if we know our data has hard limits (no one can be a negative age and no one in the population can be older than 100 for some reason)"
]
},
{
"cell_type": "code",
"execution_count": 94,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<AxesSubplot:xlabel='age', ylabel='Density'>"
]
},
"execution_count": 94,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAZAAAAEJCAYAAAC61nFHAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAA02klEQVR4nO3de0BUdf7/8ecMM9wEGcAZRC6KgqIiouINCzMzFHVzybZNf7HV5m5tXy223GrTTMu1C7u2235td/tW+93Sb9JNslxETUvFUskbihfwgiAy3JX7MJzfH67skjckhjMzvB//1JzPMLyPA/PinPc5n49GURQFIYQQ4iZp1S5ACCGEY5IAEUII0SESIEIIITpEAkQIIUSHSIAIIYToEJ3aBXSFhoYGcnJyMBqNuLi4qF2OEEI4BKvVSmlpKVFRUbi7u18x3i0CJCcnh7lz56pdhhBCOKTVq1cTGxt7xfZuESBGoxG49I/Qu3dvlasRQgjHcP78eebOndv6Gfp93SJALp+26t27N8HBwSpXI4QQjuVap/6liS6EEK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ee+T8ZwZK3drF283HunzZY7ZJUJwEixA00W1v46rtCPtxygqLSGgaF+vLrOaMYFi6TH3Y3IyNN3DYqmE+25nF7bAhBxu49+aIEiBDX0NDYTObuM3y6LZ+yqnrC+vTktw+MZlxUoExB0o09NGMouw+f52+fHuKFeeO69c+CBIgQ31NeXU/GrjNsyDrFhdomhoT58djs4YyKNHXrDwtxiW9Pd+67M5K3P8t
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# plt.figure(figsize=(12,8))\n",
"sns.kdeplot(data=sample_ages,x='age',clip=[0,100])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Binwidth\n",
"\n",
"As explained in the video, the KDE is constructed through the summation of the kernel (most commonly Gaussian), we can effect the bandwith of this kernel to make the KDE more \"sensitive\" to the data. Notice how with a smaller bandwith, the kernels don't stretch so wide, meaning we don't need the cut-off anymore. This is analagous to increasing the number of bins in a histogram (making the actual bins narrower)."
]
},
{
"cell_type": "code",
"execution_count": 95,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<AxesSubplot:xlabel='age', ylabel='Density'>"
]
},
"execution_count": 95,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAZAAAAEJCAYAAAC61nFHAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAABahklEQVR4nO29eXxUhb3//Zl9yWyZZDIhgbBGIrJpIyC1UOsSZblwQW9VWvzVK2qfVr08v3Lr3luvXqrSi9622pb23j6tWKXawrVFFrXUCrQiLoCEJeyEZDLJZDL7fp4/Ts7JTDLLObMmme/79eqrMieZnGRmzud8t89XwjAMA4IgCIIQibTUJ0AQBEGMTEhACIIgiKwgASEIgiCyggSEIAiCyAoSEIIgCCIr5KU+gWIQC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fgSBGLW5fCBVqBWSDdoEA8VsJSUCS0ecJQaWUQa0cmKHhhgmd7vKqgxRMQObPn4/9+/fD4XDA7/dj165dWLBgAX+8vr4eKpUKBw8eBABs3bqVP75u3TqMHz8eL774IpTKAZVfuHAhtm7dCgDYvn07mpubeXEhCEI4bm8oaf0DGKiB0DR6cvq8QRgH/e3M3DR6mbXyDh1DzRNWqxVr167F6tWrEQ6Hceutt2LmzJlYs2YNHnzwQcyYMQMbNmzA448/Dq/Xi2nTpmH16tU4evQo3n33XUyZMgXLly8HwEYemzZtwkMPPYSHH34Yixcvhl6vx4YNGwp1+gQxqnH7QjAkqX8AAzUQKqInx+UJwaBTJTxWaWD/3dNHApI3li5dynd
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.kdeplot(data=sample_ages,x='age',bw_adjust=0.1)"
]
},
{
"cell_type": "code",
"execution_count": 96,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<AxesSubplot:xlabel='age', ylabel='Density'>"
]
},
"execution_count": 96,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAZcAAAEJCAYAAABYCmo+AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAABBU0lEQVR4nO3de3zT9fX48Vea9ErvbdIrLXeKlMqlQEFWRMVyaYWB/FDQOp2wOYeIk3nB+3R4YUPdxneOr7jp4DsQHYhiAUG8AApUgQLlWkrpLemV3tJLks/vj0qkQqEtSZO05/l4+LD5fJJPTkKbk/ftvFWKoigIIYQQNuTm6ACEEEJ0PZJchBBC2JwkFyGEEDYnyUUIIYTNSXIRQghhcxpHB9AZ6uvrOXz4MFqtFrVa7ehwhBDCJZjNZkpKSoiPj8fLy6tdj+0WyeXw4cPMnTvX0W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QnZn5fH/c4IAIRUedzm+uAHyzHVotF1w/QIuHu9opu8a278ujscnMre3ct6at+kQFcrrgvMvVWHNGkly6oA93nkLtpuLnN/Zr9T6339Sf8BAfVm7MwuSi+3h0Rxnf5OLhrr7mci9X4umuZtgALd86WSFLi0Xh411niIsNol/PQLs8R59If6rrGik7Lyv1r5Vdk8umTZuYMmUKEydOZPXq1Zecz87OZubMmaSkpLBkyRJMJlOL82+88QZ/+ctfrLerqqqYP38+kydPZu7cuZSUyO5xP9VksvDVgQLGXR9JsL9Xq/fzcFfzy9viOaevIWNPbucFKDqsuq6RzzPzuXF4NL4drADcVknx4ZRWGjntRF1E3x03UFR
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.kdeplot(data=sample_ages,x='age',bw_adjust=0.5)"
]
},
{
"cell_type": "code",
"execution_count": 97,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<AxesSubplot:xlabel='age', ylabel='Density'>"
]
},
"execution_count": 97,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAZAAAAEJCAYAAAC61nFHAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAA5i0lEQVR4nO3deViVdf7/8eeBc9hkXw4gLoggqICouBdmZrimqf2atKFlsvI7k+ZMTo626eTY4nesWWwaW2Ym7TuaU5qToak5pVgJpYCCCojK4mEH2c9y//4gmUhRRM65Wd6P6+q65L7Pwdc50Hl535/787k1iqIoCCGEEDfITu0AQgghuiYpECGEEO0iBSKEEKJdpECEEEK0ixSIEEKIdtGqHcAW6uvrSU9Px8/PD3t7e7XjCCFEl2A2mykuLiYyMhInJ6cr9veIAklPT2fhwoVqxxBCiC5py5YtxMbGXrG9RxSIn58f0PQmBAQEqJxGC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jl2ppiUDAP5xTVoNBDR35uf3TWU8VEyk7k7GBzsTUhvDz5NypUC6USkQESXYDSZKa2sp7SynryiarLyKsi6UM7ZgirMFgUHrR1DQ3yYHTeQMZGBcqTRzWg0Gu4c04+/fJRGTn4lIUGt35td2I4UiFCd0WSmsKSGksp6SivqKK1qKoqSijrKKuspqayjqqaxxXN6OesI6+PJ3EmhDAvzY3Cwt0zu6+ZuHd6Htz4+wf7k84QEyWB6ZyAFImzuYmkNyRkG0nNKOX+xivziGiyWlndWdu/lgK+HM94eToT188TX0xkfdyd8PJ0J8HEh0KeXLFjYw7j3cmD0UH/+820eD80
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.kdeplot(data=sample_ages,x='age',bw_adjust=1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Basic Styling\n",
"\n",
"There are a few basic styling calls directly availble in a KDE."
]
},
{
"cell_type": "code",
"execution_count": 98,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<AxesSubplot:xlabel='age', ylabel='Density'>"
]
},
"execution_count": 98,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAZcAAAEJCAYAAABYCmo+AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAA3LklEQVR4nO3deVxVdf748ReyKeGIGhcNxD2tFLUY93DMjEUcGNSfoxZlEzZOuTXR4pJLmZkUZo1NmVYaTpI1EKWI2diiVmq5JZqiZm4soimIynJ+f3yEryggyz33nHt5Px8PHnrPucv7XvG872d7f5w0TdMQQgghrKiB0QEIIYRwPJJchBBCWJ0kFyGEEFYnyUUIIYTVSXIRQghhdS5GB2ALFy9eZM+ePXh7e+Ps7Gx0OEIIYReKi4vJzs6mS5cuNGzYsE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asjc6X10NGsichHJSUqBHD9UvXV233aa6At55R7+4RN2UlMDs2WoBrK00aKBaL6tX2+41K/Pjj7Btm1q3pTc3N9Wa37dP/9dyYLpdmX18fMi5qkZPVlYWFoul0vPZ2dnlzlfEYrGUPaaoqIi8vDy89O57tjeff65WWNfUX/+qpiZLN6M5lU4L7tXLtq/bv7/aL8ZImqYWAY8apX+rpVTbtqq6hag13ZJL37592bJlC7m5uRQUFJCWlkbQVeMAvr6+uLu7s/3KwFlSUlK58xUZMGAASVfKUqxZs4bAwEBcXV31egv2R9PUwrc776z5Y++4AywWmTlmRkV
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.kdeplot(data=sample_ages,x='age',bw_adjust=0.5,shade=True,color='red')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 2 Dimensional KDE Plots\n",
"\n",
"We will cover these in more detail later, but just keep in mind you could compare two continuous features and create a 2d KDE plot showing there distributions with the same kdeplot() call. Don't worry about this now, since we will cover it in more detail later when we talk about comparing 2 features against each other in a plot call."
]
},
{
"cell_type": "code",
"execution_count": 103,
"metadata": {},
"outputs": [],
"source": [
"random_data = pd.DataFrame(np.random.normal(0,1,size=(100,2)),columns=['x','y'])"
]
},
{
"cell_type": "code",
"execution_count": 104,
"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>x</th>\n",
" <th>y</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>0.926178</td>\n",
" <td>1.909417</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>-1.398568</td>\n",
" <td>0.562969</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>-0.650643</td>\n",
" <td>-0.487125</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>-0.592394</td>\n",
" <td>-0.863991</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>0.048522</td>\n",
" <td>-0.830950</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>95</th>\n",
" <td>-0.360966</td>\n",
" <td>1.159330</td>\n",
" </tr>\n",
" <tr>\n",
" <th>96</th>\n",
" <td>-1.081063</td>\n",
" <td>0.615936</td>\n",
" </tr>\n",
" <tr>\n",
" <th>97</th>\n",
" <td>0.593101</td>\n",
" <td>-0.309546</td>\n",
" </tr>\n",
" <tr>\n",
" <th>98</th>\n",
" <td>0.326133</td>\n",
" <td>-1.251114</td>\n",
" </tr>\n",
" <tr>\n",
" <th>99</th>\n",
" <td>0.924027</td>\n",
" <td>-0.184902</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>100 rows × 2 columns</p>\n",
"</div>"
],
"text/plain": [
" x y\n",
"0 0.926178 1.909417\n",
"1 -1.398568 0.562969\n",
"2 -0.650643 -0.487125\n",
"3 -0.592394 -0.863991\n",
"4 0.048522 -0.830950\n",
".. ... ...\n",
"95 -0.360966 1.159330\n",
"96 -1.081063 0.615936\n",
"97 0.593101 -0.309546\n",
"98 0.326133 -1.251114\n",
"99 0.924027 -0.184902\n",
"\n",
"[100 rows x 2 columns]"
]
},
"execution_count": 104,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"random_data"
]
},
{
"cell_type": "code",
"execution_count": 106,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<AxesSubplot:xlabel='x', ylabel='y'>"
]
},
"execution_count": 106,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYEAAAEJCAYAAAByupuRAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAACOA0lEQVR4nOydZXhU19qG79G4u7s7wd1KS4GWlrq7u5zqV3d3dy9tqQKF4hIgJCGQhLi7eyaj+/sxJCXEQ0hC2fd1cfWcjOydSbKetV55XokgCAIiIiIiIqck0vG+ARERERGR8UMUAREREZFTGFEERERERE5hRBEQEREROYURRUBERETkFEY+3jcwVDo7O0lPT8fJyQmZTDbetyMiIiJyUqDX66mtrSUyMhJTU9Nej580IpCens6ll1463rchIiIiclLy7bffMnny5F5fP2lEwMnJCTB+I66uruN8NyIiIiInB1VVVVx66aXda+ixnDQi0BUCcnV1xdPTc5zvRkREROTkor8wupgYFhERETmFEUVARERE5BRGFAERERGRUxhRBEREREROYUQREBERETmFEUVARERE5BRGFAERERGRUxhRBEREREROYUQREBERETmFEUVARERE5BRGFAERERGRUxhRBEREREROYUQREBERETmFGRcRePPNNznzzDNZtmwZn3/++XjcgoiIiIgI42AlnZiYyN69e/njjz/Q6XSceeaZzJs3D39//7G+FREREZFTnjE/CUydOpWvvvoKuVxOfX09er0ec3Pzsb4NERERERHGKRykUCh46623WLZsGTNmzMDFxWU8bkNERETklGfcEsN33HEHe/bsobKyktWrV4/XbYiIiIic0oy5COTn55OZmQmAmZkZS5YsITs7e6xvQ0RERESEcRCBsrIyHn30UTQaDRqNhs2bNxMfHz/WtyEiIiIiwjhUB82bN4+DBw+ycuVKZDIZS5YsYdmyZWN9GyIiIiIijIMIgDEfcMcdd4zHpUVEREREjmJcREBERKRv9HoDLe0aWjs0dKh1aLUG9AYDADKZFBOFDAszBVbmSqzMFUgkknG+Y5GTHVEERETGGEEQqGlUUVDeTEl1C+U1bVTUtVPb2E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y2JVawd2XTBp2qeviqd442Zrx3JeJ3P/2Dp64fga+bhOvO1pkeEgEYaju5eNLWVkZixYtYvPmzXh6eo737YgMAb3eQJtKS3unlg6Vjg61lk6NHrVaj1qrQ601oNXp0WgNaLR61Fo9Gq3e+ByNHpVaR3unlrYOo3Vym0rTy2vf0cYULxcrfN1t8HO3JsjLFndHy1Gvb9frDezLqGJ9QhGpubVIpRKmRbiyZJoPcSHOw9pZjxeCILAztZwP1hxCqzNw63kxzI/3Gvb7FFY088THe1FrdDxyzTSiAhxPwN2KjBaDrZ3iSUBkxBjLFduoqG2jqqGDmsYO6ps6aWjppKlNTbtKO+T3kkiMtfAmCikmSjlmJjLMTORYmCpwsjXD2kKJjaUJdtamONqY4mRnjquD+Qnv2K1vVrFxbzF/7y2moaUTR1szLjsjlMVTvXGwOf5wSKdaR3mtcahMfbOKplY17Z06tDo9gmCcDWBhKsfO2hRnO3O8Xa1wc7AYkchJJBLmxnkS7ufAy98k8ep3KeSVNXP18nBkw0j2+rnb8PIdc3ji4z089uEe7r44jrlx4sbsZEUUAZEh0djaSWZhAzkljeSXNVNY2Uxz27+DUaRSCQ42pjjamOHrZo2tlQk2FkoszZVYmCkwN5VjbirHVCnHVCnDRClHKZeiVMhQKmTIZZIJU34oCAKH8upYl1DI3vQqDAaBSaHO3LwqmilhLsNaMI9934q6dg7l1ZFVZPwsy2vbepxu5DIplmYKFArjNbRa42lKpzd0P8fSTEGEvwOTw1yYFuGK3TCTvY62Zjx38yw+/TO
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.kdeplot(data=random_data,x='x',y='y')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"----\n",
"----"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Bonus Code for Visualizations from Video Lecture\n",
"\n",
"Below is the code used to create the visualizations shown in the video lecture for an explanation of a KDE plot. We will not cover this code in further detail, since it was only used for the creation of the slides shown in the video."
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [],
"source": [
"from scipy import stats"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Data**"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [],
"source": [
"np.random.seed(101)\n",
"x = np.random.normal(0, 1, size=20)"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAsoAAAFoCAYAAABOqt04AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAEAAElEQVR4nOz9eWwl2Xnejz+11627X+5Lb2Sv08us0oxHI9lGpMhWNJJtBEggAYb/iBLbSAILiAIDQmBZhv8JEiuJESeRDSSALQN24EiyEFuWFf2+kuXRMjOapXt6J3vlTt791l51fn+cU8V72Xfj2mzyfADD6uHS5OFl1/u+53mfRyCEEHA4HA6Hw+FwOJwWxMf9BXA4HA6Hw+FwOPsRXihzOBwOh8PhcDht4IUyh8PhcDgcDofTBl4oczgcDofD4XA4beCFMofD4XA4HA6H0wb5cX8B7bBtG1euXMHQ0BAkSXrcXw6Hw+FwOBwO54ASBAFWVlZw4cIF6Lre8rZ9WShfuXIFn/70px/3l8HhcDgcDofDOSR85StfwQsvvNDy3/ZloTw0NASAfsGjo6OP+avhcDgcDofD4RxUFhcX8elPfzquP5vZl4VyJLcYHR3F5OTkY/5qOBwOh8PhcDgHnXZyX77Mx+FwOBwOh8PhtIEXyhwOh8PhcDgcTht4oczhcDgcDofD4bSBF8ocDofD4XA4HE4beKHM4XA4HA6Hw+G0gRfKHA6Hw+FwOBxOG3ihzOFwOBwOh8PhtIEXyhwOh8PhcDgcTht4oczhcDgcDofD4bSBF8ocDofD4XA4HE4beKHM4XA4HA6Hw+G0gRfKHA6Hw+FwOB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x432 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"\n",
"bandwidth = x.std() * x.size ** (-0.001)\n",
"support = np.linspace(-5, 5, 100)\n",
"\n",
"kernels = []\n",
"\n",
"plt.figure(figsize=(12,6))\n",
"\n",
"for x_i in x:\n",
"\n",
" kernel = stats.norm(x_i, bandwidth).pdf(support)\n",
" kernels.append(kernel)\n",
" plt.plot(support, kernel, color=\"lightblue\")\n",
"\n",
"sns.rugplot(x, color=\"darkblue\", linewidth=4);"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAsoAAAFoCAYAAABOqt04AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAABGvElEQVR4nO3deVzVdeL98XO57CAgCIiioqKgIOK+pGapg/temZZt2r45k5PT1GTNNM30dbKpbLVyGpfU3NLMJcdS0zI3BHdcQ2QTRHYul/v7w+I3ThSW4Ocur+fj4UPv/dyr51699x4/972YbDabTQAAAAAu42Z0AAAAAMAeUZQBAACAGlCUAQAAgBpQlAEAAIAaUJQBAACAGrgbHaAmZWVlSk1NVWhoqMxms9FxAAAA4KSsVqtycnIUHx8vb2/vy47ZZVFOTU3VpEmTjI4BAAAAF7FgwQJ17dr1suvssiiHhoZKuhS4cePGBqcBAACAs8rMzNSkSZOq++d/s8ui/MNwi8aNGysyMtLgNAAAAHB2NQ33ZTIfAAAAUAOKMgAAAFADijIAAABQA4oyAAAAUAOKMgAAAFADijIAAABQA4oyAAAAUAOKMgAAAFADijIAAABQA4oyAAAAUAOKMgAAAFADijIAAABQA4oyAAAAUAOKMgAAAFADijIAAABQA4oyAAAAUAOKMgAAAFADijIAAABQA4oyAAAAUAOKMgAAAFADijIAAABQA4oyAAAAUAOKMgAAAFADd6MDAADsT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AaCeFZda9NK/dykk0Fu
"text/plain": [
"<Figure size 864x432 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from scipy.integrate import trapz\n",
"plt.figure(figsize=(12,6))\n",
"density = np.sum(kernels, axis=0)\n",
"density /= trapz(density, support)\n",
"plt.plot(support, density);\n",
"sns.rugplot(x, color=\"darkblue\", linewidth=4);"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<AxesSubplot:ylabel='Density'>"
]
},
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAtIAAAFoCAYAAAB60xwkAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAEAAElEQVR4nOz9V5BdaXqeCz7/Mtv79ImE9wWggHLdVc1qki2SooJSU9LMhG4UoTuGInSnC0XokiHdSxeamQtKMTpx4pASD88MRSOxadtVd3V5A6DgffrM7f1y/1z8a+3cmdhpgUwkkOuJkNiVZufGwk7s73/X+72vkFJKQkJCQkJCQkJCQkK2hfain0BISEhISEhISEjIy0g4SIeEhISEhISEhITsgHCQDgkJCQkJCQkJCdkB4SAdEhISEhISEhISsgPCQTokJCQkJCQkJCRkBxgv+gnshE6nw7Vr1xgZGUHX9Rf9dEJCQkJCQkJCQl5RXNdlaWmJixcvEovFVn3upRykr127xj//5//8RT+NkJCQkJCQkJCQA8Lv//7v8/bbb6/62Es5SI+MjADqDzQ+Pv6Cn01ISEhISEhISMiryvz8PP/8n//z3vzZz0s5SAd2jvHxcaampl7wswkJCQkJCQkJCXnVGWQnDpcNQ0JCQkJCQkJCQnZAOEiHhISEhISEhISE7IBwkA4JCQkJCQkJCQnZAeEgHRISEhISEhISErIDwkE6JCQkJCQkJCQkZAeEg3RISEhISEhISE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c1+OT+SpzDWWzyMVM3p3MkzB3tlA61+jw0XQZz5/lyqUWH/z
"text/plain": [
"<Figure size 864x432 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"\n",
"bandwidth = x.std() * x.size ** (-0.001)\n",
"support = np.linspace(-5, 5, 100)\n",
"\n",
"kernels = []\n",
"\n",
"plt.figure(figsize=(12,6))\n",
"\n",
"for x_i in x:\n",
"\n",
" kernel = stats.norm(x_i, bandwidth).pdf(support)\n",
" kernels.append(kernel)\n",
" plt.plot(support, kernel, color=\"lightblue\")\n",
"\n",
"sns.rugplot(x, color=\"darkblue\", linewidth=4);\n",
"sns.kdeplot(x,linewidth=6,shade=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"---"
]
}
],
"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.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 1
}