parameters: (nfold, dataset, groundTruth, trainingFunc, seed=None, *args, **kwargs)
return_statement: return confusion
docstring: Evaluate the classifier on the given dataset and returns the confusion matrix.
  
      The evaluation is performed using n-fold cross validation.
      Uses only the points that are in the groundTruth parameter for the evaluation.
  
      Parameters
      ----------
  
      nfold        : the number of folds to use for the cross-validation
      dataset      : the dataset from which to get the points
      groundTruth  : a map from the points to classify to their respective class
      trainingFunc : a function which will train and return a classifier given a dataset,
                     the groundtruth, and the *args and **kwargs arguments
docstring_summary: Evaluate the classifier on the given dataset and returns the confusion matrix.
docstring_tokens: Evaluate the classifier on the given dataset and returns the confusion matrix .
function: def evaluateNfold(nfold, dataset, groundTruth, trainingFunc, seed=None, *args, **kwargs):
      """Evaluate the classifier on the given dataset and returns the confusion matrix.
  
      The evaluation is performed using n-fold cross validation.
      Uses only the points that are in the groundTruth parameter for the evaluation.
  
      Parameters
      ----------
  
      nfold        : the number of folds to use for the cross-validation
      dataset      : the dataset from which to get the points
      groundTruth  : a map from the points to classify to their respective class
      trainingFunc : a function which will train and return a classifier given a dataset,
                     the groundtruth, and the *args and **kwargs arguments
      """
      log.info('Doing %d-fold cross validation' % nfold)
      classes = set(groundTruth.values())
      progress = TextProgress(nfold, 'Evaluating fold %(current)d/%(total)d')
  
      # get map from class to point names
      iclasses = {}
      for c in classes:
          iclasses[c] = [ p for p in groundTruth.keys() if groundTruth[p] == c ]
          random.seed(a=seed)
          random.shuffle(iclasses[c])
  
      # get folds
      folds = {}
      for i in range(nfold):
          folds[i] = []
          for c in iclasses.values():
              foldsize = (len(c)-1)//nfold + 1 # -1/+1 so we take all instances into account, last fold might have fewer instances
              folds[i] += c[ foldsize * i : foldsize * (i+1) ]
  
      # build sub-datasets and run evaluation on them
      confusion = None
      pnames = [ p.name() for p in dataset.points() ]
  
      for i in range(nfold):
          if log.isEnabledFor(logging.INFO):
              progress.update(i+1)
  
          trainds = DataSet()
          trainds.addPoints([ dataset.point(pname) for pname in pnames if pname not in folds[i] ])
          traingt = GroundTruth(groundTruth.className, dict([ (p, c) for p, c in groundTruth.items() if p not in folds[i] ]))
  
          testds = DataSet()
          testds.addPoints([ dataset.point(str(pname)) for pname in folds[i] ])
          testgt = GroundTruth(groundTruth.className, dict([ (p, c) for p, c in groundTruth.items() if p in folds[i] ]))
  
          classifier = trainingFunc(trainds, traingt, *args, **kwargs)
          confusion = evaluate(classifier, testds, testgt, confusion, nfold=i, verbose=False)
  
      return confusion
function_tokens: def evaluateNfold ( nfold , dataset , groundTruth , trainingFunc , seed = None , * args , * * kwargs ) : log . info ( 'Doing %d-fold cross validation' % nfold ) classes = set ( groundTruth . values ( ) ) progress = TextProgress ( nfold , 'Evaluating fold %(current)d/%(total)d' ) # get map from class to point names iclasses = { } for c in classes : iclasses [ c ] = [ p for p in groundTruth . keys ( ) if groundTruth [ p ] == c ] random . seed ( a = seed ) random . shuffle ( iclasses [ c ] ) # get folds folds = { } for i in range ( nfold ) : folds [ i ] = [ ] for c in iclasses . values ( ) : foldsize = ( len ( c ) - 1 ) // nfold + 1 # -1/+1 so we take all instances into account, last fold might have fewer instances folds [ i ] += c [ foldsize * i : foldsize * ( i + 1 ) ] # build sub-datasets and run evaluation on them confusion = None pnames = [ p . name ( ) for p in dataset . points ( ) ] for i in range ( nfold ) : if log . isEnabledFor ( logging . INFO ) : progress . update ( i + 1 ) trainds = DataSet ( ) trainds . addPoints ( [ dataset . point ( pname ) for pname in pnames if pname not in folds [ i ] ] ) traingt = GroundTruth ( groundTruth . className , dict ( [ ( p , c ) for p , c in groundTruth . items ( ) if p not in folds [ i ] ] ) ) testds = DataSet ( ) testds . addPoints ( [ dataset . point ( str ( pname ) ) for pname in folds [ i ] ] ) testgt = GroundTruth ( groundTruth . className , dict ( [ ( p , c ) for p , c in groundTruth . items ( ) if p in folds [ i ] ] ) ) classifier = trainingFunc ( trainds , traingt , * args , * * kwargs ) confusion = evaluate ( classifier , testds , testgt , confusion , nfold = i , verbose = False ) return confusion