Exemplo n.º 1
0
 def crossVal(self,param,idParam,**kw):
     opt = self.opt
     cvDir = self.getCvDirName(idParam)
     rmdir(cvDir)
     makedir(cvDir)
     cvClOpt = copy(self.clOpt)
     for parName in param.dtype.names:
         parVal = param[parName]
         setattr(cvClOpt,parName,parVal.item()) #convert numpy scalar to python built-in type
     cvOpt = Struct(clOpt=cvClOpt)
     cvOpt.predFile = pjoin(cvDir,"pred.pkl")
     cvOpt.perfFile = pjoin(cvDir,"perf.pkl")
     cvOpt.mode = "scatter"
     cvOpt.runMode = opt.runMode
     cvOpt.cwd = cvDir
     #that just saves a copy for us - App will create its own when it 
     #submits a batch job (unique and slightly modified)
     dumpObj(cvOpt,self.getCvOptFileName(idParam))
     cvApp = CrossValidatorApp(opt=cvOpt)
     return cvApp.run(**kw)
Exemplo n.º 2
0
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
#
#   See COPYING file distributed along with the MGTAXA package for the
#   copyright and license terms.
#
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##


from MGT.Common import *
from MGT.CrossValidatorApp import CrossValidatorApp
from MGT.ClassifierApp import ClassifierApp

def makeClOpt():
    o,a = ClassifierApp.defaultOptions()
    o.C = 0.03
    o.inFeat = [os.path.abspath("usps-train.libsvm"),os.path.abspath("usps-test.libsvm")]
    o.labels = [ lf+".idlab" for lf in o.inFeat ]
    return o

clOpt = makeClOpt()
print clOpt
o = Options()
o.clOpt = clOpt
o.mode = "scatter"
o.runMode = "batch"

app = CrossValidatorApp(**o.asDict())
app.run()