def trainTest(self,testSplit,**kw): idLab = self.idLab spDir = self.getSplitDirName(testSplit) makedir(spDir) idLabRec = idLab.getRecords() spIdLab = idLabRec.copy() spIdLab["split"] = 1 spIdLab["split"][idLabRec["split"]==testSplit] = 2 spIdLabFile = pjoin(spDir,"idlab.pkl") saveIdLabelRecords(records=spIdLab,fileName=spIdLabFile) spClOpt = copy(self.clOpt) spClOpt.labels = [spIdLabFile] spClOpt.predFile = pjoin(spDir,"pred.pkl") spClOpt.perfFile = pjoin(spDir,"perf.pkl") spClOpt.mode = "trainScatter" spClOpt.runMode = self.opt.runMode spClOpt.cwd = spDir spOptFile = self.getSplitOptFileName(testSplit) spApp = ClassifierApp(opt=spClOpt) spClOpt = spApp.getOpt() #get the missing options filled with defaults #that just saves a copy for us - App will create its own when it #submits a batch job (unique and slightly modified) dumpObj(spClOpt,spOptFile) kw = kw.copy() jobs = spApp.run(**kw) spClOpt.mode = "test" spApp = ClassifierApp(opt=spClOpt) kw["depend"] = jobs jobs = spApp.run(**kw) return jobs
def run(self, **kw): from MGT.ClassifierApp import ClassifierApp opt = self.opt opt.cwd = self.path # in case we moved it after __init__() opt.predFile = pjoin(opt.cwd, "pred.pkl") jobs = [] opt.mode = "predict" app = ClassifierApp(opt=opt) opt = app.getOpt() # get the missing options filled with defaults jobs = app.run(**kw) self.save() return jobs
def run(self, **kw): from MGT.ClassifierApp import ClassifierApp opt = self.opt opt.cwd = self.path # in case we moved it after __init__() jobs = [] opt.mode = "trainScatter" app = ClassifierApp(opt=opt) opt = app.getOpt() # get the missing options filled with defaults # we need to clean up the models directory otherwise we run a danger # of picking up old models that are not trained in this session rmrf(self.getFilePath(opt.modelRoot)) return app.run(**kw)
def run(self, **kw): from MGT.ClassifierApp import ClassifierApp opt = self.opt opt.cwd = self.path # in case we moved it after __init__() opt.predFile = pjoin(opt.cwd, "pred.pkl") opt.perfFile = pjoin(opt.cwd, "perf.pkl") jobs = [] opt.mode = "trainScatter" app = ClassifierApp(opt=opt) opt = app.getOpt() # get the missing options filled with defaults # we need to clean up the models directory otherwise we run a danger # of picking up old models that are not trained in this session rmrf(self.getFilePath(opt.modelRoot)) jobs = app.run(**kw) opt.mode = "test" app = ClassifierApp(opt=opt) opt = app.getOpt() # get the missing options filled with defaults self.save() kw = kw.copy() kw["depend"] = jobs jobs = app.run(**kw) return jobs
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## # # See COPYING file distributed along with the MGTAXA package for the # copyright and license terms. # ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## """Shell scripting interface to supervised classifiers.""" from MGT.ClassifierApp import ClassifierApp app = ClassifierApp() app.run()
else: raise ValueError(o.inFeatFormat) origFeat = [pjoin(testDataDir,"usps-train"+ext),pjoin(testDataDir,"usps-test"+ext)] o.inFeat = origFeat #o.inFeat = [pjoin(testDataDir,"usps.libsvm.pca")] o.labels = [ lf+".idlab" for lf in origFeat ] o.balanceTrainCounts=-1 return o testDataDir = pjoin(options.testDataDir,"usps") workDir = pjoin(os.getcwd(),"test_ClassifierApp.tmpdir") rmdir(workDir) makedir(workDir) os.chdir(workDir) clOpt = makeClOpt(testDataDir) clOpt.numTrainJobs = 1 #6 clOpt.MEM = 500 clOpt.LENGTH = "fast" clOpt.mode = "trainScatter" clOpt.runMode = "inproc" #"inproc" #"batchDep" print clOpt app = ClassifierApp(opt=clOpt) jobs = app.run(dryRun=False) clOpt.mode = "test" clOpt.perfFile = "perf.pkl" app = ClassifierApp(opt=clOpt) jobs = app.run(dryRun=False,depend=jobs)