parameters: (learning_curve,ax,costs_all=[],cost_labels=[])
return_statement: return lines
docstring: Plot a learning curve.
      \param[in] learing_curve A learning curve that has the following format
          #rows is number of optimization updates
          column 0: Number of samples at which the cost was evaluated
          column 1: The total cost 
          column 2...: Individual cost components (column 1 is their sum)
      \param[in] ax Axis to plot the learning curve on.
      \param[in] costs_all Vector of costs of each sample (default=[])
      \param[in] cost_labels Vector of strings for the different cost components  (default=[]).
docstring_summary: Plot a learning curve.
      \param[in] learing_curve A learning curve that has the following format
          #rows is number of optimization updates
          column 0: Number of samples at which the cost was evaluated
          column 1: The total cost 
          column 2...: Individual cost components (column 1 is their sum)
      \param[in] ax Axis to plot the learning curve on.
      \param[in] costs_all Vector of costs of each sample (default=[])
      \param[in] cost_labels Vector of strings for the different cost components  (default=[]).
docstring_tokens: Plot a learning curve . \ param [ in ] learing_curve A learning curve that has the following format #rows is number of optimization updates column 0 : Number of samples at which the cost was evaluated column 1 : The total cost column 2 ... : Individual cost components ( column 1 is their sum ) \ param [ in ] ax Axis to plot the learning curve on . \ param [ in ] costs_all Vector of costs of each sample ( default = [] ) \ param [ in ] cost_labels Vector of strings for the different cost components ( default = [] ) .
function: def plotLearningCurve(learning_curve,ax,costs_all=[],cost_labels=[]):
      """ Plot a learning curve.
      \param[in] learing_curve A learning curve that has the following format
          #rows is number of optimization updates
          column 0: Number of samples at which the cost was evaluated
          column 1: The total cost 
          column 2...: Individual cost components (column 1 is their sum)
      \param[in] ax Axis to plot the learning curve on.
      \param[in] costs_all Vector of costs of each sample (default=[])
      \param[in] cost_labels Vector of strings for the different cost components  (default=[]).
      """
  
      # Plot (sum of) costs of all individual samples 
      if (len(costs_all)>0):
          # costs_all may also contain individual cost components. Only take
          # first one, because it represents the sum of the individual comps.
          costs_all = np.atleast_2d(costs_all)[:,0]
          ax.plot(costs_all,'.',color='gray')
          
      # Plot costs at evaluations 
      learning_curve = np.array(learning_curve)
      # Sum of cost components
      samples_eval = learning_curve[:,0]
      costs_eval = learning_curve[:,1:]
      lines = ax.plot(samples_eval,costs_eval[:,0],'-',color='black',linewidth=2)
      # Individual cost components
      if costs_eval.shape[1]>1:
          lines.extend(ax.plot(samples_eval,costs_eval[:,1:],'-',linewidth=1))
          
      #max_eval = 1.2*np.max(costs_eval)
      #for sample_eval in samples_eval:
      #    ax.plot([sample_eval,sample_eval],[0,max_eval],'-',color=[0.9,0.9,0.9],linewidth=1)
      
      # Annotation
      ax.set_xlabel('number of evaluations')
      ax.set_ylabel('cost')
      ax.set_title('Learning curve')
      
      if len(cost_labels)>0:
          cost_labels.insert(0,'total cost')
          plt.legend(lines, cost_labels)
  
      y_limits = [0,1.2*np.max(costs_eval)]
      plotUpdateLines(samples_eval,ax,y_limits)
          
      ax.set_ylim(y_limits)
      
      
      return lines
function_tokens: def plotLearningCurve ( learning_curve , ax , costs_all = [ ] , cost_labels = [ ] ) : # Plot (sum of) costs of all individual samples  if ( len ( costs_all ) > 0 ) : # costs_all may also contain individual cost components. Only take # first one, because it represents the sum of the individual comps. costs_all = np . atleast_2d ( costs_all ) [ : , 0 ] ax . plot ( costs_all , '.' , color = 'gray' ) # Plot costs at evaluations  learning_curve = np . array ( learning_curve ) # Sum of cost components samples_eval = learning_curve [ : , 0 ] costs_eval = learning_curve [ : , 1 : ] lines = ax . plot ( samples_eval , costs_eval [ : , 0 ] , '-' , color = 'black' , linewidth = 2 ) # Individual cost components if costs_eval . shape [ 1 ] > 1 : lines . extend ( ax . plot ( samples_eval , costs_eval [ : , 1 : ] , '-' , linewidth = 1 ) ) #max_eval = 1.2*np.max(costs_eval) #for sample_eval in samples_eval: #    ax.plot([sample_eval,sample_eval],[0,max_eval],'-',color=[0.9,0.9,0.9],linewidth=1) # Annotation ax . set_xlabel ( 'number of evaluations' ) ax . set_ylabel ( 'cost' ) ax . set_title ( 'Learning curve' ) if len ( cost_labels ) > 0 : cost_labels . insert ( 0 , 'total cost' ) plt . legend ( lines , cost_labels ) y_limits = [ 0 , 1.2 * np . max ( costs_eval ) ] plotUpdateLines ( samples_eval , ax , y_limits ) ax . set_ylim ( y_limits ) return lines