original_docstring:  Add the new sample to the training set if it satisfies some
              criteria.
  
              :param data:  A new sample for the training set.
              :type  data:  list of float
              :param class_label:    The label of the new sample.
              :type  class_label:    str
              :rtype: [flag if new data is in training set, flag if retraining is
                      required (the new point is a potential sv or a removed
                      one was a sv)]
          
docstring: Add the new sample to the training set if it satisfies some
  criteria.
docstring_tokens: Add the new sample to the training set if it satisfies some criteria .
code: def select_new_data(self, data, class_label):
          """ Add the new sample to the training set if it satisfies some
              criteria.
  
              :param data:  A new sample for the training set.
              :type  data:  list of float
              :param class_label:    The label of the new sample.
              :type  class_label:    str
              :rtype: [flag if new data is in training set, flag if retraining is
                      required (the new point is a potential sv or a removed
                      one was a sv)]
          """
          ret_label = None
  
          retraining_required = False
          new_data_in_training_set = False
  
          if self.add_type == "ONLY_MISSCLASSIFIED":
              # get the prediction for the current data
              predictionVec = self._execute(data)
              # only append misclassified data points to training set
              if predictionVec.label != class_label:
                  if self.discard_type != "INC":
                      self.add_new_sample(data, class_label)
                      ret_label = self.classes.index(class_label)
                      # no need to check if potential support vector
                      # already confirmed with criteria
                      retraining_required = True
                  else:
                      new_data_in_training_set = True
          elif self.add_type == "ADD_ALL":
              # add all incomming samples
              if self.discard_type != "INC":
                  self.add_new_sample(data, class_label)
                  ret_label = self.classes.index(class_label)
                  retraining_required =\
                      self.is_potential_support_vector(data, class_label)
              else:
                  new_data_in_training_set = True
          elif self.add_type == "ONLY_WITHIN_MARGIN":
              # append only samples that are within the margin
              # (not on the other side of own border, but really between those
              # borderlines)
              predictionVec = self._execute(data)
              if abs(predictionVec.prediction) < 1.0:
                  if self.discard_type != "INC":
                      self.add_new_sample(data, class_label)
                      ret_label = self.classes.index(class_label)
                      retraining_required =\
                          self.is_potential_support_vector(data, class_label)
                  else:
                      new_data_in_training_set = True
          elif self.add_type == "UNSUPERVISED_PROB":
              # unsupervised classification
              # only append those samples that were most probably right
              # classified
              for i in numpy.arange(len(self.decisions), self.num_samples):
                  predictionVec = self._execute(\
                                      numpy.atleast_2d(self.samples[i]))
                  self.decisions.append(predictionVec.prediction)
              # get number of target and standard samples
              prior1 = sum(map(lambda x: x == 1, self.labels))
              prior0 = self.num_samples - prior1
              # get labels as list of trues and falses
              labels = map(lambda x: x == 1, self.labels)
  
              # calculate the label and the probability for the label of the
              # given data
              [p, label] = self.get_platt_prob(self.decisions,
                                               labels,
                                               prior1, prior0,
                                               data)
  
              if p > self.p_threshold:
                  self.decisions.append(p)
                  if self.discard_type != "INC":
                      self.add_new_sample(data, label)
                      ret_label = self.classes.index(label)
                      retraining_required =\
                          self.is_potential_support_vector(data, label)
                  else:
                      new_data_in_training_set = True
  
          return [new_data_in_training_set, retraining_required, ret_label]
code_tokens: def select_new_data ( self , data , class_label ) : ret_label = None retraining_required = False new_data_in_training_set = False if self . add_type == "ONLY_MISSCLASSIFIED" : predictionVec = self . _execute ( data ) if predictionVec . label != class_label : if self . discard_type != "INC" : self . add_new_sample ( data , class_label ) ret_label = self . classes . index ( class_label ) retraining_required = True else : new_data_in_training_set = True elif self . add_type == "ADD_ALL" : if self . discard_type != "INC" : self . add_new_sample ( data , class_label ) ret_label = self . classes . index ( class_label ) retraining_required = self . is_potential_support_vector ( data , class_label ) else : new_data_in_training_set = True elif self . add_type == "ONLY_WITHIN_MARGIN" : predictionVec = self . _execute ( data ) if abs ( predictionVec . prediction ) < 1.0 : if self . discard_type != "INC" : self . add_new_sample ( data , class_label ) ret_label = self . classes . index ( class_label ) retraining_required = self . is_potential_support_vector ( data , class_label ) else : new_data_in_training_set = True elif self . add_type == "UNSUPERVISED_PROB" : for i in numpy . arange ( len ( self . decisions ) , self . num_samples ) : predictionVec = self . _execute ( numpy . atleast_2d ( self . samples [ i ] ) ) self . decisions . append ( predictionVec . prediction ) prior1 = sum ( map ( lambda x : x == 1 , self . labels ) ) prior0 = self . num_samples - prior1 labels = map ( lambda x : x == 1 , self . labels ) [ p , label ] = self . get_platt_prob ( self . decisions , labels , prior1 , prior0 , data ) if p > self . p_threshold : self . decisions . append ( p ) if self . discard_type != "INC" : self . add_new_sample ( data , label ) ret_label = self . classes . index ( label ) retraining_required = self . is_potential_support_vector ( data , label ) else : new_data_in_training_set = True return [ new_data_in_training_set , retraining_required , ret_label ]
short_docstring: Add the new sample to the training set if it satisfies some
  criteria.
short_docstring_tokens: Add the new sample to the training set if it satisfies some criteria .
comment: """ Add the new sample to the training set if it satisfies some
              criteria.
  
              :param data:  A new sample for the training set.
              :type  data:  list of float
              :param class_label:    The label of the new sample.
              :type  class_label:    str
              :rtype: [flag if new data is in training set, flag if retraining is
                      required (the new point is a potential sv or a removed
                      one was a sv)]
          """$SEP$# get the prediction for the current data$SEP$# only append misclassified data points to training set$SEP$# no need to check if potential support vector$SEP$# already confirmed with criteria$SEP$# add all incomming samples$SEP$# append only samples that are within the margin$SEP$# (not on the other side of own border, but really between those$SEP$# borderlines)$SEP$# unsupervised classification$SEP$# only append those samples that were most probably right$SEP$# classified$SEP$# get number of target and standard samples$SEP$# get labels as list of trues and falses$SEP$# calculate the label and the probability for the label of the$SEP$# given data