Commit 52e91521 authored by Chanelle Lee's avatar Chanelle Lee
Browse files

Final additions before showing Jonathan

parent 9602c60f
......@@ -353,7 +353,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 51,
"metadata": {},
"outputs": [],
"source": [
......@@ -994,7 +994,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 52,
"metadata": {},
"outputs": [],
"source": [
......@@ -1003,7 +1003,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 53,
"metadata": {},
"outputs": [
{
......@@ -1015,7 +1015,7 @@
" 0.028578442773621412]"
]
},
"execution_count": 25,
"execution_count": 53,
"metadata": {},
"output_type": "execute_result"
}
......@@ -1027,7 +1027,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 54,
"metadata": {},
"outputs": [],
"source": [
......@@ -1044,7 +1044,7 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 55,
"metadata": {},
"outputs": [],
"source": [
......@@ -1058,7 +1058,7 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 56,
"metadata": {},
"outputs": [
{
......@@ -1134,7 +1134,7 @@
"35 0.175175 0.250550 0.089228 0.021781 0.003561"
]
},
"execution_count": 28,
"execution_count": 56,
"metadata": {},
"output_type": "execute_result"
}
......@@ -1145,16 +1145,16 @@
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": 57,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.lines.Line2D at 0x22e108f63c8>"
"<matplotlib.lines.Line2D at 0x22e11174400>"
]
},
"execution_count": 29,
"execution_count": 57,
"metadata": {},
"output_type": "execute_result"
},
......@@ -1184,7 +1184,7 @@
},
{
"cell_type": "code",
"execution_count": 45,
"execution_count": 58,
"metadata": {},
"outputs": [],
"source": [
......@@ -1193,7 +1193,7 @@
},
{
"cell_type": "code",
"execution_count": 46,
"execution_count": 59,
"metadata": {},
"outputs": [],
"source": [
......@@ -1202,7 +1202,7 @@
},
{
"cell_type": "code",
"execution_count": 47,
"execution_count": 60,
"metadata": {},
"outputs": [],
"source": [
......@@ -1219,45 +1219,12 @@
},
{
"cell_type": "code",
"execution_count": 48,
"execution_count": 50,
"metadata": {},
"outputs": [
{
"ename": "KeyError",
"evalue": "'chance'",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mKeyError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m~\\Anaconda2\\envs\\Py3\\lib\\site-packages\\pandas\\core\\indexes\\base.py\u001b[0m in \u001b[0;36mget_loc\u001b[1;34m(self, key, method, tolerance)\u001b[0m\n\u001b[0;32m 2601\u001b[0m \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 2602\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 2603\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mpandas\\_libs\\index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[1;34m()\u001b[0m\n",
"\u001b[1;32mpandas\\_libs\\index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[1;34m()\u001b[0m\n",
"\u001b[1;32mpandas\\_libs\\hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[1;34m()\u001b[0m\n",
"\u001b[1;32mpandas\\_libs\\hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[1;34m()\u001b[0m\n",
"\u001b[1;31mKeyError\u001b[0m: 'chance'",
"\nDuring handling of the above exception, another exception occurred:\n",
"\u001b[1;31mKeyError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-48-649bf0486daa>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[0msigmas\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mset\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtestParams_DF\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'sigma'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mchances\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[0mdf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mloc\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mdf\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'sigma'\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m==\u001b[0m \u001b[0msigma\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'chance'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mitem\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0msigma\u001b[0m \u001b[1;32min\u001b[0m \u001b[0msigmas\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 3\u001b[0m testParams_DF = testParams_DF.append([{'sigma': sigma, 'alpha': 0.1, 'chance': chances[i], 'note': 'control'}\n\u001b[0;32m 4\u001b[0m for i, sigma in enumerate(sigmas)])\n",
"\u001b[1;32m<ipython-input-48-649bf0486daa>\u001b[0m in \u001b[0;36m<listcomp>\u001b[1;34m(.0)\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[0msigmas\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mset\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtestParams_DF\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'sigma'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mchances\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[0mdf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mloc\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mdf\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'sigma'\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m==\u001b[0m \u001b[0msigma\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'chance'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mitem\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0msigma\u001b[0m \u001b[1;32min\u001b[0m \u001b[0msigmas\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 3\u001b[0m testParams_DF = testParams_DF.append([{'sigma': sigma, 'alpha': 0.1, 'chance': chances[i], 'note': 'control'}\n\u001b[0;32m 4\u001b[0m for i, sigma in enumerate(sigmas)])\n",
"\u001b[1;32m~\\Anaconda2\\envs\\Py3\\lib\\site-packages\\pandas\\core\\indexing.py\u001b[0m in \u001b[0;36m__getitem__\u001b[1;34m(self, key)\u001b[0m\n\u001b[0;32m 1492\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mKeyError\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mIndexError\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mAttributeError\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1493\u001b[0m \u001b[1;32mpass\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1494\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_getitem_tuple\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 1495\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1496\u001b[0m \u001b[1;31m# we by definition only have the 0th axis\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32m~\\Anaconda2\\envs\\Py3\\lib\\site-packages\\pandas\\core\\indexing.py\u001b[0m in \u001b[0;36m_getitem_tuple\u001b[1;34m(self, tup)\u001b[0m\n\u001b[0;32m 866\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0m_getitem_tuple\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtup\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 867\u001b[0m \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 868\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_getitem_lowerdim\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtup\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 869\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[0mIndexingError\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 870\u001b[0m \u001b[1;32mpass\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32m~\\Anaconda2\\envs\\Py3\\lib\\site-packages\\pandas\\core\\indexing.py\u001b[0m in \u001b[0;36m_getitem_lowerdim\u001b[1;34m(self, tup)\u001b[0m\n\u001b[0;32m 986\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mi\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkey\u001b[0m \u001b[1;32min\u001b[0m \u001b[0menumerate\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtup\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 987\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mis_label_like\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mor\u001b[0m \u001b[0misinstance\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtuple\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 988\u001b[1;33m \u001b[0msection\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_getitem_axis\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 989\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 990\u001b[0m \u001b[1;31m# we have yielded a scalar ?\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32m~\\Anaconda2\\envs\\Py3\\lib\\site-packages\\pandas\\core\\indexing.py\u001b[0m in \u001b[0;36m_getitem_axis\u001b[1;34m(self, key, axis)\u001b[0m\n\u001b[0;32m 1911\u001b[0m \u001b[1;31m# fall thru to straight lookup\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1912\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_validate_key\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1913\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_get_label\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0maxis\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 1914\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1915\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32m~\\Anaconda2\\envs\\Py3\\lib\\site-packages\\pandas\\core\\indexing.py\u001b[0m in \u001b[0;36m_get_label\u001b[1;34m(self, label, axis)\u001b[0m\n\u001b[0;32m 139\u001b[0m \u001b[1;32mraise\u001b[0m \u001b[0mIndexingError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'no slices here, handle elsewhere'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 140\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 141\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mobj\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_xs\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mlabel\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0maxis\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 142\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 143\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0m_get_loc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkey\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32m~\\Anaconda2\\envs\\Py3\\lib\\site-packages\\pandas\\core\\generic.py\u001b[0m in \u001b[0;36mxs\u001b[1;34m(self, key, axis, level, drop_level)\u001b[0m\n\u001b[0;32m 3564\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 3565\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0maxis\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 3566\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 3567\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 3568\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_consolidate_inplace\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32m~\\Anaconda2\\envs\\Py3\\lib\\site-packages\\pandas\\core\\frame.py\u001b[0m in \u001b[0;36m__getitem__\u001b[1;34m(self, key)\u001b[0m\n\u001b[0;32m 2915\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcolumns\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mnlevels\u001b[0m \u001b[1;33m>\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2916\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_getitem_multilevel\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 2917\u001b[1;33m \u001b[0mindexer\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcolumns\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 2918\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mis_integer\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mindexer\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2919\u001b[0m \u001b[0mindexer\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[0mindexer\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32m~\\Anaconda2\\envs\\Py3\\lib\\site-packages\\pandas\\core\\indexes\\base.py\u001b[0m in \u001b[0;36mget_loc\u001b[1;34m(self, key, method, tolerance)\u001b[0m\n\u001b[0;32m 2602\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2603\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 2604\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_maybe_cast_indexer\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 2605\u001b[0m \u001b[0mindexer\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_indexer\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mmethod\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mmethod\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtolerance\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mtolerance\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2606\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mindexer\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mndim\u001b[0m \u001b[1;33m>\u001b[0m \u001b[1;36m1\u001b[0m \u001b[1;32mor\u001b[0m \u001b[0mindexer\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msize\u001b[0m \u001b[1;33m>\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mpandas\\_libs\\index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[1;34m()\u001b[0m\n",
"\u001b[1;32mpandas\\_libs\\index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[1;34m()\u001b[0m\n",
"\u001b[1;32mpandas\\_libs\\hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[1;34m()\u001b[0m\n",
"\u001b[1;32mpandas\\_libs\\hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[1;34m()\u001b[0m\n",
"\u001b[1;31mKeyError\u001b[0m: 'chance'"
]
}
],
"outputs": [],
"source": [
"sigmas = set(testParams_DF['sigma'])\n",
"chances = [df.loc[df['sigma'] == sigma, 'chance'].item() for sigma in sigmas]\n",
"chances = [testParams_DF.loc[testParams_DF['sigma'] == sigma, 'chance'].iloc[0] for sigma in sigmas]\n",
"testParams_DF = testParams_DF.append([{'sigma': sigma, 'alpha': 0.1, 'chance': chances[i], 'note': 'control'}\n",
" for i, sigma in enumerate(sigmas)])"
]
......@@ -1442,9 +1409,8 @@
"outputs": [],
"source": [
"def convert_paramSetNum(filePath):\n",
" df = pd.read_csv(filePath, names=['time', 'paramSet', 'simNum', 'timestep', 'agent', 'iteration', 'option', 'belief'])\n",
" df['paramSet'] +=1\n",
" df.to_csv(filePath)"
" df = pd.read_csv(filePath)\n",
" df.to_csv(filePath, header=False, index=False)"
]
},
{
......@@ -1484,7 +1450,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.2"
"version": "3.7.1"
}
},
"nbformat": 4,
......
%% Cell type:code id: tags:
``` python
import numpy as np
import scipy
import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
```
%% Cell type:markdown id: tags:
# Analysis of the probability of confusing qualities for different values of sigma
%% Cell type:markdown id: tags:
First need the pdf and cdf of the normal distributions which will represent the noise around each of the quality values
%% Cell type:code id: tags:
``` python
def f(x, mu, s):
return scipy.stats.norm.pdf(x, loc=mu, scale=s)
```
%% Cell type:code id: tags:
``` python
def F(x, mu, s):
return scipy.stats.norm.cdf(x, loc=mu, scale=s)
```
%% Cell type:markdown id: tags:
Qualities are set in the interval (0,1) and equally spaced
%% Cell type:code id: tags:
``` python
n = 5
qualities = {i: i/(n+1) for i in range(1, (n+1))}
```
%% Cell type:code id: tags:
``` python
def integrand(x, i, j, s):
return f(x, qualities[i], s)*F(x, qualities[j], s)
def probConfusion(i, j, s):
return scipy.integrate.quad(integrand, -np.inf, np.inf, args=(i, j, s))
```
%% Cell type:code id: tags:
``` python
s0 = 0.0000001
sf = 100
ss = np.linspace(s0, sf, 1000)
confusions = [probConfusion(1, 2, s)[0] for s in ss]
```
%% Cell type:code id: tags:
``` python
plt.plot(ss, confusions)
```
%%%% Output: execute_result
[<matplotlib.lines.Line2D at 0x22e0f4ad240>]
%%%% Output: display_data
[Hidden Image Output]
%% Cell type:code id: tags:
``` python
ss = np.linspace(0.0000001, 10, 1000)
confusions = [probConfusion(1, 2, s)[0] for s in ss]
plt.plot(ss, confusions)
```
%%%% Output: execute_result
[<matplotlib.lines.Line2D at 0x22e0f548f28>]
%%%% Output: display_data
[Hidden Image Output]
%% Cell type:code id: tags:
``` python
ss = np.linspace(0.0000001, 10, 1000)
confusions = [[probConfusion(1, j, s)[0] for s in ss] for j in [2, 3, 4, 5]]
for confusion in confusions:
plt.plot(ss, confusion)
```
%%%% Output: display_data
[Hidden Image Output]
%% Cell type:code id: tags:
``` python
ss = np.linspace(0.0000001, 10, 1000)
confusions = [[probConfusion(1, j, s)[0] for s in ss] for j in [2, 3, 4, 5]]
for confusion in confusions:
plt.plot(ss, confusion)
```
%%%% Output: display_data
[Hidden Image Output]
%% Cell type:code id: tags:
``` python
ss = np.linspace(0.0000001, 5, 1000)
confusions = [[probConfusion(1, j, s)[0] for s in ss] for j in [2, 3, 4, 5]]
for confusion in confusions:
plt.plot(ss, confusion)
```
%%%% Output: display_data
[Hidden Image Output]
%% Cell type:code id: tags:
``` python
d = {'sigma':ss, **{'q{}'.format(j): confusions[i] for i, j in enumerate([2, 3, 4, 5])}}
```
%% Cell type:code id: tags:
``` python
df = pd.DataFrame(data=d)
```
%% Cell type:code id: tags:
``` python
df.head()
```
%%%% Output: execute_result
sigma q2 q3 q4 q5
0 1.000000e-07 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00
1 5.005105e-03 4.104751e-122 0.000000e+00 0.000000e+00 0.000000e+00
2 1.001011e-02 1.051201e-31 3.577518e-122 7.451264e-274 0.000000e+00
3 1.501511e-02 5.734691e-15 2.733803e-55 9.343211e-123 2.336542e-219
4 2.002012e-02 4.075678e-09 6.984412e-32 7.149700e-70 3.085665e-124
%% Cell type:markdown id: tags:
### Here want to get some idea of appropriate sigma values - how about checking the cut offs for having at least a 10% chance of confusion for all sites within a range:
%% Cell type:code id: tags:
``` python
testParams_DF = pd.DataFrame(columns=['sigma', 'alpha', 'note'])
```
%% Cell type:markdown id: tags:
Range is whole quality space
%% Cell type:code id: tags:
``` python
df.loc[(df['q2'] >= 0.1) & (df['q3'] >= 0.1) & (df['q4'] >= 0.1) & (df['q5'] >= 0.1)].head()
```
%%%% Output: execute_result
sigma q2 q3 q4 q5
74 0.370370 0.375167 0.262259 0.169892 0.101546
75 0.375375 0.376777 0.265031 0.173131 0.104590
76 0.380380 0.378347 0.267745 0.176322 0.107618
77 0.385385 0.379878 0.270401 0.179466 0.110627
78 0.390390 0.381372 0.273002 0.182563 0.113616
%% Cell type:markdown id: tags:
$\sigma = 0.37$
- q2 : 0.38
- q3 : 0.26
- q4 : 0.17
- q5 : 0.10
%% Cell type:markdown id: tags:
Range is q4 or closer
%% Cell type:code id: tags:
``` python
df.loc[(df['q2'] >= 0.1) & (df['q3'] >= 0.1) & (df['q4'] >= 0.1)].head()
```
%%%% Output: execute_result
sigma q2 q3 q4 q5
56 0.280280 0.337069 0.200187 0.103577 0.046294
57 0.285285 0.339767 0.204346 0.107618 0.049227
58 0.290290 0.342380 0.208409 0.111625 0.052198
59 0.295295 0.344911 0.212380 0.115597 0.055202
60 0.300300 0.347365 0.216260 0.119531 0.058234
%% Cell type:markdown id: tags:
$\sigma=0.28$
- q2 : 0.34
- q3 : 0.20
- q4 : 0.10
- q5 : 0.04
%% Cell type:markdown id: tags:
Range is q3 or closer
%% Cell type:code id: tags:
``` python
df.loc[(df['q2'] >= 0.1) & (df['q3'] >= 0.1)].head()
```
%%%% Output: execute_result
sigma q2 q3 q4 q5
37 0.185185 0.262259 0.101546 0.028119 0.005455
38 0.190190 0.267745 0.107618 0.031517 0.006595
39 0.195195 0.273002 0.113616 0.035049 0.007867
40 0.200200 0.278043 0.119531 0.038698 0.009270
41 0.205205 0.282880 0.125357 0.042451 0.010803
%% Cell type:markdown id: tags:
$\sigma = 0.19$
- q2 : 0.26
- q3 : 0.10
- q4 : 0.03
- q5 : 0.01
%% Cell type:markdown id: tags:
Range is just q2
%% Cell type:code id: tags:
``` python
df.loc[(df['q2'] >= 0.1)].head()
```
%%%% Output: execute_result
sigma q2 q3 q4 q5
19 0.095095 0.107618 0.006595 0.000100 3.576083e-07
20 0.100100 0.119532 0.009270 0.000206 1.242683e-06
21 0.105105 0.131087 0.012463 0.000384 3.644447e-06
22 0.110110 0.142242 0.016153 0.000662 9.294145e-06
23 0.115115 0.152973 0.020303 0.001066 2.110231e-05
%% Cell type:markdown id: tags:
$\sigma = 0.1$
- q2 : 0.11
- q3 : 0.01
- q4 : 0.00
- q5 : 0.00
%% Cell type:code id: tags:
``` python
sns.lineplot(data=df.set_index('sigma'))
```
%%%% Output: execute_result
<matplotlib.axes._subplots.AxesSubplot at 0x22e106ee1d0>
%%%% Output: display_data
[Hidden Image Output]
%% Cell type:code id: tags:
``` python
sns.lineplot(data=df.where(df['sigma'] <= 1.0).set_index('sigma'))
# plotting the values of sigma
plt.axvline(0.1, alpha=0.3, color='grey')
plt.axvline(0.19, alpha=0.3, color='grey')
plt.axvline(0.28, alpha=0.3, color='grey')
plt.axvline(0.37, alpha=0.3, color='grey')
# plotting P = 0.1
plt.axhline(0.1, alpha=0.3, color='grey')
```
%%%% Output: execute_result
<matplotlib.lines.Line2D at 0x22e1083ae80>
%%%% Output: display_data
[Hidden Image Output]
%% Cell type:code id: tags:
``` python
desProb = 0.1
range_all = df[(df['q2'] >= desProb) & (df['q3'] >= desProb) & (df['q4'] >= desProb) & (df['q5'] >= desProb)].iloc[0]
range_q4 = df[(df['q2'] >= desProb) & (df['q3'] >= desProb) & (df['q4'] >= desProb)].iloc[0]
range_q3 = df[(df['q2'] >= desProb) & (df['q3'] >= desProb)].iloc[0]
range_q2 = df[(df['q2'] >= desProb)].iloc[0]
df_1Ranges = pd.DataFrame(data = [range_all, range_q4, range_q3, range_q2])
```
%% Cell type:code id: tags:
``` python
df_1Ranges
```
%%%% Output: execute_result
sigma q2 q3 q4 q5
74 0.370370 0.375167 0.262259 0.169892 1.015460e-01
56 0.280280 0.337069 0.200187 0.103577 4.629378e-02
37 0.185185 0.262259 0.101546 0.028119 5.454770e-03
19 0.095095 0.107618 0.006595 0.000100 3.576083e-07
%% Cell type:code id: tags:
``` python
testParams_DF = testParams_DF.append([{'sigma': row[1], 'alpha': row[2], 'chance': '10%', 'note': 'Prob_q2'} for row in df_1Ranges.itertuples()], sort=True)
```
%% Cell type:code id: tags:
``` python
alphas_1 = [np.mean(row[2:]) for row in df_1Ranges.itertuples()]
alphas_1
```
%%%% Output: execute_result
[0.22721601881269943,
0.17178190793707013,
0.09934474874734342,
0.028578442773621412]
%% Cell type:code id: tags:
``` python
testParams_DF = testParams_DF.append([{'sigma': row[1], 'alpha': alphas_1[i], 'chance': '10%', 'note': 'mean'}
for i, row in enumerate(df_1Ranges.itertuples())])
```
%% Cell type:markdown id: tags:
### Here want to get some idea of appropriate sigma values - how about checking the cut offs for having at least a 25% chance of confusion for all sites within a range:
%% Cell type:code id: tags:
``` python
desProb = 0.25
range_all = df[(df['q2'] >= desProb) & (df['q3'] >= desProb) & (df['q4'] >= desProb) & (df['q5'] >= desProb)].iloc[0]
range_q4 = df[(df['q2'] >= desProb) & (df['q3'] >= desProb) & (df['q4'] >= desProb)].iloc[0]
range_q3 = df[(df['q2'] >= desProb) & (df['q3'] >= desProb)].iloc[0]
range_q2 = df[(df['q2'] >= desProb)].iloc[0]
df_25Ranges = pd.DataFrame(data = [range_all, range_q4, range_q3, range_q2])
```
%% Cell type:code id: tags:
``` python
df_25Ranges
```
%%%% Output: execute_result
sigma q2 q3 q4 q5
140 0.700701 0.433217 0.368292 0.306930 0.250550
105 0.525526 0.411280 0.326893 0.250550 0.184855
70 0.350350 0.368292 0.250550 0.156453 0.089228
35 0.175175 0.250550 0.089228 0.021781 0.003561
%% Cell type:code id: tags:
``` python
sns.lineplot(data=df.where(df['sigma'] <= 1.0).set_index('sigma'))
# plotting the values of sigma
plt.axvline(df_25Ranges['sigma'].iloc[0], alpha=0.3, color='grey')
plt.axvline(df_25Ranges['sigma'].iloc[1], alpha=0.3, color='grey')
plt.axvline(df_25Ranges['sigma'].iloc[2], alpha=0.3, color='grey')
plt.axvline(df_25Ranges['sigma'].iloc[3], alpha=0.3, color='grey')
# plotting P = 0.25
plt.axhline(desProb, alpha=0.3, color='grey')
```
%%%% Output: execute_result
<matplotlib.lines.Line2D at 0x22e108f63c8>
<matplotlib.lines.Line2D at 0x22e11174400>
%%%% Output: display_data
[Hidden Image Output]
%% Cell type:code id: tags:
``` python
testParams_DF = testParams_DF.append([{'sigma': row[1], 'alpha': row[2], 'chance': '25%', 'note': 'Prob_q2'} for row in df_25Ranges.itertuples()])
```
%% Cell type:code id: tags:
``` python
alphas_25 = [np.mean(row[2:]) for row in df_25Ranges.itertuples()]
```
%% Cell type:code id: tags:
``` python
testParams_DF = testParams_DF.append([{'sigma': row[1], 'alpha': alphas_25[i], 'chance': '25%', 'note': 'mean'}
for i, row in enumerate(df_25Ranges.itertuples())])
```
%% Cell type:code id: tags:
``` python
```
%% Cell type:code id: tags:
``` python
sigmas = set(testParams_DF['sigma'])
chances = [df.loc[df['sigma'] == sigma, 'chance'].item() for sigma in sigmas]
chances = [testParams_DF.loc[testParams_DF['sigma'] == sigma, 'chance'].iloc[0] for sigma in sigmas]
testParams_DF = testParams_DF.append([{'sigma': sigma, 'alpha': 0.1, 'chance': chances[i], 'note': 'control'}
for i, sigma in enumerate(sigmas)])
```
%%%% Output: error
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
~\Anaconda2\envs\Py3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance)
2601 try:
-> 2602 return self._engine.get_loc(key)
2603 except KeyError:
pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: 'chance'
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)
<ipython-input-48-649bf0486daa> in <module>
1 sigmas = set(testParams_DF['sigma'])
----> 2 chances = [df.loc[df['sigma'] == sigma, 'chance'].item() for sigma in sigmas]
3 testParams_DF = testParams_DF.append([{'sigma': sigma, 'alpha': 0.1, 'chance': chances[i], 'note': 'control'}
4 for i, sigma in enumerate(sigmas)])
<ipython-input-48-649bf0486daa> in <listcomp>(.0)
1 sigmas = set(testParams_DF['sigma'])
----> 2 chances = [df.loc[df['sigma'] == sigma, 'chance'].item() for sigma in sigmas]
3 testParams_DF = testParams_DF.append([{'sigma': sigma, 'alpha': 0.1, 'chance': chances[i], 'note': 'control'}
4 for i, sigma in enumerate(sigmas)])
~\Anaconda2\envs\Py3\lib\site-packages\pandas\core\indexing.py in __getitem__(self, key)
1492 except (KeyError, IndexError, AttributeError):
1493 pass
-> 1494 return self._getitem_tuple(key)
1495 else:
1496 # we by definition only have the 0th axis
~\Anaconda2\envs\Py3\lib\site-packages\pandas\core\indexing.py in _getitem_tuple(self, tup)
866 def _getitem_tuple(self, tup):
867 try:
--> 868 return self._getitem_lowerdim(tup)
869 except IndexingError:
870 pass
~\Anaconda2\envs\Py3\lib\site-packages\pandas\core\indexing.py in _getitem_lowerdim(self, tup)
986 for i, key in enumerate(tup):
987 if is_label_like(key) or isinstance(key, tuple):
--> 988 section = self._getitem_axis(key, axis=i)
989
990 # we have yielded a scalar ?
~\Anaconda2\envs\Py3\lib\site-packages\pandas\core\indexing.py in _getitem_axis(self, key, axis)
1911 # fall thru to straight lookup
1912 self._validate_key(key, axis)
-> 1913 return self._get_label(key, axis=axis)
1914
1915
~\Anaconda2\envs\Py3\lib\site-packages\pandas\core\indexing.py in _get_label(self, label, axis)
139 raise IndexingError('no slices here, handle elsewhere')
140
--> 141 return self.obj._xs(label, axis=axis)
142
143 def _get_loc(self, key, axis=None):
~\Anaconda2\envs\Py3\lib\site-packages\pandas\core\generic.py in xs(self, key, axis, level, drop_level)
3564
3565 if axis == 1:
-> 3566 return self[key]
3567
3568 self._consolidate_inplace()
~\Anaconda2\envs\Py3\lib\site-packages\pandas\core\frame.py in __getitem__(self, key)
2915 if self.columns.nlevels > 1:
2916 return self._getitem_multilevel(key)
-> 2917 indexer = self.columns.get_loc(key)
2918 if is_integer(indexer):
2919 indexer = [indexer]
~\Anaconda2\envs\Py3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance)
2602 return self._engine.get_loc(key)
2603 except KeyError:
-> 2604 return self._engine.get_loc(self._maybe_cast_indexer(key))
2605 indexer = self.get_indexer([key], method=method, tolerance=tolerance)
2606 if indexer.ndim > 1 or indexer.size > 1:
pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: 'chance'
%% Cell type:code id: tags:
``` python
print(testParams_DF)
```
%%%% Output: stream
alpha chance note \
0 0.375167 10% Prob_q2
1 0.337069 10% Prob_q2
2 0.262259 10% Prob_q2
3 0.107618 10% Prob_q2
0 0.227216 10% mean
1 0.171782 10% mean
2 0.099345 10% mean
3 0.028578 10% mean
0 0.433217 25% Prob_q2
1 0.411280 25% Prob_q2
2 0.368292 25% Prob_q2
3 0.250550 25% Prob_q2
0 0.339747 25% mean
1 0.293395 25% mean
2 0.216131 25% mean
3 0.091280 25% mean
0 0.100000 0 10%
0 10%
Name: chance, dtype: object control
1 0.100000 0 25%
0 25%
Name: chance, dtype: object control
2 0.100000 3 10%
3 10%
Name: chance, dtype: object control
3 0.100000 1 10%
1 10%
Name: chance, dtype: object control
4 0.100000 2 10%
2 10%
Name: chance, dtype: object control
5 0.100000 1 25%
1 25%
Name: chance, dtype: object control
6 0.100000 2 25%
2 25%
Name: chance, dtype: object control
7 0.100000 3 25%
3 25%
Name: chance, dtype: object control
0 0.433217 25% Prob_q2
1 0.411280 25% Prob_q2
2 0.368292 25% Prob_q2
3 0.250550 25% Prob_q2
0 0.339747 25% mean
1 0.293395 25% mean
2 0.216131 25% mean
3 0.091280 25% mean
0 0.100000 0 ... control
1 0.100000 0 ... control
2 0.100000 3 ... control
3 0.100000 1 ... control
4 0.100000 2 ... control
5 0.100000 1 ... control
6 0.100000 2 ... control
7 0.100000 3 ... control
sigma
0 0.370370
1 0.280280
2 0.185185
3 0.095095
0 0.370370
1 0.280280
2 0.185185
3 0.095095
0 0.700701
1 0.525526
2 0.350350
3 0.175175
0 0.700701
1 0.525526
2 0.350350
3 0.175175
0 0.370370
1 0.700701
2 0.095095
3 0.280280
4 0.185185
5 0.525526
6 0.350350
7 0.175175
0 0.700701
1 0.525526
2 0.350350
3 0.175175
0 0.700701
1 0.525526
2 0.350350
3 0.175175
0 0.370370
1 0.700701
2 0.095095
3 0.280280
4 0.185185
5 0.525526
6 0.350350
7 0.175175
%% Cell type:code id: tags:
``` python
testParams_DF['paramSet'] = range(1, len(testParams_DF)+1)
testParams_DF = testParams_DF.set_index('paramSet')
print(testParams_DF)
```
%% Cell type:code id: tags:
``` python
testParams_DF.to_csv('testParams.csv')
```
%% Cell type:code id: tags:
``` python
testParams_DF.iloc[0]['sigma']
```
%% Cell type:code id: tags:
``` python
set(testParams_DF.index.values)
```
%% Cell type:code id: tags:
``` python
testParams_DF.index.values
```
%% Cell type:code id: tags:
``` python
testParams_DF.iloc[15]['sigma']
```
%% Cell type:code id: tags:
``` python
def convert_paramSetNum(filePath):
df = pd.read_csv(filePath, names=['time', 'paramSet', 'simNum', 'timestep', 'agent', 'iteration', 'option', 'belief'])
df['paramSet'] +=1
df.to_csv(filePath)
df = pd.read_csv(filePath)
df.to_csv(filePath, header=False, index=False)
```
%% Cell type:code id: tags:
``` python
import os, glob
path = 'Results/'
all_files = glob.glob(os.path.join(path, "botSim_beliefs_[0-9].csv"))
for f in all_files:
convert_paramSetNum(f)
```
%% Cell type:code id: tags:
``` python
```
......
This diff is collapsed.
This diff is collapsed.
......@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
......@@ -1231,114 +1231,20 @@
},
{
"cell_type": "code",
"execution_count": 42,
"execution_count": 11,
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" alpha chance note \\\n",
"0 0.375167 10% Prob_q2 \n",
"1 0.337069 10% Prob_q2 \n",
"2 0.262259 10% Prob_q2 \n",
"3 0.107618 10% Prob_q2 \n",
"0 0.227216 10% mean \n",
"1 0.171782 10% mean \n",
"2 0.099345 10% mean \n",
"3 0.028578 10% mean \n",
"0 0.433217 25% Prob_q2 \n",
"1 0.411280 25% Prob_q2 \n",
"2 0.368292 25% Prob_q2 \n",
"3 0.250550 25% Prob_q2 \n",
"0 0.339747 25% mean \n",
"1 0.293395 25% mean \n",
"2 0.216131 25% mean \n",
"3 0.091280 25% mean \n",
"0 0.100000 0 10%\n",
"0 10%\n",
"Name: chance, dtype: object control \n",
"1 0.100000 0 25%\n",
"0 25%\n",
"Name: chance, dtype: object control \n",
"2 0.100000 3 10%\n",
"3 10%\n",
"Name: chance, dtype: object control \n",
"3 0.100000 1 10%\n",
"1 10%\n",
"Name: chance, dtype: object control \n",
"4 0.100000 2 10%\n",
"2 10%\n",
"Name: chance, dtype: object control \n",
"5 0.100000 1 25%\n",
"1 25%\n",
"Name: chance, dtype: object control \n",
"6 0.100000 2 25%\n",
"2 25%\n",
"Name: chance, dtype: object control \n",
"7 0.100000 3 25%\n",
"3 25%\n",
"Name: chance, dtype: object control \n",
"0 0.433217 25% Prob_q2 \n",
"1 0.411280 25% Prob_q2 \n",
"2 0.368292 25% Prob_q2 \n",
"3 0.250550 25% Prob_q2 \n",
"0 0.339747 25% mean \n",
"1 0.293395 25% mean \n",
"2 0.216131 25% mean \n",
"3 0.091280 25% mean \n",
"0 0.100000 0 ... control \n",
"1 0.100000 0 ... control \n",
"2 0.100000 3 ... control \n",
"3 0.100000 1 ... control \n",
"4 0.100000 2 ... control \n",
"5 0.100000 1 ... control \n",
"6 0.100000 2 ... control \n",
"7 0.100000 3 ... control \n",
"\n",
" sigma \n",
"0 0.370370 \n",
"1 0.280280 \n",
"2 0.185185 \n",
"3 0.095095 \n",
"0 0.370370 \n",
"1 0.280280 \n",
"2 0.185185 \n",
"3 0.095095 \n",
"0 0.700701 \n",
"1 0.525526 \n",
"2 0.350350 \n",
"3 0.175175 \n",
"0 0.700701 \n",
"1 0.525526 \n",
"2 0.350350 \n",
"3 0.175175 \n",
"0 0.370370 \n",
"1 0.700701 \n",
"2 0.095095 \n",
"3 0.280280 \n",
"4 0.185185 \n",
"5 0.525526 \n",
"6 0.350350 \n",
"7 0.175175 \n",
"0 0.700701 \n",
"1 0.525526 \n",
"2 0.350350 \n",
"3 0.175175 \n",
"0 0.700701 \n",
"1 0.525526 \n",
"2 0.350350 \n",
"3 0.175175 \n",
"0 0.370370 \n",
"1 0.700701 \n",
"2 0.095095 \n",
"3 0.280280 \n",
"4 0.185185 \n",
"5 0.525526 \n",
"6 0.350350 \n",
"7 0.175175 \n"
"ename": "NameError",
"evalue": "name 'testParams_DF' is not defined",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-11-d89ffc317e6f>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtestParams_DF\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[1;31mNameError\u001b[0m: name 'testParams_DF' is not defined"
]
}
],
......@@ -1404,25 +1310,25 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"def convert_paramSetNum(filePath):\n",
" df = pd.read_csv(filePath, names=['time', 'paramSet', 'simNum', 'timestep', 'agent', 'iteration', 'option', 'belief'])\n",
" df['paramSet'] +=1\n",
" df.to_csv(filePath)"
" df = pd.read_csv(filePath, names=['index', 'time', 'paramSet', 'simNum', 'timestep', 'agent', 'iteration', 'option', 'belief'])\n",
" df = df.drop('index', axis=1)\n",
" df.to_csv(filePath, header=False, index=False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"import os, glob\n",
"path = 'Results/'\n",
"all_files = glob.glob(os.path.join(path, \"botSim_beliefs_[0-9].csv\")) \n",
"all_files = glob.glob(os.path.join(path, \"botSim_beliefs_[0-4].csv\")) \n",
"for f in all_files:\n",
" convert_paramSetNum(f)"
]
......@@ -1451,7 +1357,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.2"
"version": "3.7.1"
}
},
"nbformat": 4,
......
%% Cell type:code id: tags:
``` python
import numpy as np
import scipy
import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
```
%% Cell type:markdown id: tags:
# Analysis of the probability of confusing qualities for different values of sigma
%% Cell type:markdown id: tags:
First need the pdf and cdf of the normal distributions which will represent the noise around each of the quality values
%% Cell type:code id: tags:
``` python
def f(x, mu, s):
return scipy.stats.norm.pdf(x, loc=mu, scale=s)
```
%% Cell type:code id: tags:
``` python
def F(x, mu, s):
return scipy.stats.norm