Ejemplo n.º 1
0
def main(base, suffix, stayWeight, treeOptions, students, useWeka):
    makeDirs(base, False)
    header, studentData = readStudents(base, students)
    filename = makeTemp('.arff')
    try:
        writeData(header, studentData, filename)
        if len(suffix) > 0:
            if suffix[0] != '-':
                suffix = '-' + suffix
        dest = 'common%s' % (suffix)
        createDT(filename, base, dest, stayWeight, treeOptions, useWeka)
    finally:
        os.remove(filename)
Ejemplo n.º 2
0
def main(base,suffix,stayWeight,treeOptions,students,useWeka):
  makeDirs(base,False)
  header,studentData = readStudents(base,students)
  filename = makeTemp('.arff')
  try:
    writeData(header,studentData,filename)
    if len(suffix) > 0:
      if suffix[0] != '-':
        suffix = '-' + suffix
    dest = 'common%s' % (suffix)
    createDT(filename,base,dest,stayWeight,treeOptions,useWeka)
  finally:
    os.remove(filename)
Ejemplo n.º 3
0
def main(base,suffix,stayWeight,treeOptions,students,useWeka,onlyInd):
  makeDirs(base,False)
  header,studentData = readStudents(base,students)
  for i,student in enumerate(students):
    if (onlyInd is not None) and (i != onlyInd):
      continue
    if len(suffix) > 0:
      if suffix[0] != '-':
        suffix = '-' + suffix
    dest = 'leaveOneOut-%s%s' % (student,suffix)
    print '-------------------'
    print student
    print '-------------------'
    processStudent(base,dest,i,header,studentData,treeOptions,stayWeight,useWeka)
Ejemplo n.º 4
0
def main(base, suffix, stayWeight, treeOptions, students, useWeka, onlyInd):
    makeDirs(base, False)
    header, studentData = readStudents(base, students)
    for i, student in enumerate(students):
        if (onlyInd is not None) and (i != onlyInd):
            continue
        if len(suffix) > 0:
            if suffix[0] != '-':
                suffix = '-' + suffix
        dest = 'leaveOneOut-%s%s' % (student, suffix)
        print '-------------------'
        print student
        print '-------------------'
        processStudent(base, dest, i, header, studentData, treeOptions,
                       stayWeight, useWeka)
Ejemplo n.º 5
0
      tmpData = inFile
    else:
      print 'Removing trial and step features'
      removeTrialStep(inFile,tmpData,numInstances)
    if randomTree:
      tmpDataSampled = makeTemp('-sampled.arff')
      removeFiles.append(tmpDataSampled)
      for i in range(numRandomTrees):
        if (randomTreeInd is not None) and (i != randomTreeInd):
          continue
        print '*** Random Tree %i' % i
        resample(tmpData,tmpDataSampled,resampleFrac)
        makeTree(tmpDataSampled,useWeka,stayWeight,base,name + '-%i' % i,treeOptions,randomTree,featureFrac)
    else:
      makeTree(tmpData,useWeka,stayWeight,base,name,treeOptions,randomTree,featureFrac)
    print 'Done.'
  finally:
    for f in removeFiles:
      os.remove(f)

if __name__ == '__main__':
  usage = '%prog [options] inFile base name [-- treeOptions]'
  options,args,treeOptions = parseArgs(usage=usage,numArgs=3,studentOptions=False,numInstancesFlag=True)
  inFile = args[0]
  base = args[1]
  name = args[2]
  stayWeight = None

  makeDirs(base,printWarning=False)
  main(inFile,base,name,stayWeight,treeOptions,options.useWeka,options.numInstances)
Ejemplo n.º 6
0
                if (randomTreeInd is not None) and (i != randomTreeInd):
                    continue
                print '*** Random Tree %i' % i
                resample(tmpData, tmpDataSampled, resampleFrac)
                makeTree(tmpDataSampled, useWeka, stayWeight, base,
                         name + '-%i' % i, treeOptions, randomTree,
                         featureFrac)
        else:
            makeTree(tmpData, useWeka, stayWeight, base, name, treeOptions,
                     randomTree, featureFrac)
        print 'Done.'
    finally:
        for f in removeFiles:
            os.remove(f)


if __name__ == '__main__':
    usage = '%prog [options] inFile base name [-- treeOptions]'
    options, args, treeOptions = parseArgs(usage=usage,
                                           numArgs=3,
                                           studentOptions=False,
                                           numInstancesFlag=True)
    inFile = args[0]
    base = args[1]
    name = args[2]
    stayWeight = None

    makeDirs(base, printWarning=False)
    main(inFile, base, name, stayWeight, treeOptions, options.useWeka,
         options.numInstances)