Skip to content

Instantly share code, notes, and snippets.

@egentry
Last active June 3, 2019 20:27
Show Gist options
  • Save egentry/e212c944f3d127fb96a25b885aa35e3e to your computer and use it in GitHub Desktop.
Save egentry/e212c944f3d127fb96a25b885aa35e3e to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# How do I make this work?\n",
"\n",
"Possibilities:\n",
" - I'm viewing this in github and I just want to preview the end results\n",
" - View this notebook with nbviewer (follow [this link](https://nbviewer.jupyter.org/gist/egentry/e212c944f3d127fb96a25b885aa35e3e)), then scroll to the bottom. The table should be sortable. I was hoping you could view the table directly in Github, but it wasn't working.\n",
" \n",
" \n",
" \n",
" \n",
" - I want to run this on my own datasets, but don't want to change much else.\n",
" \n",
" 1) Open in a `jupyter notebook` or just copy the code cells into a python script.\n",
" \n",
" 2a) If using a `pokeminer`-style database: change the `databases` list [below](#Chose-what-datasets-to-compare), then hit `Cell > Run All` in the notebook menu at the top\n",
"\n",
" 2b) If using some different dataset: go to [this spot](#Create-a-Data-object), and create the `Data` object and `db_labels` yourself. Remember `data.counts` should be a 2D array, of shape (N_POKEMON X 2)\n",
" \n",
" - I like the idea, but want to change a lot.\n",
" - This is all MIT licensed, so you can do what you want. I might be able to offer some help troubleshooting / extending this, if you're interested. \n",
" \n",
"\n",
"\n",
"\n",
"## Misc. details\n",
"\n",
"Works in Python 2 and 3\n",
"\n",
"Required packages:\n",
" - numpy\n",
" - pandas\n",
" - scipy\n",
" - astropy\n",
" - ipython + jupyter notebook (if you want to run this in a notebook rather than a python script)\n",
"\n",
"All of those packages are included in the default anaconda distribution of python, or though pip\n",
"\n",
"License: MIT"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from __future__ import print_function, division\n",
"\n",
"import numpy as np\n",
"import pandas as pd\n",
"\n",
"from scipy import stats\n",
"from scipy.special import gamma, gammaln\n",
"\n",
"#if you know a better way to push a table to a notebook, let me know\n",
"from astropy.table import Table\n",
"\n",
"N_POKEMON = 151"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Chose what datasets to compare"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# a list of tuples of the form (\"db_uri\", \"Dataset Label\")\n",
"databases = [\n",
" (\"sqlite:///db_Paris.sqlite\", \"Paris\"),\n",
" (\"sqlite:///db_SC.sqlite\", \"Santa Cruz\"),\n",
"]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Create a Data object\n",
"\n",
"This can either be from a list of sqllite databases (formatted in the `pokeminer` style) or you can just create a `Data` object by hand, by passing `Data` a counts array of shape `N_POKEMON x N_DATASETS`\n",
"\n",
"I currently assume you're only comparing 2 datasets, but it wouldn't be that hard to add more, if you're willing to play with code."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def read_sql_into_counts_array(db_uri):\n",
" \"\"\"Given a database URI\n",
" Inputs\n",
" ------\n",
" db_uri : database connectable recognized by pandas.read_sql_table\n",
" \n",
" Returns\n",
" -------\n",
" counts : numpy.array\n",
" - shape: (151,)\n",
" - dtype: int\n",
" \n",
" Notes\n",
" -----\n",
" Expects db_uri to have a table `sightings` which has the \n",
" columns defined in `db.py` of `pokeminer`\n",
" \"\"\"\n",
" df = pd.read_sql_table(\"sightings\", db_uri)\n",
"\n",
" counts = np.zeros(151, dtype=int)\n",
" for p_id in df.pokemon_id:\n",
" counts[p_id-1] += 1\n",
" return counts"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"class Data(object):\n",
" def __init__(self, counts):\n",
" self.counts = counts\n",
" \n",
" @staticmethod\n",
" def from_db_uris(db_uris):\n",
" \"\"\"Container for observed data\n",
" \n",
" Inputs\n",
" ------\n",
" db_uris: sequence of `db_uri` for `read_sql_into_counts_array`\n",
" - must be of length `n_regions`\n",
" \"\"\"\n",
" counts = np.empty((N_POKEMON, len(db_uris)),\n",
" dtype=int)\n",
" \n",
" for i, db_uri in enumerate(db_uris):\n",
" counts[:,i] = read_sql_into_counts_array(db_uri)\n",
" \n",
" return Data(counts)\n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"n_regions = len(databases)\n",
"\n",
"db_uris = [db_tuple[0] for db_tuple in databases]\n",
"db_labels = [db_tuple[1] for db_tuple in databases]\n",
"\n",
"data = Data.from_db_uris(db_uris)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Model comparisons\n",
"\n",
"We're about to do some statistics to compare two different models, to see which describes our data. In short, Model 1 says that spawn rates of a particular species can be different between two regions. Model 2 says the spawn rate is the same in both regions.\n",
"\n",
"\n",
"## Technical details\n",
"\n",
"For each Pokemon species, with Pokemon number $j^\\prime$, we have $N$ total counts between the two regions. We assume the distribution between these two regions follows a [multinomial distribution](https://en.wikipedia.org/wiki/Multinomial_distribution). (This also happens to be a binomial distribution, but keeping it as a multinomial makes it easier to add more regions.)\n",
"\n",
"The difference between my models comes from the Bayesian prior. Both models use a [Dirichlet prior](https://en.wikipedia.org/wiki/Dirichlet_distribution), but they differ in their hyperparameters, $\\alpha_i$. \n",
"\n",
"\"Model 1\" uses a non-informative prior $\\alpha_i = 1/2$. When we want to estimate the relative spawn ratio, this is effectively like adding an extra $1/2$ to the number of observations in each region. (Because [reasons](https://en.wikipedia.org/wiki/Jeffreys_prior)) \n",
"\n",
"\"Model 2\" uses a highly-informative prior. If we're only looking at 1 Pokemon species at a time, then we assume its spawn ratio will be _very_ similar to the combined spawn ratio of all Pokemon except this particular species. For a region $i$ and Pokemon number $j^\\prime$ this gives: $\\alpha_i = 1/2 + \\sum_{j \\neq j^\\prime} \\mathtt{counts[i,j]}$\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def log_B(alpha):\n",
" \"\"\"Calculates the natural log of B, a function defined by:\n",
" https://en.wikipedia.org/wiki/Dirichlet_distribution\n",
" \n",
" Inputs\n",
" ------\n",
" alpha : numpy.ndarray\n",
" - an array of the alpha_i parameters of a Dirichlet distribution\n",
" \n",
" Returns\n",
" -------\n",
" log_B_ : float\n",
" \n",
" Notes\n",
" -----\n",
" alpha_i > 0, for all alpha_i\n",
" \"\"\"\n",
" log_B_ = np.sum(gammaln(alpha)) - gammaln(np.sum(alpha))\n",
" return log_B_"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"def log_marginal(prior, counts):\n",
" \"\"\"Calculate the natural log of the marginal density for the observed counts.\n",
" \n",
" Inputs\n",
" ------\n",
" - prior : scipy.stats.Dirichlet object\n",
" - the `a priori` distribution\n",
" - counts : numpy.ndarray\n",
" - the number of observed pokemon for each category\n",
" - must be flattened into a 1D array\n",
" \n",
" Returns\n",
" -------\n",
" - log_marginal_ : float\n",
" \n",
" Notes\n",
" -----\n",
" - This is also known as the `prior predictive`\n",
" - This calculates:\n",
" ln p(x) = ln \\int( p(x|theta) * p(theta) d theta)\n",
" where\n",
" p(theta) is the prior (a dirichlet distribution)\n",
" and\n",
" p(x|theta) is the likelihood (a multinomial distribution)\n",
" \"\"\"\n",
" n = counts.sum()\n",
" alpha = prior.alpha\n",
" beta = alpha + counts\n",
"\n",
" log_B_ratio = log_B(beta) - log_B(alpha)\n",
"\n",
" log_factorial_ratio = gammaln(n+1) - np.sum(gammaln(counts+1))\n",
"\n",
" log_marginal_ = log_B_ratio + log_factorial_ratio\n",
" return log_marginal_"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"def log_bayes_factor(prior_1, prior_2, counts):\n",
" \"\"\"Calculate the natural log of the Bayes factor between two hypotheses.\n",
" \n",
" Inputs\n",
" ------\n",
" - prior_1 : scipy.stats.Dirichlet object\n",
" - the `a priori` distribution of hypothesis 1\n",
" - prior_2 : scipy.stats.Dirichlet object\n",
" - the `a priori` distribution of hypothesis 2\n",
" - counts : numpy.ndarray\n",
" - the number of observed pokemon for each category\n",
" - must be flattened into a 1D array\n",
" \n",
" Returns\n",
" -------\n",
" - log_bayes_factor_ : float\n",
" \n",
" Notes\n",
" -----\n",
" - This calculates:\n",
" ln BF = ln (p(x|model 1) / p(x|model 2))\n",
" - If BF > 0, the data favors model 1;\n",
" If BF < 0, the data favors model 2;\n",
" - You need abs( ln BF ) > 1 to have any confidence\n",
" You need abs( ln BF ) > 5 to be very confident\n",
" - For more information see:\n",
" https://en.wikipedia.org/wiki/Bayes_factor\n",
" \n",
" \"\"\"\n",
" log_bayes_factor_ = log_marginal(prior_1, counts) - log_marginal(prior_2, counts)\n",
" return log_bayes_factor_"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def region_dependent_label(log_BF):\n",
" if log_BF < -5:\n",
" return \"No - very confident\"\n",
" elif log_BF < -1:\n",
" return \"No\"\n",
" elif log_BF < 1:\n",
" return \"Not sure\"\n",
" elif log_BF < 5:\n",
" return \"Yes\"\n",
" else:\n",
" return \"Yes - very confident\""
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"prior_overall = stats.dirichlet(np.full(data.counts.size, 1/2))\n",
"\n",
"prior_1 = stats.dirichlet(np.full(n_regions, 1/2))\n",
"\n",
"log_bayes_factors = np.empty(N_POKEMON)\n",
"for j in range(N_POKEMON):\n",
" counts_j = data.counts[j]\n",
"\n",
" mask = np.arange(N_POKEMON) != j # select all pokemon *except* this one\n",
" counts_except_j = data.counts[mask].sum(axis=0)\n",
"\n",
" prior_2_j = stats.dirichlet(counts_except_j + 1/2)\n",
" \n",
" log_bayes_factors[j] = log_bayes_factor(\n",
" prior_1, \n",
" prior_2_j, \n",
" counts_j,\n",
" )"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Gather together some useful results"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Taken from `locales/pokemon.en.json` from pokeminer\n",
"\n",
"pokemon_name_map = {1: 'Bulbasaur', 2: 'Ivysaur', 3: 'Venusaur', 4: 'Charmander', 5: 'Charmeleon', 6: 'Charizard', 7: 'Squirtle', 8: 'Wartortle', 9: 'Blastoise', 10: 'Caterpie', 11: 'Metapod', 12: 'Butterfree', 13: 'Weedle', 14: 'Kakuna', 15: 'Beedrill', 16: 'Pidgey', 17: 'Pidgeotto', 18: 'Pidgeot', 19: 'Rattata', 20: 'Raticate', 21: 'Spearow', 22: 'Fearow', 23: 'Ekans', 24: 'Arbok', 25: 'Pikachu', 26: 'Raichu', 27: 'Sandshrew', 28: 'Sandslash', 29: 'Nidoran(F)', 30: 'Nidorina', 31: 'Nidoqueen', 32: 'Nidoran(M)', 33: 'Nidorino', 34: 'Nidoking', 35: 'Clefairy', 36: 'Clefable', 37: 'Vulpix', 38: 'Ninetales', 39: 'Jigglypuff', 40: 'Wigglytuff', 41: 'Zubat', 42: 'Golbat', 43: 'Oddish', 44: 'Gloom', 45: 'Vileplume', 46: 'Paras', 47: 'Parasect', 48: 'Venonat', 49: 'Venomoth', 50: 'Diglett', 51: 'Dugtrio', 52: 'Meowth', 53: 'Persian', 54: 'Psyduck', 55: 'Golduck', 56: 'Mankey', 57: 'Primeape', 58: 'Growlithe', 59: 'Arcanine', 60: 'Poliwag', 61: 'Poliwhirl', 62: 'Poliwrath', 63: 'Abra', 64: 'Kadabra', 65: 'Alakazam', 66: 'Machop', 67: 'Machoke', 68: 'Machamp', 69: 'Bellsprout', 70: 'Weepinbell', 71: 'Victreebel', 72: 'Tentacool', 73: 'Tentacruel', 74: 'Geodude', 75: 'Graveler', 76: 'Golem', 77: 'Ponyta', 78: 'Rapidash', 79: 'Slowpoke', 80: 'Slowbro', 81: 'Magnemite', 82: 'Magneton', 83: \"Farfetch'd\", 84: 'Doduo', 85: 'Dodrio', 86: 'Seel', 87: 'Dewgong', 88: 'Grimer', 89: 'Muk', 90: 'Shellder', 91: 'Cloyster', 92: 'Gastly', 93: 'Haunter', 94: 'Gengar', 95: 'Onix', 96: 'Drowzee', 97: 'Hypno', 98: 'Krabby', 99: 'Kingler', 100: 'Voltorb', 101: 'Electrode', 102: 'Exeggcute', 103: 'Exeggutor', 104: 'Cubone', 105: 'Marowak', 106: 'Hitmonlee', 107: 'Hitmonchan', 108: 'Lickitung', 109: 'Koffing', 110: 'Weezing', 111: 'Rhyhorn', 112: 'Rhydon', 113: 'Chansey', 114: 'Tangela', 115: 'Kangaskhan', 116: 'Horsea', 117: 'Seadra', 118: 'Goldeen', 119: 'Seaking', 120: 'Staryu', 121: 'Starmie', 122: 'Mr. Mime', 123: 'Scyther', 124: 'Jynx', 125: 'Electabuzz', 126: 'Magmar', 127: 'Pinsir', 128: 'Tauros', 129: 'Magikarp', 130: 'Gyarados', 131: 'Lapras', 132: 'Ditto', 133: 'Eevee', 134: 'Vaporeon', 135: 'Jolteon', 136: 'Flareon', 137: 'Porygon', 138: 'Omanyte', 139: 'Omastar', 140: 'Kabuto', 141: 'Kabutops', 142: 'Aerodactyl', 143: 'Snorlax', 144: 'Articuno', 145: 'Zapdos', 146: 'Moltres', 147: 'Dratini', 148: 'Dragonair', 149: 'Dragonite', 150: 'Mewtwo', 151: 'Mew', 152: 'Chikorita', 153: 'Bayleef', 154: 'Meganium', 155: 'Cyndaquil', 156: 'Quilava', 157: 'Typhlosion', 158: 'Totodile', 159: 'Croconaw', 160: 'Feraligatr', 161: 'Sentret', 162: 'Furret', 163: 'Hoothoot', 164: 'Noctowl', 165: 'Ledyba', 166: 'Ledian', 167: 'Spinarak', 168: 'Ariados', 169: 'Crobat', 170: 'Chinchou', 171: 'Lanturn', 172: 'Pichu', 173: 'Cleffa', 174: 'Igglybuff', 175: 'Togepi', 176: 'Togetic', 177: 'Natu', 178: 'Xatu', 179: 'Mareep', 180: 'Flaaffy', 181: 'Ampharos', 182: 'Bellossom', 183: 'Marill', 184: 'Azumarill', 185: 'Sudowoodo', 186: 'Politoed', 187: 'Hoppip', 188: 'Skiploom', 189: 'Jumpluff', 190: 'Aipom', 191: 'Sunkern', 192: 'Sunflora', 193: 'Yanma', 194: 'Wooper', 195: 'Quagsire', 196: 'Espeon', 197: 'Umbreon', 198: 'Murkrow', 199: 'Slowking', 200: 'Misdreavus', 201: 'Unown', 202: 'Wobbuffet', 203: 'Girafarig', 204: 'Pineco', 205: 'Forretress', 206: 'Dunsparce', 207: 'Gligar', 208: 'Steelix', 209: 'Snubbull', 210: 'Granbull', 211: 'Qwilfish', 212: 'Scizor', 213: 'Shuckle', 214: 'Heracross', 215: 'Sneasel', 216: 'Teddiursa', 217: 'Ursaring', 218: 'Slugma', 219: 'Magcargo', 220: 'Swinub', 221: 'Piloswine', 222: 'Corsola', 223: 'Remoraid', 224: 'Octillery', 225: 'Delibird', 226: 'Mantine', 227: 'Skarmory', 228: 'Houndour', 229: 'Houndoom', 230: 'Kingdra', 231: 'Phanpy', 232: 'Donphan', 233: 'Porygon2', 234: 'Stantler', 235: 'Smeargle', 236: 'Tyrogue', 237: 'Hitmontop', 238: 'Smoochum', 239: 'Elekid', 240: 'Magby', 241: 'Miltank', 242: 'Blissey', 243: 'Raikou', 244: 'Entei', 245: 'Suicune', 246: 'Larvitar', 247: 'Pupitar', 248: 'Tyranitar', 249: 'Lugia', 250: 'Ho-Oh', 251: 'Celebi', 252: 'Treecko', 253: 'Grovyle', 254: 'Sceptile', 255: 'Torchic', 256: 'Combusken', 257: 'Blaziken', 258: 'Mudkip', 259: 'Marshtomp', 260: 'Swampert', 261: 'Poochyena', 262: 'Mightyena', 263: 'Zigzagoon', 264: 'Linoone', 265: 'Wurmple', 266: 'Silcoon', 267: 'Beautifly', 268: 'Cascoon', 269: 'Dustox', 270: 'Lotad', 271: 'Lombre', 272: 'Ludicolo', 273: 'Seedot', 274: 'Nuzleaf', 275: 'Shiftry', 276: 'Taillow', 277: 'Swellow', 278: 'Wingull', 279: 'Pelipper', 280: 'Ralts', 281: 'Kirlia', 282: 'Gardevoir', 283: 'Surskit', 284: 'Masquerain', 285: 'Shroomish', 286: 'Breloom', 287: 'Slakoth', 288: 'Vigoroth', 289: 'Slaking', 290: 'Nincada', 291: 'Ninjask', 292: 'Shedinja', 293: 'Whismur', 294: 'Loudred', 295: 'Exploud', 296: 'Makuhita', 297: 'Hariyama', 298: 'Azurill', 299: 'Nosepass', 300: 'Skitty', 301: 'Delcatty', 302: 'Sableye', 303: 'Mawile', 304: 'Aron', 305: 'Lairon', 306: 'Aggron', 307: 'Meditite', 308: 'Medicham', 309: 'Electrike', 310: 'Manectric', 311: 'Plusle', 312: 'Minun', 313: 'Volbeat', 314: 'Illumise', 315: 'Roselia', 316: 'Gulpin', 317: 'Swalot', 318: 'Carvanha', 319: 'Sharpedo', 320: 'Wailmer', 321: 'Wailord', 322: 'Numel', 323: 'Camerupt', 324: 'Torkoal', 325: 'Spoink', 326: 'Grumpig', 327: 'Spinda', 328: 'Trapinch', 329: 'Vibrava', 330: 'Flygon', 331: 'Cacnea', 332: 'Cacturne', 333: 'Swablu', 334: 'Altaria', 335: 'Zangoose', 336: 'Seviper', 337: 'Lunatone', 338: 'Solrock', 339: 'Barboach', 340: 'Whiscash', 341: 'Corphish', 342: 'Crawdaunt', 343: 'Baltoy', 344: 'Claydol', 345: 'Lileep', 346: 'Cradily', 347: 'Anorith', 348: 'Armaldo', 349: 'Feebas', 350: 'Milotic', 351: 'Castform', 352: 'Kecleon', 353: 'Shuppet', 354: 'Banette', 355: 'Duskull', 356: 'Dusclops', 357: 'Tropius', 358: 'Chimecho', 359: 'Absol', 360: 'Wynaut', 361: 'Snorunt', 362: 'Glalie', 363: 'Spheal', 364: 'Sealeo', 365: 'Walrein', 366: 'Clamperl', 367: 'Huntail', 368: 'Gorebyss', 369: 'Relicanth', 370: 'Luvdisc', 371: 'Bagon', 372: 'Shelgon', 373: 'Salamence', 374: 'Beldum', 375: 'Metang', 376: 'Metagross', 377: 'Regirock', 378: 'Regice', 379: 'Registeel', 380: 'Latias', 381: 'Latios', 382: 'Kyogre', 383: 'Groudon', 384: 'Rayquaza', 385: 'Jirachi', 386: 'Deoxys', 387: 'Turtwig', 388: 'Grotle', 389: 'Torterra', 390: 'Chimchar', 391: 'Monferno', 392: 'Infernape', 393: 'Piplup', 394: 'Prinplup', 395: 'Empoleon', 396: 'Starly', 397: 'Staravia', 398: 'Staraptor', 399: 'Bidoof', 400: 'Bibarel', 401: 'Kricketot', 402: 'Kricketune', 403: 'Shinx', 404: 'Luxio', 405: 'Luxray', 406: 'Budew', 407: 'Roserade', 408: 'Cranidos', 409: 'Rampardos', 410: 'Shieldon', 411: 'Bastiodon', 412: 'Burmy', 413: 'Wormadam', 414: 'Mothim', 415: 'Combee', 416: 'Vespiquen', 417: 'Pachirisu', 418: 'Buizel', 419: 'Floatzel', 420: 'Cherubi', 421: 'Cherrim', 422: 'Shellos', 423: 'Gastrodon', 424: 'Ambipom', 425: 'Drifloon', 426: 'Drifblim', 427: 'Buneary', 428: 'Lopunny', 429: 'Mismagius', 430: 'Honchkrow', 431: 'Glameow', 432: 'Purugly', 433: 'Chingling', 434: 'Stunky', 435: 'Skuntank', 436: 'Bronzor', 437: 'Bronzong', 438: 'Bonsly', 439: 'Mime Jr.', 440: 'Happiny', 441: 'Chatot', 442: 'Spiritomb', 443: 'Gible', 444: 'Gabite', 445: 'Garchomp', 446: 'Munchlax', 447: 'Riolu', 448: 'Lucario', 449: 'Hippopotas', 450: 'Hippowdon', 451: 'Skorupi', 452: 'Drapion', 453: 'Croagunk', 454: 'Toxicroak', 455: 'Carnivine', 456: 'Finneon', 457: 'Lumineon', 458: 'Mantyke', 459: 'Snover', 460: 'Abomasnow', 461: 'Weavile', 462: 'Magnezone', 463: 'Lickilicky', 464: 'Rhyperior', 465: 'Tangrowth', 466: 'Electivire', 467: 'Magmortar', 468: 'Togekiss', 469: 'Yanmega', 470: 'Leafeon', 471: 'Glaceon', 472: 'Gliscor', 473: 'Mamoswine', 474: 'Porygon-Z', 475: 'Gallade', 476: 'Probopass', 477: 'Dusknoir', 478: 'Froslass', 479: 'Rotom', 480: 'Uxie', 481: 'Mesprit', 482: 'Azelf', 483: 'Dialga', 484: 'Palkia', 485: 'Heatran', 486: 'Regigigas', 487: 'Giratina', 488: 'Cresselia', 489: 'Phione', 490: 'Manaphy', 491: 'Darkrai', 492: 'Shaymin', 493: 'Arceus', 494: 'Victini', 495: 'Snivy', 496: 'Servine', 497: 'Serperior', 498: 'Tepig', 499: 'Pignite', 500: 'Emboar', 501: 'Oshawott', 502: 'Dewott', 503: 'Samurott', 504: 'Patrat', 505: 'Watchog', 506: 'Lillipup', 507: 'Herdier', 508: 'Stoutland', 509: 'Purrloin', 510: 'Liepard', 511: 'Pansage', 512: 'Simisage', 513: 'Pansear', 514: 'Simisear', 515: 'Panpour', 516: 'Simipour', 517: 'Munna', 518: 'Musharna', 519: 'Pidove', 520: 'Tranquill', 521: 'Unfezant', 522: 'Blitzle', 523: 'Zebstrika', 524: 'Roggenrola', 525: 'Boldore', 526: 'Gigalith', 527: 'Woobat', 528: 'Swoobat', 529: 'Drilbur', 530: 'Excadrill', 531: 'Audino', 532: 'Timburr', 533: 'Gurdurr', 534: 'Conkeldurr', 535: 'Tympole', 536: 'Palpitoad', 537: 'Seismitoad', 538: 'Throh', 539: 'Sawk', 540: 'Sewaddle', 541: 'Swadloon', 542: 'Leavanny', 543: 'Venipede', 544: 'Whirlipede', 545: 'Scolipede', 546: 'Cottonee', 547: 'Whimsicott', 548: 'Petilil', 549: 'Lilligant', 550: 'Basculin', 551: 'Sandile', 552: 'Krokorok', 553: 'Krookodile', 554: 'Darumaka', 555: 'Darmanitan', 556: 'Maractus', 557: 'Dwebble', 558: 'Crustle', 559: 'Scraggy', 560: 'Scrafty', 561: 'Sigilyph', 562: 'Yamask', 563: 'Cofagrigus', 564: 'Tirtouga', 565: 'Carracosta', 566: 'Archen', 567: 'Archeops', 568: 'Trubbish', 569: 'Garbodor', 570: 'Zorua', 571: 'Zoroark', 572: 'Minccino', 573: 'Cinccino', 574: 'Gothita', 575: 'Gothorita', 576: 'Gothitelle', 577: 'Solosis', 578: 'Duosion', 579: 'Reuniclus', 580: 'Ducklett', 581: 'Swanna', 582: 'Vanillite', 583: 'Vanillish', 584: 'Vanilluxe', 585: 'Deerling', 586: 'Sawsbuck', 587: 'Emolga', 588: 'Karrablast', 589: 'Escavalier', 590: 'Foongus', 591: 'Amoonguss', 592: 'Frillish', 593: 'Jellicent', 594: 'Alomomola', 595: 'Joltik', 596: 'Galvantula', 597: 'Ferroseed', 598: 'Ferrothorn', 599: 'Klink', 600: 'Klang', 601: 'Klinklang', 602: 'Tynamo', 603: 'Eelektrik', 604: 'Eelektross', 605: 'Elgyem', 606: 'Beheeyem', 607: 'Litwick', 608: 'Lampent', 609: 'Chandelure', 610: 'Axew', 611: 'Fraxure', 612: 'Haxorus', 613: 'Cubchoo', 614: 'Beartic', 615: 'Cryogonal', 616: 'Shelmet', 617: 'Accelgor', 618: 'Stunfisk', 619: 'Mienfoo', 620: 'Mienshao', 621: 'Druddigon', 622: 'Golett', 623: 'Golurk', 624: 'Pawniard', 625: 'Bisharp', 626: 'Bouffalant', 627: 'Rufflet', 628: 'Braviary', 629: 'Vullaby', 630: 'Mandibuzz', 631: 'Heatmor', 632: 'Durant', 633: 'Deino', 634: 'Zweilous', 635: 'Hydreigon', 636: 'Larvesta', 637: 'Volcarona', 638: 'Cobalion', 639: 'Terrakion', 640: 'Virizion', 641: 'Tornadus', 642: 'Thundurus', 643: 'Reshiram', 644: 'Zekrom', 645: 'Landorus', 646: 'Kyurem', 647: 'Keldeo', 648: 'Meloetta', 649: 'Genesect', 650: 'Chespin', 651: 'Quilladin', 652: 'Chesnaught', 653: 'Fennekin', 654: 'Braixen', 655: 'Delphox', 656: 'Froakie', 657: 'Frogadier', 658: 'Greninja', 659: 'Bunnelby', 660: 'Diggersby', 661: 'Fletchling', 662: 'Fletchinder', 663: 'Talonflame', 664: 'Scatterbug', 665: 'Spewpa', 666: 'Vivillon', 667: 'Litleo', 668: 'Pyroar', 669: 'Flabébé', 670: 'Floette', 671: 'Florges', 672: 'Skiddo', 673: 'Gogoat', 674: 'Pancham', 675: 'Pangoro', 676: 'Furfrou', 677: 'Espurr', 678: 'Meowstic', 679: 'Honedge', 680: 'Doublade', 681: 'Aegislash', 682: 'Spritzee', 683: 'Aromatisse', 684: 'Swirlix', 685: 'Slurpuff', 686: 'Inkay', 687: 'Malamar', 688: 'Binacle', 689: 'Barbaracle', 690: 'Skrelp', 691: 'Dragalge', 692: 'Clauncher', 693: 'Clawitzer', 694: 'Helioptile', 695: 'Heliolisk', 696: 'Tyrunt', 697: 'Tyrantrum', 698: 'Amaura', 699: 'Aurorus', 700: 'Sylveon', 701: 'Hawlucha', 702: 'Dedenne', 703: 'Carbink', 704: 'Goomy', 705: 'Sliggoo', 706: 'Goodra', 707: 'Klefki', 708: 'Phantump', 709: 'Trevenant', 710: 'Pumpkaboo', 711: 'Gourgeist', 712: 'Bergmite', 713: 'Avalugg', 714: 'Noibat', 715: 'Noivern', 716: 'Xerneas', 717: 'Yveltal', 718: 'Zygarde', 719: 'Diancie', 720: 'Hoopa', 721: 'Volcanion'}\n"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"p_ids = np.arange(1,151+1)\n",
"names = np.array([pokemon_name_map[p_id] for p_id in p_ids])\n",
"total_counts = [data.counts[p_id-1].sum() for p_id in p_ids]\n",
"\n",
"region_dependent_labels = [region_dependent_label(log_bayes_factors[p_id-1]) for p_id in p_ids]\n",
"\n",
"rate_ratio = np.empty(N_POKEMON)\n",
"alphas = prior_overall.alpha.reshape((N_POKEMON, n_regions))\n",
"for p_id in p_ids:\n",
" mask = p_id != p_ids\n",
" rate_ratio[p_id-1] = ( (data.counts[p_id-1][0] + alphas[p_id-1][0]) \n",
" / (data.counts[p_id-1][1] + alphas[p_id-1][1]) ) \\\n",
" / ( (data.counts[mask].sum(axis=0)[0] + alphas[mask].sum(axis=0)[0]) \n",
" / (data.counts[mask].sum(axis=0)[1] + alphas[mask].sum(axis=0)[1]) )\n",
"\n",
"more_likely_in = [db_labels[0] if rate>1 else db_labels[1] for rate in rate_ratio]"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"collapsed": false,
"scrolled": false
},
"outputs": [],
"source": [
"t = Table([p_ids, names, total_counts, log_bayes_factors,\n",
" region_dependent_labels, more_likely_in, rate_ratio],\n",
" names=(\"Pokemon #\", \"names\", \"total_counts\", \n",
" \"significance proxy\", \"Region Dependent?\",\n",
" \"More Common In\", \n",
" \"spawn rate ratio ({0} / {1})\".format(db_labels[0], db_labels[1])))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Final Results\n",
"\n",
"Most columns are self-explanatory, except:\n",
" - `significance proxy`: values > 0 suggest the spawn rate is different between regions. Large values means we're very confident of that. Technically this is the log of the Bayes Factor.\n",
"\n",
" - Spawn rate ratio is an estimate of the relative spawn rate. It is *approximately, but not exactly*: $$ \\frac{\\text{number of this Pokemon in region 1 } / \\text{ total number of Pokemon in region 1}}{\\text{number of this Pokemon in region 2 } / \\text{ total number of Pokemon in region 2}} $$\n",
" \n",
" \n",
" \n",
" \n",
"So if you want to look for a pokemon that's changed a lot, look for a `spawn rate ratio` far from 1 **and** a large value for `significance proxy`. One easy way to do this is sort by `spawn rate ratio` and then sort by `Region Dependent?`.\n",
"\n",
"In my example notebook you'll know you're doing this right when either Clefairy or Magmar comes to the top fo the list."
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js\"></script>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%%HTML # needed to make the table sortable in nbviewer\n",
"<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js\"></script>"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"collapsed": false,
"scrolled": false
},
"outputs": [
{
"data": {
"text/html": [
"&lt;Table length=151&gt;\n",
"<table id=\"table4704613584-30734\" class=\"table-striped table-bordered table-condensed\">\n",
"<thead><tr><th>Pokemon #</th><th>names</th><th>total_counts</th><th>significance proxy</th><th>Region Dependent?</th><th>More Common In</th><th>spawn rate ratio (Paris / Santa Cruz)</th></tr></thead>\n",
"<tr><td>1</td><td>Bulbasaur</td><td>44</td><td>6.77094507132</td><td>Yes - very confident</td><td>Santa Cruz</td><td>0.274552536912</td></tr>\n",
"<tr><td>2</td><td>Ivysaur</td><td>2</td><td>0.900364678959</td><td>Not sure</td><td>Santa Cruz</td><td>0.128284115036</td></tr>\n",
"<tr><td>3</td><td>Venusaur</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>4</td><td>Charmander</td><td>22</td><td>11.3079079351</td><td>Yes - very confident</td><td>Santa Cruz</td><td>0.0781433170468</td></tr>\n",
"<tr><td>5</td><td>Charmeleon</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>6</td><td>Charizard</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>7</td><td>Squirtle</td><td>95</td><td>-1.74228009716</td><td>No</td><td>Santa Cruz</td><td>0.773771335815</td></tr>\n",
"<tr><td>8</td><td>Wartortle</td><td>12</td><td>-1.4067843265</td><td>No</td><td>Paris</td><td>1.21180059466</td></tr>\n",
"<tr><td>9</td><td>Blastoise</td><td>1</td><td>0.247431359412</td><td>Not sure</td><td>Santa Cruz</td><td>0.213819725922</td></tr>\n",
"<tr><td>10</td><td>Caterpie</td><td>915</td><td>136.15121324</td><td>Yes - very confident</td><td>Santa Cruz</td><td>0.320822653707</td></tr>\n",
"<tr><td>11</td><td>Metapod</td><td>52</td><td>11.6853135476</td><td>Yes - very confident</td><td>Santa Cruz</td><td>0.21884136051</td></tr>\n",
"<tr><td>12</td><td>Butterfree</td><td>1</td><td>0.247431359412</td><td>Not sure</td><td>Santa Cruz</td><td>0.213819725922</td></tr>\n",
"<tr><td>13</td><td>Weedle</td><td>1816</td><td>231.290508095</td><td>Yes - very confident</td><td>Santa Cruz</td><td>0.34893039532</td></tr>\n",
"<tr><td>14</td><td>Kakuna</td><td>126</td><td>8.98703323009</td><td>Yes - very confident</td><td>Santa Cruz</td><td>0.422350893558</td></tr>\n",
"<tr><td>15</td><td>Beedrill</td><td>14</td><td>2.9896631039</td><td>Yes</td><td>Santa Cruz</td><td>0.195131817922</td></tr>\n",
"<tr><td>16</td><td>Pidgey</td><td>10241</td><td>59.4541140904</td><td>Yes - very confident</td><td>Paris</td><td>1.3079487553</td></tr>\n",
"<tr><td>17</td><td>Pidgeotto</td><td>658</td><td>-3.45133944105</td><td>No</td><td>Paris</td><td>1.01330765508</td></tr>\n",
"<tr><td>18</td><td>Pidgeot</td><td>81</td><td>2.01710674339</td><td>Yes</td><td>Paris</td><td>2.0586589435</td></tr>\n",
"<tr><td>19</td><td>Rattata</td><td>8930</td><td>489.949207996</td><td>Yes - very confident</td><td>Paris</td><td>2.2538027074</td></tr>\n",
"<tr><td>20</td><td>Raticate</td><td>269</td><td>12.622710503</td><td>Yes - very confident</td><td>Paris</td><td>2.13891820375</td></tr>\n",
"<tr><td>21</td><td>Spearow</td><td>4331</td><td>65.9878212252</td><td>Yes - very confident</td><td>Paris</td><td>1.49683135</td></tr>\n",
"<tr><td>22</td><td>Fearow</td><td>125</td><td>-0.205359889659</td><td>Not sure</td><td>Paris</td><td>1.51571290235</td></tr>\n",
"<tr><td>23</td><td>Ekans</td><td>302</td><td>65.4992892633</td><td>Yes - very confident</td><td>Santa Cruz</td><td>0.245626974018</td></tr>\n",
"<tr><td>24</td><td>Arbok</td><td>11</td><td>1.11332471245</td><td>Yes</td><td>Santa Cruz</td><td>0.264049562378</td></tr>\n",
"<tr><td>25</td><td>Pikachu</td><td>21</td><td>1.50667846199</td><td>Yes</td><td>Santa Cruz</td><td>0.331619270294</td></tr>\n",
"<tr><td>26</td><td>Raichu</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>27</td><td>Sandshrew</td><td>18</td><td>-1.68503733585</td><td>No</td><td>Santa Cruz</td><td>0.983633274118</td></tr>\n",
"<tr><td>28</td><td>Sandslash</td><td>1</td><td>0.247431359412</td><td>Not sure</td><td>Santa Cruz</td><td>0.213819725922</td></tr>\n",
"<tr><td>29</td><td>Nidoran(F)</td><td>116</td><td>33.2910369348</td><td>Yes - very confident</td><td>Santa Cruz</td><td>0.187012272798</td></tr>\n",
"<tr><td>30</td><td>Nidorina</td><td>4</td><td>2.46585308196</td><td>Yes</td><td>Santa Cruz</td><td>0.0712603744451</td></tr>\n",
"<tr><td>31</td><td>Nidoqueen</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>32</td><td>Nidoran(M)</td><td>118</td><td>72.7472381739</td><td>Yes - very confident</td><td>Santa Cruz</td><td>0.0553092242521</td></tr>\n",
"<tr><td>33</td><td>Nidorino</td><td>15</td><td>12.1778271318</td><td>Yes - very confident</td><td>Santa Cruz</td><td>0.0206747981147</td></tr>\n",
"<tr><td>34</td><td>Nidoking</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>35</td><td>Clefairy</td><td>35</td><td>30.5885858391</td><td>Yes - very confident</td><td>Santa Cruz</td><td>0.00901615056096</td></tr>\n",
"<tr><td>36</td><td>Clefable</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>37</td><td>Vulpix</td><td>8</td><td>-0.402610295119</td><td>Not sure</td><td>Santa Cruz</td><td>0.408150300784</td></tr>\n",
"<tr><td>38</td><td>Ninetales</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>39</td><td>Jigglypuff</td><td>246</td><td>7.22480986532</td><td>Yes - very confident</td><td>Santa Cruz</td><td>0.561495819555</td></tr>\n",
"<tr><td>40</td><td>Wigglytuff</td><td>8</td><td>-1.09963482369</td><td>No</td><td>Santa Cruz</td><td>0.641442415351</td></tr>\n",
"<tr><td>41</td><td>Zubat</td><td>6179</td><td>44.3234137813</td><td>Yes - very confident</td><td>Paris</td><td>1.33035404975</td></tr>\n",
"<tr><td>42</td><td>Golbat</td><td>275</td><td>4.89008939915</td><td>Yes</td><td>Paris</td><td>1.67816623265</td></tr>\n",
"<tr><td>43</td><td>Oddish</td><td>100</td><td>32.6558859916</td><td>Yes - very confident</td><td>Santa Cruz</td><td>0.162701965334</td></tr>\n",
"<tr><td>44</td><td>Gloom</td><td>5</td><td>0.658167702051</td><td>Not sure</td><td>Santa Cruz</td><td>0.213789376158</td></tr>\n",
"<tr><td>45</td><td>Vileplume</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>46</td><td>Paras</td><td>464</td><td>126.646070121</td><td>Yes - very confident</td><td>Santa Cruz</td><td>0.203654016021</td></tr>\n",
"<tr><td>47</td><td>Parasect</td><td>16</td><td>4.35896326762</td><td>Yes</td><td>Santa Cruz</td><td>0.166203381978</td></tr>\n",
"<tr><td>48</td><td>Venonat</td><td>498</td><td>68.3168449623</td><td>Yes - very confident</td><td>Santa Cruz</td><td>0.334495203988</td></tr>\n",
"<tr><td>49</td><td>Venomoth</td><td>13</td><td>0.891927495123</td><td>Not sure</td><td>Santa Cruz</td><td>0.303749702816</td></tr>\n",
"<tr><td>50</td><td>Diglett</td><td>55</td><td>-1.76190041548</td><td>No</td><td>Paris</td><td>1.30078276823</td></tr>\n",
"<tr><td>51</td><td>Dugtrio</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>52</td><td>Meowth</td><td>213</td><td>-0.759509526724</td><td>Not sure</td><td>Santa Cruz</td><td>0.751111574746</td></tr>\n",
"<tr><td>53</td><td>Persian</td><td>1</td><td>-0.198153063264</td><td>Not sure</td><td>Paris</td><td>1.92456763434</td></tr>\n",
"<tr><td>54</td><td>Psyduck</td><td>524</td><td>152.738644547</td><td>Yes - very confident</td><td>Santa Cruz</td><td>0.191416993671</td></tr>\n",
"<tr><td>55</td><td>Golduck</td><td>13</td><td>6.70075780547</td><td>Yes - very confident</td><td>Santa Cruz</td><td>0.0769271155034</td></tr>\n",
"<tr><td>56</td><td>Mankey</td><td>32</td><td>-0.0352089437278</td><td>Not sure</td><td>Santa Cruz</td><td>0.502522529482</td></tr>\n",
"<tr><td>57</td><td>Primeape</td><td>1</td><td>0.247431359412</td><td>Not sure</td><td>Santa Cruz</td><td>0.213819725922</td></tr>\n",
"<tr><td>58</td><td>Growlithe</td><td>51</td><td>16.0955914319</td><td>Yes - very confident</td><td>Santa Cruz</td><td>0.161968747746</td></tr>\n",
"<tr><td>59</td><td>Arcanine</td><td>1</td><td>-0.198153063264</td><td>Not sure</td><td>Paris</td><td>1.92456763434</td></tr>\n",
"<tr><td>60</td><td>Poliwag</td><td>479</td><td>4.35421118601</td><td>Yes</td><td>Santa Cruz</td><td>0.69727721921</td></tr>\n",
"<tr><td>61</td><td>Poliwhirl</td><td>23</td><td>0.42466497275</td><td>Not sure</td><td>Santa Cruz</td><td>0.420083517092</td></tr>\n",
"<tr><td>62</td><td>Poliwrath</td><td>1</td><td>0.247431359412</td><td>Not sure</td><td>Santa Cruz</td><td>0.213819725922</td></tr>\n",
"<tr><td>63</td><td>Abra</td><td>66</td><td>3.07997238044</td><td>Yes</td><td>Santa Cruz</td><td>0.446029127914</td></tr>\n",
"<tr><td>64</td><td>Kadabra</td><td>2</td><td>0.00917409758655</td><td>Not sure</td><td>Paris</td><td>3.20773655561</td></tr>\n",
"<tr><td>65</td><td>Alakazam</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>66</td><td>Machop</td><td>33</td><td>-1.90269631683</td><td>No</td><td>Santa Cruz</td><td>0.8626097984</td></tr>\n",
"<tr><td>67</td><td>Machoke</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>68</td><td>Machamp</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>69</td><td>Bellsprout</td><td>176</td><td>91.8798387125</td><td>Yes - very confident</td><td>Santa Cruz</td><td>0.0833055521442</td></tr>\n",
"<tr><td>70</td><td>Weepinbell</td><td>3</td><td>1.65869536916</td><td>Yes</td><td>Santa Cruz</td><td>0.0916259960846</td></tr>\n",
"<tr><td>71</td><td>Victreebel</td><td>1</td><td>0.247431359412</td><td>Not sure</td><td>Santa Cruz</td><td>0.213819725922</td></tr>\n",
"<tr><td>72</td><td>Tentacool</td><td>86</td><td>15.4912559096</td><td>Yes - very confident</td><td>Santa Cruz</td><td>0.265266520903</td></tr>\n",
"<tr><td>73</td><td>Tentacruel</td><td>7</td><td>2.01076516479</td><td>Yes</td><td>Santa Cruz</td><td>0.147990212382</td></tr>\n",
"<tr><td>74</td><td>Geodude</td><td>8</td><td>2.7439018948</td><td>Yes</td><td>Santa Cruz</td><td>0.128250463249</td></tr>\n",
"<tr><td>75</td><td>Graveler</td><td>1</td><td>-0.198153063264</td><td>Not sure</td><td>Paris</td><td>1.92456763434</td></tr>\n",
"<tr><td>76</td><td>Golem</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>77</td><td>Ponyta</td><td>4</td><td>-0.817056912903</td><td>Not sure</td><td>Paris</td><td>1.49691143541</td></tr>\n",
"<tr><td>78</td><td>Rapidash</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>79</td><td>Slowpoke</td><td>237</td><td>70.7970366081</td><td>Yes - very confident</td><td>Santa Cruz</td><td>0.184334466739</td></tr>\n",
"<tr><td>80</td><td>Slowbro</td><td>5</td><td>0.658167702051</td><td>Not sure</td><td>Santa Cruz</td><td>0.213789376158</td></tr>\n",
"<tr><td>81</td><td>Magnemite</td><td>5</td><td>1.07307903765</td><td>Yes</td><td>Paris</td><td>7.05783783784</td></tr>\n",
"<tr><td>82</td><td>Magneton</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>83</td><td>Farfetch&apos;d</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>84</td><td>Doduo</td><td>60</td><td>22.6999221924</td><td>Yes - very confident</td><td>Santa Cruz</td><td>0.133030765907</td></tr>\n",
"<tr><td>85</td><td>Dodrio</td><td>2</td><td>0.900364678959</td><td>Not sure</td><td>Santa Cruz</td><td>0.128284115036</td></tr>\n",
"<tr><td>86</td><td>Seel</td><td>9</td><td>2.77063230772</td><td>Yes</td><td>Paris</td><td>12.1926938523</td></tr>\n",
"<tr><td>87</td><td>Dewgong</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>88</td><td>Grimer</td><td>8</td><td>-1.293931312</td><td>No</td><td>Paris</td><td>1.00808052951</td></tr>\n",
"<tr><td>89</td><td>Muk</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>90</td><td>Shellder</td><td>9</td><td>2.77063230772</td><td>Yes</td><td>Paris</td><td>12.1926938523</td></tr>\n",
"<tr><td>91</td><td>Cloyster</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>92</td><td>Gastly</td><td>125</td><td>-2.34616781019</td><td>No</td><td>Santa Cruz</td><td>0.868962071624</td></tr>\n",
"<tr><td>93</td><td>Haunter</td><td>5</td><td>-1.0804851292</td><td>No</td><td>Santa Cruz</td><td>0.898092811366</td></tr>\n",
"<tr><td>94</td><td>Gengar</td><td>1</td><td>-0.198153063264</td><td>Not sure</td><td>Paris</td><td>1.92456763434</td></tr>\n",
"<tr><td>95</td><td>Onix</td><td>1</td><td>-0.198153063264</td><td>Not sure</td><td>Paris</td><td>1.92456763434</td></tr>\n",
"<tr><td>96</td><td>Drowzee</td><td>37</td><td>-1.33909471919</td><td>No</td><td>Paris</td><td>1.47873968653</td></tr>\n",
"<tr><td>97</td><td>Hypno</td><td>2</td><td>0.00917409758655</td><td>Not sure</td><td>Paris</td><td>3.20773655561</td></tr>\n",
"<tr><td>98</td><td>Krabby</td><td>422</td><td>2.20773955613</td><td>Yes</td><td>Santa Cruz</td><td>0.723131127238</td></tr>\n",
"<tr><td>99</td><td>Kingler</td><td>13</td><td>-0.945943537631</td><td>Not sure</td><td>Santa Cruz</td><td>0.555859299587</td></tr>\n",
"<tr><td>100</td><td>Voltorb</td><td>12</td><td>1.42535958863</td><td>Yes</td><td>Paris</td><td>4.9199428439</td></tr>\n",
"<tr><td>101</td><td>Electrode</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>102</td><td>Exeggcute</td><td>96</td><td>14.2151141514</td><td>Yes - very confident</td><td>Paris</td><td>4.34749080206</td></tr>\n",
"<tr><td>103</td><td>Exeggutor</td><td>1</td><td>0.247431359412</td><td>Not sure</td><td>Santa Cruz</td><td>0.213819725922</td></tr>\n",
"<tr><td>104</td><td>Cubone</td><td>23</td><td>-1.43885488636</td><td>No</td><td>Santa Cruz</td><td>0.697141580988</td></tr>\n",
"<tr><td>105</td><td>Marowak</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>106</td><td>Hitmonlee</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>107</td><td>Hitmonchan</td><td>1</td><td>-0.198153063264</td><td>Not sure</td><td>Paris</td><td>1.92456763434</td></tr>\n",
"<tr><td>108</td><td>Lickitung</td><td>241</td><td>49.1348691082</td><td>Yes - very confident</td><td>Paris</td><td>5.73474313425</td></tr>\n",
"<tr><td>109</td><td>Koffing</td><td>279</td><td>-2.67253999549</td><td>No</td><td>Paris</td><td>1.11166348137</td></tr>\n",
"<tr><td>110</td><td>Weezing</td><td>11</td><td>-0.336761047482</td><td>Not sure</td><td>Paris</td><td>2.43824528885</td></tr>\n",
"<tr><td>111</td><td>Rhyhorn</td><td>15</td><td>0.735823592323</td><td>Not sure</td><td>Santa Cruz</td><td>0.335885273028</td></tr>\n",
"<tr><td>112</td><td>Rhydon</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>113</td><td>Chansey</td><td>2</td><td>0.900364678959</td><td>Not sure</td><td>Santa Cruz</td><td>0.128284115036</td></tr>\n",
"<tr><td>114</td><td>Tangela</td><td>6</td><td>-0.471367078772</td><td>Not sure</td><td>Paris</td><td>2.35247104247</td></tr>\n",
"<tr><td>115</td><td>Kangaskhan</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>116</td><td>Horsea</td><td>213</td><td>3.05801214629</td><td>Yes</td><td>Santa Cruz</td><td>0.622228771479</td></tr>\n",
"<tr><td>117</td><td>Seadra</td><td>4</td><td>-0.882315095613</td><td>Not sure</td><td>Santa Cruz</td><td>0.641470099988</td></tr>\n",
"<tr><td>118</td><td>Goldeen</td><td>404</td><td>1.81559523891</td><td>Yes</td><td>Santa Cruz</td><td>0.727252270064</td></tr>\n",
"<tr><td>119</td><td>Seaking</td><td>12</td><td>1.70928685305</td><td>Yes</td><td>Santa Cruz</td><td>0.236240647948</td></tr>\n",
"<tr><td>120</td><td>Staryu</td><td>419</td><td>1.0653069731</td><td>Yes</td><td>Santa Cruz</td><td>0.748711507095</td></tr>\n",
"<tr><td>121</td><td>Starmie</td><td>7</td><td>-0.76790130771</td><td>Not sure</td><td>Santa Cruz</td><td>0.498880395336</td></tr>\n",
"<tr><td>122</td><td>Mr. Mime</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>123</td><td>Scyther</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>124</td><td>Jynx</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>125</td><td>Electabuzz</td><td>5</td><td>-0.678715990719</td><td>Not sure</td><td>Paris</td><td>1.92467472298</td></tr>\n",
"<tr><td>126</td><td>Magmar</td><td>21</td><td>5.02871183626</td><td>Yes - very confident</td><td>Paris</td><td>8.77338226772</td></tr>\n",
"<tr><td>127</td><td>Pinsir</td><td>61</td><td>-2.23655732589</td><td>No</td><td>Santa Cruz</td><td>0.918116846646</td></tr>\n",
"<tr><td>128</td><td>Tauros</td><td>2</td><td>0.900364678959</td><td>Not sure</td><td>Santa Cruz</td><td>0.128284115036</td></tr>\n",
"<tr><td>129</td><td>Magikarp</td><td>973</td><td>254.748094013</td><td>Yes - very confident</td><td>Santa Cruz</td><td>0.212172447165</td></tr>\n",
"<tr><td>130</td><td>Gyarados</td><td>2</td><td>0.900364678959</td><td>Not sure</td><td>Santa Cruz</td><td>0.128284115036</td></tr>\n",
"<tr><td>131</td><td>Lapras</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>132</td><td>Ditto</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>133</td><td>Eevee</td><td>568</td><td>145.610862392</td><td>Yes - very confident</td><td>Santa Cruz</td><td>0.215995484611</td></tr>\n",
"<tr><td>134</td><td>Vaporeon</td><td>6</td><td>1.31118799368</td><td>Yes</td><td>Santa Cruz</td><td>0.174908052108</td></tr>\n",
"<tr><td>135</td><td>Jolteon</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>136</td><td>Flareon</td><td>1</td><td>-0.198153063264</td><td>Not sure</td><td>Paris</td><td>1.92456763434</td></tr>\n",
"<tr><td>137</td><td>Porygon</td><td>10</td><td>3.21446920821</td><td>Yes</td><td>Paris</td><td>13.476655725</td></tr>\n",
"<tr><td>138</td><td>Omanyte</td><td>4</td><td>-0.817056912903</td><td>Not sure</td><td>Paris</td><td>1.49691143541</td></tr>\n",
"<tr><td>139</td><td>Omastar</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>140</td><td>Kabuto</td><td>4</td><td>-0.882315095613</td><td>Not sure</td><td>Santa Cruz</td><td>0.641470099988</td></tr>\n",
"<tr><td>141</td><td>Kabutops</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>142</td><td>Aerodactyl</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>143</td><td>Snorlax</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>144</td><td>Articuno</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>145</td><td>Zapdos</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>146</td><td>Moltres</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>147</td><td>Dratini</td><td>59</td><td>13.1119627757</td><td>Yes - very confident</td><td>Santa Cruz</td><td>0.222980544308</td></tr>\n",
"<tr><td>148</td><td>Dragonair</td><td>1</td><td>-0.198153063264</td><td>Not sure</td><td>Paris</td><td>1.92456763434</td></tr>\n",
"<tr><td>149</td><td>Dragonite</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>150</td><td>Mewtwo</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"<tr><td>151</td><td>Mew</td><td>0</td><td>0.0</td><td>Not sure</td><td>Santa Cruz</td><td>0.641497780351</td></tr>\n",
"</table><style>table.dataTable {clear: both; width: auto !important; margin: 0 !important;}\n",
".dataTables_info, .dataTables_length, .dataTables_filter, .dataTables_paginate{\n",
"display: inline-block; margin-right: 1em; }\n",
".paginate_button { margin-right: 5px; }\n",
"</style>\n",
"<script>\n",
"require.config({paths: {\n",
" datatables: 'https://cdn.datatables.net/1.10.9/js/jquery.dataTables.min'\n",
"}});\n",
"require([\"datatables\"], function(){\n",
" console.log(\"$('#table4704613584-30734').dataTable()\");\n",
" $('#table4704613584-30734').dataTable({\n",
" \"order\": [],\n",
" \"iDisplayLength\": 151,\n",
" \"aLengthMenu\": [[151, 10, 25, 50, 100, 500, 1000, -1], [151, 10, 25, 50, 100, 500, 1000, 'All']],\n",
" \"pagingType\": \"full_numbers\"\n",
" });\n",
"});\n",
"</script>\n"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"t.show_in_notebook(show_row_index=False, display_length=N_POKEMON)"
]
}
],
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Python [poke27]",
"language": "python",
"name": "Python [poke27]"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.12"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
This file has been truncated, but you can view the full file.
View raw

(Sorry about that, but we can’t show files that are this big right now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment