import gzip import os import sys from collections import Counter from Ordinal.utils import jaggedness import pickle import numpy as np amazon = np.genfromtxt('prevalence_votes1_reviews100.csv', delimiter='\t') telescope = np.genfromtxt('fact_real_prevalences.csv', delimiter=',')[1:] nclasses_amazon = amazon.shape[1] nclasses_telescope = telescope.shape[1] jags_amazon = np.asarray([jaggedness(p) for p in amazon]) jags_telescope = np.asarray([jaggedness(p) for p in telescope]) import matplotlib.pyplot as plt from matplotlib.pyplot import figure import seaborn as sns sns.set_theme('paper') sns.set_style('dark') sns.set(font_scale=0.7) # figure, axis = plt.subplots(1, 2, figsize=(8, 7)) ymax = 0.75 figure(figsize=(8, 4), dpi=300) ax=plt.subplot(1, 2, 1) classes = np.arange(1, nclasses_amazon+1) plt.bar(classes, np.mean(amazon, axis=0), yerr=np.std(amazon, axis=0), width=1) ax.set_ylim(0, ymax) ax.set_xlabel("stars") ax.set_xticks(classes) ax.set_title(f'Amazon Books ({jags_amazon.mean():.4f})') ax=plt.subplot(1, 2, 2) # ax=plt.subplot(1, 1, 1) classes = np.arange(1, nclasses_telescope+1) plt.bar(classes, np.mean(telescope, axis=0), yerr=np.std(telescope, axis=0), width=1) ax.set_ylim(0, ymax) ax.set_xlabel("energy bin") ax.set_xticks(classes) ax.set_title(f'FACT Samples ({jags_telescope.mean():.4f})') plt.subplots_adjust(wspace=0.1, hspace=0) plt.savefig('prevalence_averages.pdf', bbox_inches='tight')