In [1]:
%cd ~/NetBeansProjects/ExpLosion/
from notebooks.common_imports import *
import numpy as np
from sklearn.metrics import accuracy_score
In [8]:
gold = np.array([1,1,1,1,1,0,0,0,0,0])
pred = np.array([1,1,1,1,0,0,0,0,0,1])
accuracies = []
for i in range(50000):
ids = np.random.choice(list(range(10)), 10)
acc = accuracy_score(gold[ids], pred[ids])
accuracies.append(acc)
if i<6:
print(i, ids, acc)
In [9]:
sns.set_style('white')
sns.distplot(accuracies, kde=False, bins=10, kde_kws={'bw':0.04})
plt.axvline(np.mean(accuracies), c='k', linewidth=4);
plt.axvline(np.mean(np.percentile(accuracies, 2.5)), linestyle ='--', c='k', linewidth=4);
plt.axvline(np.mean(np.percentile(accuracies, 97.5)), linestyle ='--', c='k', linewidth=4);
plt.xlabel('Accuracy');
plt.xlim(0, 1.01)
plt.ylabel('')
plt.yticks([])
sns.despine(top=True, left=True)
plt.savefig('bootstrap-example.pdf', format='pdf', dpi=300, bbox_inches='tight', pad_inches=0.1)
In [56]:
np.mean(accuracies[:1000])
Out[56]:
In [60]:
''.join(map(str,gold))
Out[60]:
In [61]:
''.join(map(str,pred))
Out[61]:
In [63]:
print(np.mean(np.percentile(accuracies, 2.5)))
print(np.mean(np.percentile(accuracies, 97.5)))
In [ ]: