Example #1
0
   def make_plot_FMQUERYTIME(self):
      # This graph shows the time spent training vs. the data set size

      exp_no = FMQUERYTIME

      plot_dir = OUTPUT_DIR + "fm_query_time/"
      os.mkdir(plot_dir)

      gnuplot_script = open(plot_dir + 'plot.gp', 'w')
      print >> gnuplot_script, """
set terminal png nocrop enhanced size 400, 400
set output "plot.png"
set xlabel "Data Set Size"
set ylabel "Average Query Time (Seconds)"
set key top left
set title "Forward Mapping Query Time (%s)"
""" % self._exp.name

      mi = int(numpy.floor(2 * self._exp.training_sizes[0] - self._exp.training_sizes[1]))
      ma = int(numpy.ceil(2 * self._exp.training_sizes[-1] - self._exp.training_sizes[-2]))
      print >> gnuplot_script, "set xrange [%d:%d]" % (mi, ma)

      print >> gnuplot_script, 'plot ',

      first = True
      for reg, params in self._exp.regressions:
         label = labelize(reg, params)

         if first:
            first = False
         else:
            print >> gnuplot_script, ", ",

         out_file = open(plot_dir + "%s" % reg.name, 'w')
         print >> gnuplot_script, '"%s" with errorbars' % reg.name,

         for training_size in self._exp.training_sizes:
            key = (label, training_size)

            # this is the list of times
            times = self._fm_results[key][exp_no]

            # average them
            avg, lower, upper = misc.errorbars(times)
            
            print >> out_file, "%d %f %f %f" % (training_size, avg, lower, upper)

         out_file.close()

      print >> gnuplot_script, '\n',
      gnuplot_script.close()

      curdir = os.path.abspath('.')
      os.chdir(plot_dir)
      os.system('gnuplot ' +'plot.gp')
      os.chdir(curdir)
Example #2
0
   def make_plot_RMQUERYTIME(self):
      # This graph shows the time spent training vs. the data set size

      exp_no = RMQUERYTIME

      plot_dir = OUTPUT_DIR + "rm_query_time/"
      os.mkdir(plot_dir)

      gnuplot_script = open(plot_dir + 'plot.gp', 'w')
      print >> gnuplot_script, """
set terminal png nocrop enhanced size 400, 400
set output "plot.png"
set xlabel "Granularity"
set ylabel "Average Query Time (Seconds)"
set nokey
set title "Reverse Mapping Query Time (%s)"
""" % self._exp.name

      mi = int(numpy.floor(2 * self._exp.rm_granularities[0] - self._exp.rm_granularities[1]))
      ma = int(numpy.ceil(2 * self._exp.rm_granularities[-1] - self._exp.rm_granularities[-2]))
      print >> gnuplot_script, "set xrange [%d:%d]" % (mi, ma)

      print >> gnuplot_script, 'plot "rm_times" with errorbars, "rm_times" with lines',

      out_file = open(plot_dir + "rm_times", 'w')

      for gran in self._exp.rm_granularities:
         times = self._rm_results[gran][exp_no]

         avg, lower, upper = misc.errorbars(times)

         print >> out_file, "%d %f %f %f" % (gran, avg, lower, upper)


      out_file.close()

      print >> gnuplot_script, '\n',
      gnuplot_script.close()

      curdir = os.path.abspath('.')
      os.chdir(plot_dir)
      os.system('gnuplot ' +'plot.gp')
      os.chdir(curdir)