Created
August 26, 2019 18:44
-
-
Save AlexAndorra/8a40eb36763a3d5cd9eb4e2aa957b88c to your computer and use it in GitHub Desktop.
Log likelihood not present in sample_stats of ArviZ compare function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "cells": [ | |
| { | |
| "cell_type": "code", | |
| "execution_count": 1, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "%matplotlib inline\n", | |
| "\n", | |
| "import arviz as az\n", | |
| "import matplotlib.pyplot as plt\n", | |
| "import numpy as np\n", | |
| "import pandas as pd\n", | |
| "import pymc3 as pm\n", | |
| "import scipy as sp\n", | |
| "import seaborn as sns\n", | |
| "import warnings\n", | |
| "\n", | |
| "from theano import tensor as tt\n", | |
| "\n", | |
| "warnings.simplefilter(action='ignore', category=FutureWarning)\n", | |
| "\n", | |
| "sns.set(context='notebook', font_scale=1.2, rc={'figure.figsize': (12, 5)})\n", | |
| "plt.style.use(['seaborn-colorblind', 'seaborn-darkgrid'])\n", | |
| "\n", | |
| "RANDOM_SEED = 8927\n", | |
| "np.random.seed(286)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "metadata": {}, | |
| "source": [ | |
| "### 14M2.\n", | |
| "*In earlier chapters, we threw away cases from the primary milk data, so we could use the neocortex variable. Now repeat the WAIC model comparison example from chapter 6, but use imputation on the neocortex variable, so that you can include all of the cases in the original data. The simplest form of imputation is acceptable. How are the model comparison results affected by being able to include all of the cases?*" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 3, | |
| "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>clade</th>\n", | |
| " <th>species</th>\n", | |
| " <th>kcal.per.g</th>\n", | |
| " <th>perc.fat</th>\n", | |
| " <th>perc.protein</th>\n", | |
| " <th>perc.lactose</th>\n", | |
| " <th>mass</th>\n", | |
| " <th>neocortex.perc</th>\n", | |
| " <th>neocortex.prop</th>\n", | |
| " <th>logmass</th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th>0</th>\n", | |
| " <td>Strepsirrhine</td>\n", | |
| " <td>Eulemur fulvus</td>\n", | |
| " <td>0.49</td>\n", | |
| " <td>16.60</td>\n", | |
| " <td>15.42</td>\n", | |
| " <td>67.98</td>\n", | |
| " <td>1.95</td>\n", | |
| " <td>55.16</td>\n", | |
| " <td>0.5516</td>\n", | |
| " <td>0.667829</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1</th>\n", | |
| " <td>Strepsirrhine</td>\n", | |
| " <td>E macaco</td>\n", | |
| " <td>0.51</td>\n", | |
| " <td>19.27</td>\n", | |
| " <td>16.91</td>\n", | |
| " <td>63.82</td>\n", | |
| " <td>2.09</td>\n", | |
| " <td>NaN</td>\n", | |
| " <td>NaN</td>\n", | |
| " <td>0.737164</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2</th>\n", | |
| " <td>Strepsirrhine</td>\n", | |
| " <td>E mongoz</td>\n", | |
| " <td>0.46</td>\n", | |
| " <td>14.11</td>\n", | |
| " <td>16.85</td>\n", | |
| " <td>69.04</td>\n", | |
| " <td>2.51</td>\n", | |
| " <td>NaN</td>\n", | |
| " <td>NaN</td>\n", | |
| " <td>0.920283</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>3</th>\n", | |
| " <td>Strepsirrhine</td>\n", | |
| " <td>E rubriventer</td>\n", | |
| " <td>0.48</td>\n", | |
| " <td>14.91</td>\n", | |
| " <td>13.18</td>\n", | |
| " <td>71.91</td>\n", | |
| " <td>1.62</td>\n", | |
| " <td>NaN</td>\n", | |
| " <td>NaN</td>\n", | |
| " <td>0.482426</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>4</th>\n", | |
| " <td>Strepsirrhine</td>\n", | |
| " <td>Lemur catta</td>\n", | |
| " <td>0.60</td>\n", | |
| " <td>27.28</td>\n", | |
| " <td>19.50</td>\n", | |
| " <td>53.22</td>\n", | |
| " <td>2.19</td>\n", | |
| " <td>NaN</td>\n", | |
| " <td>NaN</td>\n", | |
| " <td>0.783902</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "</div>" | |
| ], | |
| "text/plain": [ | |
| " clade species kcal.per.g perc.fat perc.protein \\\n", | |
| "0 Strepsirrhine Eulemur fulvus 0.49 16.60 15.42 \n", | |
| "1 Strepsirrhine E macaco 0.51 19.27 16.91 \n", | |
| "2 Strepsirrhine E mongoz 0.46 14.11 16.85 \n", | |
| "3 Strepsirrhine E rubriventer 0.48 14.91 13.18 \n", | |
| "4 Strepsirrhine Lemur catta 0.60 27.28 19.50 \n", | |
| "\n", | |
| " perc.lactose mass neocortex.perc neocortex.prop logmass \n", | |
| "0 67.98 1.95 55.16 0.5516 0.667829 \n", | |
| "1 63.82 2.09 NaN NaN 0.737164 \n", | |
| "2 69.04 2.51 NaN NaN 0.920283 \n", | |
| "3 71.91 1.62 NaN NaN 0.482426 \n", | |
| "4 53.22 2.19 NaN NaN 0.783902 " | |
| ] | |
| }, | |
| "execution_count": 3, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "d = pd.read_csv('../Data/milk.csv', ';')\n", | |
| "d.loc[:,'neocortex.prop'] = d['neocortex.perc'] / 100\n", | |
| "d.loc[:,'logmass'] = np.log(d['mass'])\n", | |
| "d.head()" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 4, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "# prep data\n", | |
| "neocortex = d['neocortex.prop'].values\n", | |
| "logmass = d['logmass'].values\n", | |
| "kcal = d['kcal.per.g'].values\n", | |
| "\n", | |
| "# masked array for missing values\n", | |
| "mask = np.isfinite(neocortex)\n", | |
| "neocortex[~mask] = -999\n", | |
| "neocortex = np.ma.masked_values(neocortex, value=-999)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 5, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stderr", | |
| "output_type": "stream", | |
| "text": [ | |
| "/anaconda/envs/stat-rethink-pymc3/lib/python3.7/site-packages/pymc3/model.py:1331: UserWarning: Data in neocortex contains missing values and will be automatically imputed from the sampling distribution.\n", | |
| " warnings.warn(impute_message, UserWarning)\n", | |
| "Auto-assigning NUTS sampler...\n", | |
| "Initializing NUTS using jitter+adapt_diag...\n", | |
| "Multiprocess sampling (2 chains in 2 jobs)\n", | |
| "NUTS: [neocortex_missing, sigma_N, mu_N, sigma, a]\n", | |
| "Sampling 2 chains: 100%|██████████| 4000/4000 [00:13<00:00, 298.06draws/s]\n", | |
| "/anaconda/envs/stat-rethink-pymc3/lib/python3.7/site-packages/pymc3/model.py:1331: UserWarning: Data in neocortex contains missing values and will be automatically imputed from the sampling distribution.\n", | |
| " warnings.warn(impute_message, UserWarning)\n", | |
| "Auto-assigning NUTS sampler...\n", | |
| "Initializing NUTS using jitter+adapt_diag...\n", | |
| "Multiprocess sampling (2 chains in 2 jobs)\n", | |
| "NUTS: [neocortex_missing, sigma_N, mu_N, sigma, bn, a]\n", | |
| "Sampling 2 chains: 100%|██████████| 6000/6000 [01:38<00:00, 60.79draws/s]\n", | |
| "/anaconda/envs/stat-rethink-pymc3/lib/python3.7/site-packages/pymc3/model.py:1331: UserWarning: Data in neocortex contains missing values and will be automatically imputed from the sampling distribution.\n", | |
| " warnings.warn(impute_message, UserWarning)\n", | |
| "Auto-assigning NUTS sampler...\n", | |
| "Initializing NUTS using jitter+adapt_diag...\n", | |
| "Multiprocess sampling (2 chains in 2 jobs)\n", | |
| "NUTS: [neocortex_missing, sigma_N, mu_N, sigma, bm, a]\n", | |
| "Sampling 2 chains: 100%|██████████| 4000/4000 [00:18<00:00, 219.05draws/s]\n", | |
| "/anaconda/envs/stat-rethink-pymc3/lib/python3.7/site-packages/pymc3/model.py:1331: UserWarning: Data in neocortex contains missing values and will be automatically imputed from the sampling distribution.\n", | |
| " warnings.warn(impute_message, UserWarning)\n", | |
| "Auto-assigning NUTS sampler...\n", | |
| "Initializing NUTS using jitter+adapt_diag...\n", | |
| "Multiprocess sampling (2 chains in 2 jobs)\n", | |
| "NUTS: [neocortex_missing, sigma_N, mu_N, sigma, bm, bn, a]\n", | |
| "Sampling 2 chains: 100%|██████████| 6000/6000 [03:10<00:00, 36.81draws/s]\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "with pm.Model() as m6_11_full:\n", | |
| " a = pm.Normal('a', mu=0., sd=10.)\n", | |
| " sigma = pm.Exponential('sigma', 1.)\n", | |
| " \n", | |
| " # need neocortex even though not used, because pymc can't compare models with different numbers of observed RVs\n", | |
| " mu_N = pm.Normal('mu_N', .5, 1.)\n", | |
| " sigma_N = pm.Exponential('sigma_N', 1.)\n", | |
| " neocortex_ = pm.Normal('neocortex', mu_N, sigma_N, observed=neocortex)\n", | |
| " \n", | |
| " mu = a\n", | |
| " \n", | |
| " kcal_ = pm.Normal('kcal', mu, sigma, observed=kcal)\n", | |
| " \n", | |
| " trace_m6_11_full = pm.sample(1000, tune=1000, random_seed=RANDOM_SEED, cores=2)\n", | |
| " \n", | |
| "with pm.Model() as m6_12_full:\n", | |
| " a = pm.Normal('a', mu=0., sd=10.)\n", | |
| " bn = pm.Normal('bn', mu=0., sd=1.)\n", | |
| " sigma = pm.Exponential('sigma', 1.)\n", | |
| " \n", | |
| " mu_N = pm.Normal('mu_N', .5, 1.)\n", | |
| " sigma_N = pm.Exponential('sigma_N', 1.)\n", | |
| " neocortex_ = pm.Normal('neocortex', mu_N, sigma_N, observed=neocortex)\n", | |
| " \n", | |
| " mu = a + bn*neocortex_\n", | |
| " \n", | |
| " kcal_ = pm.Normal('kcal', mu, sigma, observed=kcal)\n", | |
| " \n", | |
| " trace_m6_12_full = pm.sample(1000, tune=2000, random_seed=RANDOM_SEED, cores=2, nuts_kwargs={\"target_accept\": .9})\n", | |
| " \n", | |
| "with pm.Model() as m6_13_full:\n", | |
| " a = pm.Normal('a', mu=0., sd=10.)\n", | |
| " bm = pm.Normal('bm', mu=0., sd=1.)\n", | |
| " sigma = pm.Exponential('sigma', 1.)\n", | |
| " \n", | |
| " # need neocortex even though not used, because pymc can't compare models with different numbers of observed RVs\n", | |
| " mu_N = pm.Normal('mu_N', .5, 1.)\n", | |
| " sigma_N = pm.Exponential('sigma_N', 1.)\n", | |
| " neocortex_ = pm.Normal('neocortex', mu_N, sigma_N, observed=neocortex)\n", | |
| " \n", | |
| " mu = a + bm*logmass\n", | |
| " \n", | |
| " kcal_ = pm.Normal('kcal', mu, sigma, observed=kcal)\n", | |
| " \n", | |
| " trace_m6_13_full = pm.sample(1000, tune=1000, random_seed=RANDOM_SEED, cores=2)\n", | |
| " \n", | |
| "with pm.Model() as m6_14_full:\n", | |
| " a = pm.Normal('a', mu=0., sd=10.)\n", | |
| " bn = pm.Normal('bn', mu=0., sd=1.)\n", | |
| " bm = pm.Normal('bm', mu=0., sd=1.)\n", | |
| " sigma = pm.Exponential('sigma', 1.)\n", | |
| " \n", | |
| " mu_N = pm.Normal('mu_N', .5, 1.)\n", | |
| " sigma_N = pm.Exponential('sigma_N', 1.)\n", | |
| " neocortex_ = pm.Normal('neocortex', mu_N, sigma_N, observed=neocortex)\n", | |
| " \n", | |
| " mu = a + bn*neocortex_ + bm*logmass\n", | |
| " \n", | |
| " kcal_ = pm.Normal('kcal', mu, sigma, observed=kcal)\n", | |
| " \n", | |
| " trace_m6_14_full = pm.sample(1000, tune=2000, random_seed=RANDOM_SEED, cores=2, nuts_kwargs={\"target_accept\": .9})" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 6, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "ename": "TypeError", | |
| "evalue": "Data must include log_likelihood in sample_stats", | |
| "output_type": "error", | |
| "traceback": [ | |
| "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", | |
| "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", | |
| "\u001b[0;32m<ipython-input-6-07017a4325b9>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0;34m'm6_12_full'\u001b[0m \u001b[0;34m:\u001b[0m \u001b[0mtrace_m6_12_full\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;34m'm6_13_full'\u001b[0m \u001b[0;34m:\u001b[0m \u001b[0mtrace_m6_13_full\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 4\u001b[0;31m 'm6_14_full' : trace_m6_14_full})\n\u001b[0m", | |
| "\u001b[0;32m/anaconda/envs/stat-rethink-pymc3/lib/python3.7/site-packages/arviz/stats/stats.py\u001b[0m in \u001b[0;36mcompare\u001b[0;34m(dataset_dict, ic, method, b_samples, alpha, seed, scale)\u001b[0m\n\u001b[1;32m 161\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdataset\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mdataset_dict\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 162\u001b[0m \u001b[0mnames\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 163\u001b[0;31m \u001b[0mics\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mics\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mic_func\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdataset\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpointwise\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mscale\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mscale\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 164\u001b[0m \u001b[0mics\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mindex\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnames\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 165\u001b[0m \u001b[0mics\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msort_values\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mby\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mic\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0minplace\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mascending\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mascending\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", | |
| "\u001b[0;32m/anaconda/envs/stat-rethink-pymc3/lib/python3.7/site-packages/arviz/stats/stats.py\u001b[0m in \u001b[0;36mwaic\u001b[0;34m(data, pointwise, scale)\u001b[0m\n\u001b[1;32m 1042\u001b[0m )\n\u001b[1;32m 1043\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;34m\"log_likelihood\"\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32min\u001b[0m \u001b[0minference_data\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msample_stats\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1044\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Data must include log_likelihood in sample_stats\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1045\u001b[0m \u001b[0mlog_likelihood\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0minference_data\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msample_stats\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlog_likelihood\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1046\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", | |
| "\u001b[0;31mTypeError\u001b[0m: Data must include log_likelihood in sample_stats" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "az.compare({'m6_11_full' : trace_m6_11_full,\n", | |
| " 'm6_12_full' : trace_m6_12_full,\n", | |
| " 'm6_13_full' : trace_m6_13_full,\n", | |
| " 'm6_14_full' : trace_m6_14_full})" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 7, | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "name": "stderr", | |
| "output_type": "stream", | |
| "text": [ | |
| "/anaconda/envs/stat-rethink-pymc3/lib/python3.7/site-packages/pymc3/stats.py:219: UserWarning: For one or more samples the posterior variance of the\n", | |
| " log predictive densities exceeds 0.4. This could be indication of\n", | |
| " WAIC starting to fail see http://arxiv.org/abs/1507.04544 for details\n", | |
| " \n", | |
| " \"\"\")\n", | |
| "/anaconda/envs/stat-rethink-pymc3/lib/python3.7/site-packages/pymc3/stats.py:219: UserWarning: For one or more samples the posterior variance of the\n", | |
| " log predictive densities exceeds 0.4. This could be indication of\n", | |
| " WAIC starting to fail see http://arxiv.org/abs/1507.04544 for details\n", | |
| " \n", | |
| " \"\"\")\n", | |
| "/anaconda/envs/stat-rethink-pymc3/lib/python3.7/site-packages/pymc3/stats.py:219: UserWarning: For one or more samples the posterior variance of the\n", | |
| " log predictive densities exceeds 0.4. This could be indication of\n", | |
| " WAIC starting to fail see http://arxiv.org/abs/1507.04544 for details\n", | |
| " \n", | |
| " \"\"\")\n", | |
| "/anaconda/envs/stat-rethink-pymc3/lib/python3.7/site-packages/pymc3/stats.py:219: UserWarning: For one or more samples the posterior variance of the\n", | |
| " log predictive densities exceeds 0.4. This could be indication of\n", | |
| " WAIC starting to fail see http://arxiv.org/abs/1507.04544 for details\n", | |
| " \n", | |
| " \"\"\")\n" | |
| ] | |
| }, | |
| { | |
| "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>WAIC</th>\n", | |
| " <th>pWAIC</th>\n", | |
| " <th>dWAIC</th>\n", | |
| " <th>weight</th>\n", | |
| " <th>SE</th>\n", | |
| " <th>dSE</th>\n", | |
| " <th>var_warn</th>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>model</th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " <th></th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th>m6_14_full</th>\n", | |
| " <td>-73.05</td>\n", | |
| " <td>6.27</td>\n", | |
| " <td>0</td>\n", | |
| " <td>1</td>\n", | |
| " <td>9.3</td>\n", | |
| " <td>0</td>\n", | |
| " <td>1</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>m6_13_full</th>\n", | |
| " <td>-66.73</td>\n", | |
| " <td>3.78</td>\n", | |
| " <td>6.31</td>\n", | |
| " <td>0</td>\n", | |
| " <td>9.63</td>\n", | |
| " <td>2.18</td>\n", | |
| " <td>1</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>m6_11_full</th>\n", | |
| " <td>-65.37</td>\n", | |
| " <td>3.04</td>\n", | |
| " <td>7.67</td>\n", | |
| " <td>0</td>\n", | |
| " <td>9.53</td>\n", | |
| " <td>3.94</td>\n", | |
| " <td>1</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>m6_12_full</th>\n", | |
| " <td>-64.5</td>\n", | |
| " <td>3.91</td>\n", | |
| " <td>8.55</td>\n", | |
| " <td>0</td>\n", | |
| " <td>9.52</td>\n", | |
| " <td>4.17</td>\n", | |
| " <td>1</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "</div>" | |
| ], | |
| "text/plain": [ | |
| " WAIC pWAIC dWAIC weight SE dSE var_warn\n", | |
| "model \n", | |
| "m6_14_full -73.05 6.27 0 1 9.3 0 1\n", | |
| "m6_13_full -66.73 3.78 6.31 0 9.63 2.18 1\n", | |
| "m6_11_full -65.37 3.04 7.67 0 9.53 3.94 1\n", | |
| "m6_12_full -64.5 3.91 8.55 0 9.52 4.17 1" | |
| ] | |
| }, | |
| "execution_count": 7, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "comp_df_full = pm.compare({m6_11_full : trace_m6_11_full, \n", | |
| " m6_12_full : trace_m6_12_full, \n", | |
| " m6_13_full : trace_m6_13_full, \n", | |
| " m6_14_full : trace_m6_14_full})\n", | |
| "\n", | |
| "comp_df_full.loc[:,'model'] = pd.Series(['m6_11_full', 'm6_12_full', 'm6_13_full', 'm6_14_full'])\n", | |
| "comp_df_full = comp_df_full.set_index('model')\n", | |
| "comp_df_full" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [] | |
| } | |
| ], | |
| "metadata": { | |
| "kernelspec": { | |
| "display_name": "stat-rethink-pymc3", | |
| "language": "python", | |
| "name": "stat-rethink-pymc3" | |
| }, | |
| "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.3" | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 2 | |
| } |
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "clade";"species";"kcal.per.g";"perc.fat";"perc.protein";"perc.lactose";"mass";"neocortex.perc" | |
| "Strepsirrhine";"Eulemur fulvus";0.49;16.6;15.42;67.98;1.95;55.16 | |
| "Strepsirrhine";"E macaco";0.51;19.27;16.91;63.82;2.09;NA | |
| "Strepsirrhine";"E mongoz";0.46;14.11;16.85;69.04;2.51;NA | |
| "Strepsirrhine";"E rubriventer";0.48;14.91;13.18;71.91;1.62;NA | |
| "Strepsirrhine";"Lemur catta";0.6;27.28;19.5;53.22;2.19;NA | |
| "New World Monkey";"Alouatta seniculus";0.47;21.22;23.58;55.2;5.25;64.54 | |
| "New World Monkey";"A palliata";0.56;29.66;23.46;46.88;5.37;64.54 | |
| "New World Monkey";"Cebus apella";0.89;53.41;15.8;30.79;2.51;67.64 | |
| "New World Monkey";"Saimiri boliviensis";0.91;46.08;23.34;30.58;0.71;NA | |
| "New World Monkey";"S sciureus";0.92;50.58;22.33;27.09;0.68;68.85 | |
| "New World Monkey";"Cebuella pygmaea";0.8;41.35;20.85;37.8;0.12;58.85 | |
| "New World Monkey";"Callimico goeldii";0.46;3.93;25.3;70.77;0.47;61.69 | |
| "New World Monkey";"Callithrix jacchus";0.71;38.38;20.09;41.53;0.32;60.32 | |
| "New World Monkey";"Leontopithecus rosalia";0.71;36.9;21.27;41.83;0.6;NA | |
| "Old World Monkey";"Chlorocebus pygerythrus";0.73;39.17;14.65;46.18;3.47;NA | |
| "Old World Monkey";"Miopithecus talpoin";0.68;40.15;18.08;41.77;1.55;69.97 | |
| "Old World Monkey";"M fuscata";0.72;53.05;13;33.95;7.08;NA | |
| "Old World Monkey";"M mulatta";0.97;55.51;13.17;31.32;3.24;70.41 | |
| "Old World Monkey";"M sinica";0.79;48.9;13.91;37.19;7.94;NA | |
| "Old World Monkey";"Papio spp";0.84;54.31;10.97;34.72;12.3;73.4 | |
| "Ape";"Nomascus concolor";0.48;15.96;12.52;71.52;7.59;NA | |
| "Ape";"Hylobates lar";0.62;34.51;12.57;52.92;5.37;67.53 | |
| "Ape";"Symphalangus syndactylus";0.51;26.42;13.46;60.12;10.72;NA | |
| "Ape";"Pongo pygmaeus";0.54;37.78;7.37;54.85;35.48;71.26 | |
| "Ape";"Gorilla gorilla gorilla";0.49;27.18;16.29;56.53;79.43;72.6 | |
| "Ape";"G gorilla beringei";0.53;30.59;20.77;48.64;97.72;NA | |
| "Ape";"Pan paniscus";0.48;21.18;11.68;67.14;40.74;70.24 | |
| "Ape";"P troglodytes";0.55;36.84;9.54;53.62;33.11;76.3 | |
| "Ape";"Homo sapiens";0.71;50.49;9.84;39.67;54.95;75.49 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment