From f794bc5c1716d29da488bf7c03758d4a14bb44c6 Mon Sep 17 00:00:00 2001 From: Alejandro Moreo Date: Tue, 5 Jul 2022 15:13:28 +0200 Subject: [PATCH] repairing the plot --- eDiscovery/main.py | 6 +++--- eDiscovery/plot.py | 39 +++++++++++++++++++-------------------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/eDiscovery/main.py b/eDiscovery/main.py index f8b213e..1f4f934 100644 --- a/eDiscovery/main.py +++ b/eDiscovery/main.py @@ -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) diff --git a/eDiscovery/plot.py b/eDiscovery/plot.py index 649ef21..fb29f53 100644 --- a/eDiscovery/plot.py +++ b/eDiscovery/plot.py @@ -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]')