def load(modelSpecFilename): """ Need the following items in the model spec file: costFn decisionFn stages specs :param modelSpecFilename: :return: """ with open(modelSpecFilename) as f: modelDict = yaml.load(f) for stageDict in modelDict['specs']: router.addStage(stageDict) modelStages = [] for s in modelDict['stages']: modelStages.append(router.routeStage(s)) costFn=router.routeFn(modelDict['costFn']) decisionFn=router.routeFn(modelDict['decisionFn']) outputList = modelDict['outputs'].split(',') for i in range(len(outputList)): outputList[i] = outputList[i].strip() model = GraphModel( name=modelDict['name'] if modelDict.has_key('name') else None, stages=modelStages, outputStageNames=outputList, costFn=costFn, decisionFn=decisionFn, specFilename=modelSpecFilename) return model
def load(modelSpecFilename): with open(modelSpecFilename) as f: modelDict = yaml.load(f) for stageDict in modelDict['stages']: router.routeStage(stageDict) costFn=router.routeFn(modelDict['costFn']) decisionFn=router.routeFn(modelDict['decisionFn']) model = router.getStage(modelDict['model']) model.getCost = costFn model.predict = decisionFn model.specFilename = modelSpecFilename return model