import matplotlib.pyplot as plt

workloads_to_be_plotted = [
  "cmtDatasetSimple",
  "cmtDatasetComplex",
  "milanTelecomSimple",
  "milanTelecomComplex",
  "campaignExpendituresSimple",
  "campaignExpendituresComplex",
  "fedDisbursementsSimple",
  "fedDisbursementsComplex"
]

timing_types = [
  'Loading',
  'Summarization',
  'Scoring',
  'Training'
]

def parse_output_file(filename):
  parameters_description = None
  parsed_results = dict()
  with open(filename, 'r') as f:
    lines = f.read().split('\n')
    for i in xrange(len(lines)):
      line = lines[i]
      if "Running all workloads" in line:
        parameters_description = line.split("Running all workloads with ")[1].strip()
      if "Times" in line:
        [times, itemsets] = line.split(" , ")
        split_point = times.find(": ")
        times = eval(times[split_point+2:])
        itemsets = int(itemsets.split(": ")[1])
        workload_name = lines[i-1].split("-->")[0].strip()
        try:
          [parameter_type, parameter_value] = parameters_description.split(" = ")
        except:
          continue
        parameter_value = float(parameter_value)
        if parameter_type not in parsed_results:
          parsed_results[parameter_type] = dict()
          parsed_results[parameter_type][workload_name] = dict()
        if workload_name not in parsed_results[parameter_type]:
          parsed_results[parameter_type][workload_name] = dict()
        parsed_results[parameter_type][workload_name][parameter_value] = (times, itemsets)
  return parsed_results

def get_time(parsed_results, parameter_type, workload_name, parameter_value, timing_type):
  if timing_type == 'Total':
    tot_time = 0.0
    for timing_type_prime in timing_types:
      tot_time += parsed_results[parameter_type][workload_name][parameter_value][0][timing_type_prime.lower()]
    return tot_time
  return parsed_results[parameter_type][workload_name][parameter_value][0][timing_type.lower()]

def plot_graphs(parsed_results):
  for parameter_type in parsed_results:
    for timing_type in timing_types + ['Total']:
      plt.cla()
      plt.xscale('log')
      handles = list()
      for workload_name in parsed_results[parameter_type]:
        if workload_name not in workloads_to_be_plotted:
          continue
        keys = list()
        values = list()
        for parameter_value in sorted(parsed_results[parameter_type][workload_name].keys()):
          try:
            values.append(get_time(parsed_results, parameter_type, workload_name, parameter_value, timing_type))
            keys.append(parameter_value)
          except:
            continue
        handle, = plt.plot(keys, values, label=workload_name)
        handles.append(handle)
      lgd = plt.legend(handles=handles, loc=(0.0, -1.5))
      plt.xlabel(parameter_type)
      plt.ylabel(timing_type + " time (in milliseconds)")
      plt.savefig(parameter_type + "_" + timing_type + '.pdf', bbox_extra_artists=(lgd,), bbox_inches='tight')

if __name__ == '__main__':
  parsed_results = parse_output_file("parameter_sweep.out")
  plot_graphs(parsed_results)

@@ -1955,24 +1955,29 @@
 %5D%0A%0Adef plot_
+time_
 graphs(parse
@@ -1988,16 +1988,16 @@
 sults):%0A
-
   for pa
@@ -2975,16 +2975,905 @@
 ight')%0A%0A
+def plot_itemset_graphs(parsed_results):%0A  for parameter_type in parsed_results:%0A    plt.cla()%0A    plt.xscale('log')%0A    handles = list()%0A    for workload_name in parsed_results%5Bparameter_type%5D:%0A      if workload_name not in workloads_to_be_plotted:%0A        continue%0A      keys = list()%0A      values = list()%0A      for parameter_value in sorted(parsed_results%5Bparameter_type%5D%5Bworkload_name%5D.keys()):%0A        try:%0A          values.append(parsed_results%5Bparameter_type%5D%5Bworkload_name%5D%5Bparameter_value%5D%5B1%5D)%0A          keys.append(parameter_value)%0A        except:%0A          continue%0A      handle, = plt.plot(keys, values, label=workload_name)%0A      handles.append(handle)%0A    lgd = plt.legend(handles=handles, loc=(0.0, -1.5))%0A    plt.xlabel(parameter_type)%0A    plt.ylabel(%22Number of itemsets%22)%0A    plt.savefig(parameter_type + %22_Itemsets.pdf%22, bbox_extra_artists=(lgd,), bbox_inches='tight')%0A%0A
 if __nam
@@ -3955,15 +3955,58 @@
 t%22)%0A
-
   plot_
+time_graphs(parsed_results)%0A  plot_itemset_
 grap

Add itemset plotting