Commit c2c28401 authored by Chanelle Lee's avatar Chanelle Lee
Browse files

Worked on some of the analysis but mostly just updated testParams to add new noise models

parent 485d4c83
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
......@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
......@@ -29,7 +29,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
......@@ -39,7 +39,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
......@@ -56,7 +56,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
......@@ -66,7 +66,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
......@@ -390,7 +390,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
......@@ -406,94 +406,19 @@
},
{
"cell_type": "code",
"execution_count": 79,
"execution_count": 7,
"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>sigma</th>\n",
" <th>q2</th>\n",
" <th>q3</th>\n",
" <th>q4</th>\n",
" <th>q5</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>121</th>\n",
" <td>0.060506</td>\n",
" <td>0.025722</td>\n",
" <td>0.000049</td>\n",
" <td>2.733868e-09</td>\n",
" <td>3.208290e-15</td>\n",
" </tr>\n",
" <tr>\n",
" <th>122</th>\n",
" <td>0.061006</td>\n",
" <td>0.026693</td>\n",
" <td>0.000056</td>\n",
" <td>3.629824e-09</td>\n",
" <td>5.322023e-15</td>\n",
" </tr>\n",
" <tr>\n",
" <th>123</th>\n",
" <td>0.061506</td>\n",
" <td>0.027677</td>\n",
" <td>0.000064</td>\n",
" <td>4.787065e-09</td>\n",
" <td>8.720838e-15</td>\n",
" </tr>\n",
" <tr>\n",
" <th>124</th>\n",
" <td>0.062006</td>\n",
" <td>0.028675</td>\n",
" <td>0.000072</td>\n",
" <td>6.272245e-09</td>\n",
" <td>1.412178e-14</td>\n",
" </tr>\n",
" <tr>\n",
" <th>125</th>\n",
" <td>0.062506</td>\n",
" <td>0.029686</td>\n",
" <td>0.000081</td>\n",
" <td>8.166519e-09</td>\n",
" <td>2.260656e-14</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" sigma q2 q3 q4 q5\n",
"121 0.060506 0.025722 0.000049 2.733868e-09 3.208290e-15\n",
"122 0.061006 0.026693 0.000056 3.629824e-09 5.322023e-15\n",
"123 0.061506 0.027677 0.000064 4.787065e-09 8.720838e-15\n",
"124 0.062006 0.028675 0.000072 6.272245e-09 1.412178e-14\n",
"125 0.062506 0.029686 0.000081 8.166519e-09 2.260656e-14"
]
},
"execution_count": 79,
"metadata": {},
"output_type": "execute_result"
"ename": "NameError",
"evalue": "name '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-7-a48bd813cbaf>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mdf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mloc\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdf\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'q2'\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m>=\u001b[0m \u001b[1;36m0.025\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mhead\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[1;31mNameError\u001b[0m: name 'df' is not defined"
]
}
],
"source": [
......@@ -502,7 +427,7 @@
},
{
"cell_type": "code",
"execution_count": 88,
"execution_count": 8,
"metadata": {},
"outputs": [
{
......@@ -532,7 +457,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
......@@ -702,7 +627,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
......@@ -870,7 +795,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
......@@ -1036,7 +961,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
......@@ -1235,7 +1160,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
......@@ -1244,7 +1169,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
......@@ -1259,7 +1184,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
......@@ -1274,7 +1199,37 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
"desProb = 2.5\n",
"testParams_DF = testParams_DF.append([{'sigma': noiseDict[desProb], 'alpha': alpha, 'chance': '{}%'.format(desProb), 'note': 'control'} for alpha in [0, 0.1, 0.2, 0.3, 0.4]], sort=True)\n",
"testParams_DF = testParams_DF.append([{'sigma': noiseDict[desProb], 'alpha': desProb/100, 'chance': '{}%'.format(desProb), 'note': 'q2 prob'}], sort=True)\n",
"testParams_DF = testParams_DF.append([{'sigma': noiseDict[desProb],\n",
" 'alpha': np.mean([probConfusion(1, i, noiseDict[desProb]) for i in [2, 3, 4, 5]]),\n",
" 'chance': '{}%'.format(desProb), \n",
" 'note': 'mean'}], sort=True)"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"desProb = 7.5\n",
"testParams_DF = testParams_DF.append([{'sigma': noiseDict[desProb], 'alpha': alpha, 'chance': '{}%'.format(desProb), 'note': 'control'} for alpha in [0, 0.1, 0.2, 0.3, 0.4]], sort=True)\n",
"testParams_DF = testParams_DF.append([{'sigma': noiseDict[desProb], 'alpha': desProb/100, 'chance': '{}%'.format(desProb), 'note': 'q2 prob'}], sort=True)\n",
"testParams_DF = testParams_DF.append([{'sigma': noiseDict[desProb],\n",
" 'alpha': np.mean([probConfusion(1, i, noiseDict[desProb]) for i in [2, 3, 4, 5]]),\n",
" 'chance': '{}%'.format(desProb), \n",
" 'note': 'mean'}], sort=True)"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
......@@ -1296,7 +1251,21 @@
"11 0.300000 10% control 0.0920\n",
"12 0.400000 10% control 0.0920\n",
"13 0.100000 10% q2 prob 0.0920\n",
"14 0.013170 10% mean 0.0920\n"
"14 0.013170 10% mean 0.0920\n",
"15 0.000000 2.5% control 0.0602\n",
"16 0.100000 2.5% control 0.0602\n",
"17 0.200000 2.5% control 0.0602\n",
"18 0.300000 2.5% control 0.0602\n",
"19 0.400000 2.5% control 0.0602\n",
"20 0.025000 2.5% q2 prob 0.0602\n",
"21 0.003148 2.5% mean 0.0602\n",
"22 0.000000 7.5% control 0.0820\n",
"23 0.100000 7.5% control 0.0820\n",
"24 0.200000 7.5% control 0.0820\n",
"25 0.300000 7.5% control 0.0820\n",
"26 0.400000 7.5% control 0.0820\n",
"27 0.075000 7.5% q2 prob 0.0820\n",
"28 0.009670 7.5% mean 0.0820\n"
]
}
],
......@@ -1308,7 +1277,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
......@@ -1339,7 +1308,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))} # i is the id of the site with corresponding quality
```
%% Cell type:code id: tags:
``` python
def integrand(x, i, j, s):
"""
x : float
point at which to evaluate the integrand
i : int
id of first site so the quality can be returned as the mean of the pdf
j : int
id of the second site so the quality can be returned as the mean of the cdf
s : float
sigma value to be tested
"""
return f(x, qualities[i], s)*F(x, qualities[j], s)
def probConfusion(i, j, s):
"""
i : int
id of the first site to be confused (will normally always be 1)
j : int
id of the site to be confused with
s : float
sigma value to be tested
"""
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]
```
%%%% Output: error
---------------------------------------------------------------------------
KeyboardInterrupt Traceback (most recent call last)
<ipython-input-15-9ba2372464a5> in <module>
2 sf = 100
3 ss = np.linspace(s0, sf, 1000)
----> 4 confusions = [probConfusion(1, 2, s)[0] for s in ss]
<ipython-input-15-9ba2372464a5> in <listcomp>(.0)
2 sf = 100
3 ss = np.linspace(s0, sf, 1000)
----> 4 confusions = [probConfusion(1, 2, s)[0] for s in ss]
<ipython-input-14-f48366cefba1> in probConfusion(i, j, s)
21 sigma value to be tested
22 """
---> 23 return scipy.integrate.quad(integrand, -np.inf, np.inf, args=(i, j, s))
~\Anaconda2\envs\Py3\lib\site-packages\scipy\integrate\quadpack.py in quad(func, a, b, args, full_output, epsabs, epsrel, limit, points, weight, wvar, wopts, maxp1, limlst)
339 if weight is None:
340 retval = _quad(func, a, b, args, full_output, epsabs, epsrel, limit,
--> 341 points)
342 else:
343 retval = _quad_weight(func, a, b, args, full_output, epsabs, epsrel,
~\Anaconda2\envs\Py3\lib\site-packages\scipy\integrate\quadpack.py in _quad(func, a, b, args, full_output, epsabs, epsrel, limit, points)
448 return _quadpack._qagse(func,a,b,args,full_output,epsabs,epsrel,limit)
449 else:
--> 450 return _quadpack._qagie(func,bound,infbounds,args,full_output,epsabs,epsrel,limit)
451 else:
452 if infbounds != 0:
<ipython-input-14-f48366cefba1> in integrand(x, i, j, s)
10 sigma value to be tested
11 """
---> 12 return f(x, qualities[i], s)*F(x, qualities[j], s)
13
14 def probConfusion(i, j, s):
<ipython-input-11-94977a845123> in f(x, mu, s)
1 def f(x, mu, s):
----> 2 return scipy.stats.norm.pdf(x, loc=mu, scale=s)
~\Anaconda2\envs\Py3\lib\site-packages\scipy\stats\_distn_infrastructure.py in pdf(self, x, *args, **kwds)
1665 cond = cond0 & cond1
1666 output = zeros(shape(cond), dtyp)
-> 1667 putmask(output, (1-cond0)+np.isnan(x), self.badvalue)
1668 if np.any(cond):
1669 goodargs = argsreduce(cond, *((x,)+args+(scale,)))
KeyboardInterrupt:
%% Cell type:code id: tags:
``` python
plt.plot(ss, confusions)
```
%%%% Output: execute_result
[<matplotlib.lines.Line2D at 0x96b9198>]
%%%% 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 0x9943c50>]
%%%% 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, 10000)
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.tail()
```
%%%% Output: execute_result
sigma q2 q3 q4 q5
9995 4.9980 0.490594 0.481193 0.471803 0.462428
9996 4.9985 0.490595 0.481195 0.471806 0.462432
9997 4.9990 0.490596 0.481197 0.471808 0.462436
9998 4.9995 0.490597 0.481199 0.471811 0.462439
9999 5.0000 0.490598 0.481201 0.471814 0.462443
%% Cell type:markdown id: tags:
## Investigating suitable noise ranges wrt q2:
%% Cell type:code id: tags:
``` python
noiseDict = {}
```
%% Cell type:markdown id: tags:
### 2.5% noise:
%% Cell type:code id: tags:
``` python
df.loc[(df['q2'] >= 0.025)].head()
```
%%%% Output: execute_result
%%%% Output: error
sigma q2 q3 q4 q5
121 0.060506 0.025722 0.000049 2.733868e-09 3.208290e-15
122 0.061006 0.026693 0.000056 3.629824e-09 5.322023e-15
123 0.061506 0.027677 0.000064 4.787065e-09 8.720838e-15
124 0.062006 0.028675 0.000072 6.272245e-09 1.412178e-14
125 0.062506 0.029686 0.000081 8.166519e-09 2.260656e-14
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-7-a48bd813cbaf> in <module>()
----> 1 df.loc[(df['q2'] >= 0.025)].head()
NameError: name 'df' is not defined
%% Cell type:code id: tags:
``` python
print(probConfusion(1, 2, 0.060)[0])
print(probConfusion(1, 2, 0.0601)[0])
print(probConfusion(1, 2, 0.0602)[0])
print(probConfusion(1, 2, 0.0605)[0])
```
%%%% Output: stream
0.02475429167307887
0.02494433498561147
0.025134962669580048
0.02571031960745227
%% Cell type:markdown id: tags:
So sigma = 0.0602 is a sensible choices when the target is to have a 2.5% confusion with q2. (3sf accuracy to confusion)
%% Cell type:code id: tags:
``` python
noiseDict[2.5] = 0.0602
```
%% Cell type:code id: tags:
``` python
sns.lineplot(data=df.where(df['sigma'] <= 0.15).set_index('sigma'));
# plotting the values of sigma
plt.axvline(0.0602, alpha=0.3, color='grey');
# plotting P = 0.025
plt.axhline(0.025, alpha=0.3, color='grey');
```
%%%% Output: display_data
[Hidden Image Output]
%% Cell type:markdown id: tags:
### 5% noise:
%% Cell type:code id: tags:
``` python
df.loc[(df['q2'] >= 0.05)].head()
```
%%%% Output: execute_result
sigma q2 q3 q4 q5
144 0.072007 0.050851 0.000531 4.554609e-07 2.935573e-11
145 0.072507 0.052042 0.000576 5.410073e-07 3.969403e-11
146 0.073007 0.053238 0.000622 6.404128e-07 5.334540e-11
147 0.073507 0.054439 0.000672 7.555478e-07 7.126576e-11
148 0.074007 0.055645 0.000724 8.884804e-07 9.465574e-11
%% Cell type:code id: tags:
``` python
print(probConfusion(1, 2, 0.0715)[0])
print(probConfusion(1, 2, 0.0716)[0])
print(probConfusion(1, 2, 0.0717)[0])
print(probConfusion(1, 2, 0.072)[0])
print(probConfusion(1, 2, 0.0725)[0])
```
%%%% Output: stream
0.049648889742545464
0.04988543051051232
0.050122205690951147
0.050833911844210954
0.05202453716771595
%% Cell type:markdown id: tags:
So sigma = 0.0717 is a sensible choices when the target is to have a 5% confusion with q2. (3sf accuracy to confusion)
%% Cell type:code id: tags:
``` python
noiseDict[5] = 0.0717
```
%% Cell type:code id: tags:
``` python
sns.lineplot(data=df.where(df['sigma'] <= 0.25).set_index('sigma'));
# plotting the values of sigma
plt.axvline(0.0717, alpha=0.3, color='grey');
# plotting P = 0.1
plt.axhline(0.05, alpha=0.3, color='grey');
```
%%%% Output: display_data
[Hidden Image Output]
%% Cell type:markdown id: tags:
### 7.5% noise:
%% Cell type:code id: tags:
``` python
df.loc[(df['q2']) >= 0.075].head()
```
%%%% Output: execute_result
sigma q2 q3 q4 q5
164 0.082008 0.075350 0.002026 0.000008 4.518469e-09
165 0.082508 0.076595 0.002140 0.000009 5.548921e-09
166 0.083008 0.077840 0.002259 0.000010 6.789574e-09
167 0.083508 0.079086 0.002383 0.000011 8.278111e-09
168 0.084008 0.080331 0.002510 0.000013 1.003532e-08
%% Cell type:code id: tags:
``` python
print(probConfusion(1, 2, 0.080)[0])
print(probConfusion(1, 2, 0.081)[0])
print(probConfusion(1, 2, 0.0815)[0])
print(probConfusion(1, 2, 0.082)[0])
```
%%%% Output: stream
0.07035676242634634
0.07284124411849473
0.07408493545579492
0.0753293217492284
%% Cell type:markdown id: tags:
So sigma = 0.082 is a sensible choice when the target is to have a 7.5% confusion with q2. (3sf accuracy to confusion)
%% Cell type:code id: tags:
``` python
noiseDict[7.5] = 0.082
```
%% Cell type:code id: tags:
``` python
sns.lineplot(data=df.where(df['sigma'] <= 0.5).set_index('sigma'));
# plotting the values of sigma
plt.axvline(0.082, alpha=0.3, color='grey');
# plotting P = 0.075
plt.axhline(0.075, alpha=0.3, color='grey');
```
%%%% Output: display_data
[Hidden Image Output]
%% Cell type:markdown id: tags:
### 10% noise:
%% Cell type:code id: tags:
``` python
df.loc[(df['q2'] >= 0.1)].head()
```
%%%% Output: execute_result
sigma q2 q3 q4 q5
184 0.092009 0.100121 0.005208 0.000061 1.500021e-07
185 0.092509 0.101343 0.005419 0.000066 1.736816e-07
186 0.093009 0.102562 0.005636 0.000072 2.006357e-07
187 0.093509 0.103778 0.005857 0.000078 2.312503e-07
188 0.094009 0.104992 0.006084 0.000085 2.659477e-07
%% Cell type:code id: tags:
``` python
print(probConfusion(1, 2, 0.0915)[0])
print(probConfusion(1, 2, 0.092)[0])
print(probConfusion(1, 2, 0.095)[0])
```
%%%% Output: stream
0.09887463613021713
0.10009849345738388
0.10738819470991004
%% Cell type:markdown id: tags:
So sigma = 0.092 is a sensible choice when the target is to have a 10% confusion with q2. (3sf accuracy to confusion)
%% Cell type:code id: tags:
``` python
noiseDict[10] = 0.092
```
%% Cell type:code id: tags:
``` python
sns.lineplot(data=df.where(df['sigma'] <= 0.5).set_index('sigma'));
# plotting the values of sigma
plt.axvline(0.092, alpha=0.3, color='grey');
# plotting P = 0.1
plt.axhline(0.1, alpha=0.3, color='grey');
```
%%%% Output: display_data
[Hidden Image Output]
%% Cell type:markdown id: tags:
### 25% noise:
%% Cell type:code id: tags:
``` python
df.loc[(df['q2'] >= 0.25)].head()
```
%%%% Output: execute_result
sigma q2 q3 q4 q5
350 0.175018 0.250357 0.089033 0.021686 0.003536
351 0.175518 0.250967 0.089653 0.021987 0.003618
352 0.176018 0.251575 0.090272 0.022289 0.003701
353 0.176518 0.252180 0.090891 0.022592 0.003786
354 0.177018 0.252783 0.091509 0.022898 0.003872
%% Cell type:code id: tags:
``` python
print(probConfusion(1, 2, 0.17)[0])
print(probConfusion(1, 2, 0.1725)[0])
print(probConfusion(1, 2, 0.175)[0])
```
%%%% Output: stream
0.24407886543949514
0.24724182921706586
0.2503352846480645
%% Cell type:markdown id: tags:
So sigma = 0.175 is a sensible choice when the target is to have a 25% confusion with q2. (3sf accuracy to confusion)
%% Cell type:code id: tags:
``` python
sns.lineplot(data=df.where(df['sigma'] <= 0.5).set_index('sigma'));
# plotting the values of sigma
plt.axvline(0.175, alpha=0.3, color='grey');
# plotting P = 0.25
plt.axhline(0.25, alpha=0.3, color='grey');
```
%%%% Output: display_data
[Hidden Image Output]
%% Cell type:markdown id: tags:
### Creating test parameters dataframe
%% Cell type:code id: tags:
``` python
testParams_DF = pd.DataFrame(columns=['sigma', 'alpha', 'chance', 'note'])
```
%% Cell type:code id: tags:
``` python
desProb = 5
testParams_DF = testParams_DF.append([{'sigma': noiseDict[desProb], 'alpha': alpha, 'chance': '{}%'.format(desProb), 'note': 'control'} for alpha in [0, 0.1, 0.2, 0.3, 0.4]], sort=True)
testParams_DF = testParams_DF.append([{'sigma': noiseDict[desProb], 'alpha': desProb/100, 'chance': '{}%'.format(desProb), 'note': 'q2 prob'}], sort=True)
testParams_DF = testParams_DF.append([{'sigma': noiseDict[desProb],
'alpha': np.mean([probConfusion(1, i, noiseDict[desProb]) for i in [2, 3, 4, 5]]),
'chance': '{}%'.format(desProb),
'note': 'mean'}], sort=True)
```
%% Cell type:code id: tags:
``` python
desProb = 10
testParams_DF = testParams_DF.append([{'sigma': noiseDict[desProb], 'alpha': alpha, 'chance': '{}%'.format(desProb), 'note': 'control'} for alpha in [0, 0.1, 0.2, 0.3, 0.4]], sort=True)
testParams_DF = testParams_DF.append([{'sigma': noiseDict[desProb], 'alpha': desProb/100, 'chance': '{}%'.format(desProb), 'note': 'q2 prob'}], sort=True)
testParams_DF = testParams_DF.append([{'sigma': noiseDict[desProb],
'alpha': np.mean([probConfusion(1, i, noiseDict[desProb]) for i in [2, 3, 4, 5]]),
'chance': '{}%'.format(desProb),
'note': 'mean'}], sort=True)
```
%% Cell type:code id: tags:
``` python
desProb = 2.5
testParams_DF = testParams_DF.append([{'sigma': noiseDict[desProb], 'alpha': alpha, 'chance': '{}%'.format(desProb), 'note': 'control'} for alpha in [0, 0.1, 0.2, 0.3, 0.4]], sort=True)
testParams_DF = testParams_DF.append([{'sigma': noiseDict[desProb], 'alpha': desProb/100, 'chance': '{}%'.format(desProb), 'note': 'q2 prob'}], sort=True)
testParams_DF = testParams_DF.append([{'sigma': noiseDict[desProb],
'alpha': np.mean([probConfusion(1, i, noiseDict[desProb]) for i in [2, 3, 4, 5]]),
'chance': '{}%'.format(desProb),
'note': 'mean'}], sort=True)
```
%% Cell type:code id: tags:
``` python
desProb = 7.5
testParams_DF = testParams_DF.append([{'sigma': noiseDict[desProb], 'alpha': alpha, 'chance': '{}%'.format(desProb), 'note': 'control'} for alpha in [0, 0.1, 0.2, 0.3, 0.4]], sort=True)
testParams_DF = testParams_DF.append([{'sigma': noiseDict[desProb], 'alpha': desProb/100, 'chance': '{}%'.format(desProb), 'note': 'q2 prob'}], sort=True)
testParams_DF = testParams_DF.append([{'sigma': noiseDict[desProb],
'alpha': np.mean([probConfusion(1, i, noiseDict[desProb]) for i in [2, 3, 4, 5]]),
'chance': '{}%'.format(desProb),
'note': 'mean'}], sort=True)
```
%% 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)
```
%%%% Output: stream
alpha chance note sigma
paramSet
1 0.000000 5% control 0.0717
2 0.100000 5% control 0.0717
3 0.200000 5% control 0.0717
4 0.300000 5% control 0.0717
5 0.400000 5% control 0.0717
6 0.050000 5% q2 prob 0.0717
7 0.006329 5% mean 0.0717
8 0.000000 10% control 0.0920
9 0.100000 10% control 0.0920
10 0.200000 10% control 0.0920
11 0.300000 10% control 0.0920
12 0.400000 10% control 0.0920
13 0.100000 10% q2 prob 0.0920
14 0.013170 10% mean 0.0920
15 0.000000 2.5% control 0.0602
16 0.100000 2.5% control 0.0602
17 0.200000 2.5% control 0.0602
18 0.300000 2.5% control 0.0602
19 0.400000 2.5% control 0.0602
20 0.025000 2.5% q2 prob 0.0602
21 0.003148 2.5% mean 0.0602
22 0.000000 7.5% control 0.0820
23 0.100000 7.5% control 0.0820
24 0.200000 7.5% control 0.0820
25 0.300000 7.5% control 0.0820
26 0.400000 7.5% control 0.0820
27 0.075000 7.5% q2 prob 0.0820
28 0.009670 7.5% mean 0.0820
%% Cell type:code id: tags:
``` python
testParams_DF.to_csv('testParams.csv')
```
%% Cell type:code id: tags:
``` python
```
......
......@@ -28,7 +28,7 @@ def main(numSims=10):
vrep.simx_opmode_blocking)
testParams = pd.read_csv('testParams.csv', index_col='paramSet')
for paramNum in set(testParams.index.values):
if paramNum < 8: # This just allows us to skip ones already tested
if paramNum < 15: # This just allows us to skip ones already tested
continue
print('Param num: {}'.format(paramNum))
simNum = 0
......
......@@ -10,8 +10,12 @@ Experiments:
☐ 2.5% and 7.5%
- _0 logs contain paramsets 1-5 complete
- _1 logs contain paramsets 6, 8-11 complete and paramset 7 1-3 sims
- _2 logs contain paramsets 12-14 complete
- Paramset 7 is not complete, only has sim runs 1-3
- Beware that paramset 13 sim 2 had some intervention to reorientate an epuck
Analysis:
......@@ -13,3 +13,17 @@ paramSet,alpha,chance,note,sigma
12,0.4,10%,control,0.092
13,0.1,10%,q2 prob,0.092
14,0.01317041146831397,10%,mean,0.092
15,0.0,2.5%,control,0.0602
16,0.1,2.5%,control,0.0602
17,0.2,2.5%,control,0.0602
18,0.3,2.5%,control,0.0602
19,0.4,2.5%,control,0.0602
20,0.025,2.5%,q2 prob,0.0602
21,0.0031475154252090347,2.5%,mean,0.0602
22,0.0,7.5%,control,0.082
23,0.1,7.5%,control,0.082
24,0.2,7.5%,control,0.082
25,0.3,7.5%,control,0.082
26,0.4,7.5%,control,0.082
27,0.075,7.5%,q2 prob,0.082
28,0.00967016335700319,7.5%,mean,0.082
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment