Mentions légales du service

Skip to content
Snippets Groups Projects
Commit a2284d25 authored by AGUIRRE-CERVANTES Jose-Luis's avatar AGUIRRE-CERVANTES Jose-Luis
Browse files

cleaning old code

parent d93eb118
No related branches found
No related tags found
No related merge requests found
......@@ -11,53 +11,7 @@ dict_ops = {'size':['Size','size'],'successrate':['Succes rate','srate'],'f-meas
sep = os.environ.get("sep", " ") # default to space
#### All this is legacy code for the first Notebook generation
def plot_average_curve_for_list_of_patterns( data, label, col, ops, maxval, nbgames, pattern_list ):
fig = plt.figure(figsize=(12,3))
ax = plt.gca()
linestylelist = ['solid', 'dashed', 'dotted', 'dashdot']
ind = 0
for pattern, ls in zip( pattern_list, linestylelist ):
plt.gca().set_prop_cycle(None)
for op in ops:
data[ind].iloc[1::100].plot(kind='line',y=col, label=op, ax=ax, linestyle=ls, linewidth=1.0) #, marker='*', color='blue'
ind += 1
ax.set_xlabel('games') # Add an x-label to the axes.
ax.set_xlim([0,nbgames])
ax.set_ylabel(label) # Add a y-label to the axes.
ax.set_ylim([0,maxval])
#ax.set_ylim([0,100])
ax.spines['top'].set_visible(False) # suppress top and right bars
ax.spines['right'].set_visible(False)
#
#ax.set_title(label+" for "+pattern) # Add a title to the axes.
ax.set_title(label) # Add a title to the axes.
#ax.legend(loc='center', bbox_to_anchor=(0.5, -0.05), shadow=True, ncol=2) # Add a legend.
ax.legend() # ncol=2
#
plt.show()
# Returns an ordered array of the data for a list of patterns
def prepare_pattern_list_simple_data ( ops, nbgames, pattern_list, results_directory, observed_variables ):
dataArray = []
for pattern in pattern_list:
for op in ops:
dataArray.append( load_norm_data( pattern.replace( "%%", op ), results_directory, observed_variables ) )
return dataArray
def print_data_series( pattern_list, nbiter, results_directory, observed_variables ):
allops = ['delete','replace','refine','add','addjoin','refadd']
dataframes = prepare_pattern_list_simple_data( allops, nbiter, pattern_list, results_directory, observed_variables )
# here it would be good to scrap the MAXSIZE. This can be done in the data
plot_average_curve( dataframes, "Size", 'size', allops, 120, nbiter, pattern_list )
plot_average_curve( dataframes, "Success rate", 'srate', allops, 1, nbiter, pattern_list )
plot_average_curve( dataframes, "Precision", 'prec', allops, 1, nbiter, pattern_list )
plot_average_curve( dataframes, "F-measure", 'fmeas', allops, 1, nbiter, pattern_list )
plot_average_curve( dataframes, "Recall", 'rec', allops, 1, nbiter, pattern_list )
#### All this is new code for Notebook generation
#### New code for Notebook generation
# Returns the prefix of the files in the results directory of the experience 'label'
# prefix could be label+nbAgents+nbIterations or just nbAgents+nbIterations
......@@ -128,42 +82,6 @@ def prepare_data_for_labels(labelpatts,base_directory,observed_variables):
dataDict[filepattern] = df
return(dataDict)
# Prepare data for all plots
#Returns a dictionary where the keys are combinations of an experience+pattern
def prepare_all_dataOld(allplots,results_directory,labelexp,prefix,ops,observed_variables):
dataDict = {}
for group in allplots:
#a group: [[['Size', 'Games', '10000', '120'], ['20180601-NOOR', 'clever-nr-gen'], ['20180529-NOOR', 'clever-nr']], [['Size', 'Games (im80)', '10000', '120'], ['20180601-NOOR', 'clever-nr-im80-gen'], ['20180530-NOOR', 'clever-nr-im80']]]
for plot in group:
#a plot: [['Size', 'Games', '10000', '120'], ['20180601-NOOR', 'clever-nr-gen'], ['20180529-NOOR', 'clever-nr']]
for filepair in plot[1:]:
#a filepair: ['20180601-NOOR', 'clever-nr-gen']
#filepair[0] can be the current experience or other experience
#filepair[1] is a pattern
filepattern = filepair[0]+filepair[1]
if not (filepattern in dataDict):
#This is for manage cases where there is no pattern, files concern just operators
opPattern = '%%-'
if filepair[1] == '':
opPattern = '%%'
#We look for the directory containing result files and also for the prefix of the files in that directory
# LABEL+NBAGENTS+ITERATIONS or just NBAGENTS+ITERATIONS
filesprefix = prefix
resdir = results_directory
if not filepair[0] == labelexp:
#if (not filepair[0] == labelexp) and (labelexp != '20170529-NOOR'):
local_directory = os.getcwd()
resdir = local_directory+'/../'+filepair[0]+'/results/'
filesprefix = getPrefix(resdir,filepair[0],'tsv')
#This also works for resdir
#resdir = results_directory+'/../../'+filepair[0]+'/results/'
#display("Will prepare dataframe for "+filesprefix+filepair[1]+" in "+resdir)
if (labelexp == '20170208-NOOR'):
ops = ['add','del','repl']
df = prepare_pattern_data(ops,filesprefix+opPattern+filepair[1],resdir,observed_variables)
dataDict[filepattern] = df
return(dataDict)
# Prepare data needed for all plots
# Returns a dictionary where the keys are combinations of an experience+pattern
def prepare_all_data(expPatterns,results_directory,labelexp,prefix,ops,observed_variables):
......@@ -237,7 +155,7 @@ def plot_datafiles_curve( alldata, indexes, ops, ylabel, xlabel, xmax, ymax, col
#
plt.show()
def plot_average_curve( alldata, indexes, ylabel, xlabel, xmax, ymax, col, ops, nbgames ):
def plot_average_curve( alldata, indexes, ylabel, xlabel, xmax, ymax, col, ops ):
fig = plt.figure(figsize=(12,3))
ax = plt.gca()
linestylelist = ['solid', 'dashed', 'dotted', 'dashdot']
......@@ -279,7 +197,7 @@ def print_datafiles( alldf, plotinfo, labelpatts, cols, nbiter ):
#plot_datafiles_curve_data( alldf, indexes, cols )
plot_datafiles_curve( alldf, indexes, cols, plotlabel, xlabel, xmax, ymax, col, nbiter )
def print_one_series( alldf, plotinfo, patterns, operators, nbiter ):
def print_one_series( alldf, plotinfo, patterns, operators ):
# plotinfo: ['Size', 'Games', '10000', '120']
# patterns: [['20180601-NOOR', 'clever-nr-gen'], ['20180529-NOOR', 'clever-nr']]
#print("Will build plot for ")
......@@ -294,14 +212,9 @@ def print_one_series( alldf, plotinfo, patterns, operators, nbiter ):
xlabel = plotinfo[1]
xmax = int(plotinfo[2])
ymax = int(plotinfo[3])
plot_average_curve( alldf, indexes, plotlabel, xlabel, xmax, ymax, col, operators, nbiter )
plot_average_curve( alldf, indexes, plotlabel, xlabel, xmax, ymax, col, operators )
### Print all plots of an experience extracted from the latexfile
#def print_all_series( label, latexfile, prefix, nbiter, results_directory, operators, observed_variables ):
#allplots = getPlots(latexfile,label,'[0-9]-[0-9]+-')
#print(plots)
#def print_all_series( label, allplots, prefix, nbiter, results_directory, operators, observed_variables ):
# alldf = prepare_all_data(allplots,results_directory,label,prefix,operators,observed_variables)
def print_all_series( allplots, alldf, operators, nbiter ):
for group in allplots:
for plot in group:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment