def plotInferenceStats(self,
                         fields,
                         plotDir="plots",
                         experimentID=0,
                         onePlot=True):
    """
    Plots and saves the desired inference statistics.

    Parameters:
    ----------------------------
    @param   fields (list(str))
             List of fields to include in the plots

    @param   experimentID (int)
             ID of the experiment (usually 0 if only one was conducted)

    @param   onePlot (bool)
             If true, all cortical columns will be merged in one plot.

    """
    if not os.path.exists(plotDir):
      os.makedirs(plotDir)

    plt.figure()
    stats = self.statistics[experimentID]
    objectName = stats["object"]

    for i in xrange(self.numColumns):
      if not onePlot:
        plt.figure()

      # plot request stats
      for field in fields:
        fieldKey = field + " C" + str(i)
        plt.plot(stats[fieldKey], marker='+', label=fieldKey)

      # format
      plt.legend(loc="upper right")
      plt.xlabel("Sensation #")
      plt.xticks(range(stats["numSteps"]))
      plt.ylabel("Number of active bits")
      plt.ylim(plt.ylim()[0] - 5, plt.ylim()[1] + 5)
      plt.title("Object inference for object {}".format(objectName))

      # save
      if not onePlot:
        relPath = "{}_exp_{}_C{}.png".format(self.name, experimentID, i)
        path = os.path.join(plotDir, relPath)
        plt.savefig(path)
        plt.close()

    if onePlot:
      relPath = "{}_exp_{}.png".format(self.name, experimentID)
      path = os.path.join(plotDir, relPath)
      plt.savefig(path)
      plt.close()
def plotInferenceStats ( self , fields , plotDir = "plots" , experimentID = 0 , onePlot = True ) : if not os . path . exists ( plotDir ) : os . makedirs ( plotDir ) plt . figure ( ) stats = self . statistics [ experimentID ] objectName = stats [ "object" ] for i in xrange ( self . numColumns ) : if not onePlot : plt . figure ( ) for field in fields : fieldKey = field + " C" + str ( i ) plt . plot ( stats [ fieldKey ] , marker = '+' , label = fieldKey ) plt . legend ( loc = "upper right" ) plt . xlabel ( "Sensation #" ) plt . xticks ( range ( stats [ "numSteps" ] ) ) plt . ylabel ( "Number of active bits" ) plt . ylim ( plt . ylim ( ) [ 0 ] - 5 , plt . ylim ( ) [ 1 ] + 5 ) plt . title ( "Object inference for object {}" . format ( objectName ) ) if not onePlot : relPath = "{}_exp_{}_C{}.png" . format ( self . name , experimentID , i ) path = os . path . join ( plotDir , relPath ) plt . savefig ( path ) plt . close ( ) if onePlot : relPath = "{}_exp_{}.png" . format ( self . name , experimentID ) path = os . path . join ( plotDir , relPath ) plt . savefig ( path ) plt . close ( )
Plots and saves the desired inference statistics.

    Parameters:
    ----------------------------
    @param   fields (list(str))
             List of fields to include in the plots

    @param   experimentID (int)
             ID of the experiment (usually 0 if only one was conducted)

    @param   onePlot (bool)
             If true, all cortical columns will be merged in one plot.