1
0
Fork 0

repairing the plot

This commit is contained in:
Alejandro Moreo Fernandez 2022-07-05 15:13:28 +02:00
parent 29993386ae
commit f794bc5c17
2 changed files with 22 additions and 23 deletions

View File

@ -117,14 +117,14 @@ if __name__ == '__main__':
parser.add_argument('--sampling', metavar='SAMPLING', type=str, help='Sampling criterion',
default='relevance_sampling')
parser.add_argument('--iter', metavar='INT', type=int, help='number of iterations (-1 to set no limit)',
default=-1)
default=0.5)
parser.add_argument('--k', metavar='BATCH', type=int, help='number of documents in a batch',
default=100)
parser.add_argument('--initsize', metavar='SIZE', type=int, help='number of labelled documents at the beginning',
default=2)
default=10)
parser.add_argument('--initprev', metavar='PREV', type=float,
help='prevalence of the initial sample (-1 for uniform sampling)',
default=0.5)
default=-1)
parser.add_argument('--seed', metavar='SEED', type=int,
help='random seed',
default=1)

View File

@ -33,11 +33,11 @@ class eDiscoveryPlot:
self.fig, self.axs = plt.subplots(nPlots)
self.calls=0
def plot(self, posteriors, y):
def plot(self):
if (self.calls+1) % self.refreshEach != 0:
self.calls+=1
return
# if (self.calls+1) % self.refreshEach != 0:
# self.calls+=1
# return
fig, axs = self.fig, self.axs
loop, save = self.loop, self.save
@ -99,18 +99,16 @@ class eDiscoveryPlot:
aXn += 1
# distribution of posterior probabilities in the pool
if self.showYdist:
positive_posteriors = posteriors[y==1,1]
negative_posteriors = posteriors[y==0,1]
#axs[aXn].hist([negative_posteriors, positive_posteriors], bins=50,
# label=['negative', 'positive'])
axs[aXn].hist(negative_posteriors, bins=50, label='negative', density=True, alpha=.75)
axs[aXn].hist(positive_posteriors, bins=50, label='positive', density=True, alpha=.75)
axs[aXn].legend()
axs[aXn].grid()
axs[aXn].set_xlim(0, 1)
axs[aXn].set_ylabel('te-$Pr(\oplus)$ distribution')
aXn += 1
# if self.showYdist:
# positive_posteriors = posteriors[y==1,1]
# negative_posteriors = posteriors[y==0,1]
# axs[aXn].hist(negative_posteriors, bins=50, label='negative', density=True, alpha=.75)
# axs[aXn].hist(positive_posteriors, bins=50, label='positive', density=True, alpha=.75)
# axs[aXn].legend()
# axs[aXn].grid()
# axs[aXn].set_xlim(0, 1)
# axs[aXn].set_ylabel('te-$Pr(\oplus)$ distribution')
# aXn += 1
axs[aXn].plot(xs, df['Shift'], '--k', label='shift (AE)')
axs[aXn].plot(xs, df['tr-prev'], 'y', label='tr-$Pr(\oplus)$')
@ -130,9 +128,9 @@ class eDiscoveryPlot:
# Put a legend to the right of the current axis
axs[i].legend(loc='center left', bbox_to_anchor=(1, 0.5))
if save:
os.makedirs(self.outdir, exist_ok=True)
plt.savefig(f'{self.outdir}/{self.plotname}')
# if save:
# os.makedirs(self.outdir, exist_ok=True)
# plt.savefig(f'{self.outdir}/{self.plotname}')
if loop:
plt.pause(.5)
@ -206,7 +204,8 @@ if __name__ == '__main__':
figure = eDiscoveryPlot(file)
try:
figure.plot(loop)
while True:
figure.plot()
except KeyboardInterrupt:
print('\n[stop]')