wip
This commit is contained in:
@@ -13,20 +13,18 @@ colors = {'neg': 'red', 'neu': 'green', 'pos': 'blue', 'com': 'orange'}
|
||||
|
||||
|
||||
def main(folder):
|
||||
if folder.endswith("/"):
|
||||
folder = folder[:-1]
|
||||
onlyfiles = [f for f in listdir(folder)]
|
||||
onlyfiles = [f for f in onlyfiles if isfile(join(folder, f))]
|
||||
onlyfiles = [f for f in onlyfiles if f.endswith(".py")]
|
||||
# onlyfiles = [f[:-3] for f in onlyfiles]
|
||||
# onlyfiles = [f.replace(".", "\.") for f in onlyfiles]
|
||||
outputdir = folder + "/output/ksbatch/"
|
||||
os.system("mkdir -p " + outputdir)
|
||||
folder = folder + "/output/batch/"
|
||||
|
||||
onlyfiles = [folder + f for f in listdir(folder) if isfile(join(folder, f)) and f.endswith(".py")]
|
||||
onlyfiles = sorted(onlyfiles)
|
||||
plotbypost(onlyfiles)
|
||||
plotbydate(onlyfiles)
|
||||
|
||||
plotbypost(onlyfiles, outputdir)
|
||||
plotbydate(onlyfiles, outputdir)
|
||||
|
||||
|
||||
def plotbypost(onlyfiles):
|
||||
def plotbypost(onlyfiles, outputdir):
|
||||
files = defaultdict(list)
|
||||
for f in onlyfiles:
|
||||
s = f[:-3].split("_")
|
||||
@@ -43,8 +41,8 @@ def plotbypost(onlyfiles):
|
||||
continue
|
||||
print(p)
|
||||
for i in range(len(l) - 1):
|
||||
tox1 = imprt(folder + "/" + l[i]).toxlevels
|
||||
tox2 = imprt(folder + "/" + l[i + 1]).toxlevels
|
||||
tox1 = imprt(l[i]).toxlevels
|
||||
tox2 = imprt(l[i + 1]).toxlevels
|
||||
|
||||
neglevelsflat1 = [item['neg'] for item in flatmap(tox1.values())]
|
||||
neulevelsflat1 = [item['neu'] for item in flatmap(tox1.values())]
|
||||
@@ -67,7 +65,7 @@ def plotbypost(onlyfiles):
|
||||
changes_com[p].append(kscom)
|
||||
|
||||
for (p, l) in files.items():
|
||||
with open(folder + "/ks_" + str(p) + ".log", "w") as f:
|
||||
with open(outputdir + "/ks_post_" + str(p) + ".log", "w") as f:
|
||||
for i in range(len(l) - 1):
|
||||
f1 = l[i]
|
||||
f2 = l[i + 1]
|
||||
@@ -88,7 +86,7 @@ def plotbypost(onlyfiles):
|
||||
plt.title("KS 2-sided test with max " + str(p) + " posts")
|
||||
plt.xticks(rotation=90)
|
||||
plt.legend(loc="upper right")
|
||||
plt.savefig(folder + "/ks_pval_" + str(p) + ".png", bbox_inches='tight')
|
||||
plt.savefig(outputdir + "/ks_post_pval_" + str(p) + ".png", bbox_inches='tight')
|
||||
plt.close(fig)
|
||||
|
||||
# stat
|
||||
@@ -106,11 +104,11 @@ def plotbypost(onlyfiles):
|
||||
plt.title("KS 2-sided test with max " + str(p) + " posts")
|
||||
plt.xticks(rotation=90)
|
||||
plt.legend(loc="upper right")
|
||||
plt.savefig(folder + "/ks_stat_" + str(p) + ".png", bbox_inches='tight')
|
||||
plt.savefig(outputdir + "/ks_post_stat_" + str(p) + ".png", bbox_inches='tight')
|
||||
plt.close(fig)
|
||||
|
||||
|
||||
def plotbydate(onlyfiles):
|
||||
def plotbydate(onlyfiles, outputdir):
|
||||
files = defaultdict(list)
|
||||
for f in onlyfiles:
|
||||
s = f[:-3].split("_")
|
||||
@@ -127,8 +125,8 @@ def plotbydate(onlyfiles):
|
||||
continue
|
||||
print(d)
|
||||
for i in range(len(l) - 1):
|
||||
tox1 = imprt(folder + "/" + l[i]).toxlevels
|
||||
tox2 = imprt(folder + "/" + l[i + 1]).toxlevels
|
||||
tox1 = imprt(l[i]).toxlevels
|
||||
tox2 = imprt(l[i + 1]).toxlevels
|
||||
|
||||
neglevelsflat1 = [item['neg'] for item in flatmap(tox1.values())]
|
||||
neulevelsflat1 = [item['neu'] for item in flatmap(tox1.values())]
|
||||
@@ -151,7 +149,7 @@ def plotbydate(onlyfiles):
|
||||
changes_com[d].append(kscom)
|
||||
|
||||
for (d, l) in files.items():
|
||||
with open(folder + "/ks_" + d[0] + "_" + d[1] + ".log", "w") as f:
|
||||
with open(outputdir + "/ks_date_" + d[0] + "_" + d[1] + ".log", "w") as f:
|
||||
for i in range(len(l) - 1):
|
||||
f1 = l[i]
|
||||
f2 = l[i + 1]
|
||||
@@ -173,7 +171,7 @@ def plotbydate(onlyfiles):
|
||||
plt.title("KS 2-sided test with between " + d[0] + " and " + d[1])
|
||||
plt.xticks(rotation=90)
|
||||
plt.legend(loc="upper right")
|
||||
plt.savefig(folder + "/ks_pval_" + d[0] + "_" + d[1] + ".png", bbox_inches='tight')
|
||||
plt.savefig(outputdir + "/ks_date_pval_" + d[0] + "_" + d[1] + ".png", bbox_inches='tight')
|
||||
plt.close(fig)
|
||||
|
||||
# stat
|
||||
@@ -191,7 +189,7 @@ def plotbydate(onlyfiles):
|
||||
plt.title("KS 2-sided test with between " + d[0] + " and " + d[1])
|
||||
plt.xticks(rotation=90)
|
||||
plt.legend(loc="upper right")
|
||||
plt.savefig(folder + "/ks_stat_" + d[0] + "_" + d[1] + ".png", bbox_inches='tight')
|
||||
plt.savefig(outputdir + "/ks_date_stat_" + d[0] + "_" + d[1] + ".png", bbox_inches='tight')
|
||||
plt.close(fig)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user