Example #1
0
 def handleLearningEvent(self, subject, status):
     file = open(self.filename, "a")
     tmpout = sys.stdout
     sys.stdout = file
     InfoToScreen.handleLearningEvent(self, subject, status)
     sys.stdout = tmpout
     file.close()
Example #2
0
 def handleLearningEvent(self, subject, status):
     file = open(self.filename, "a")
     tmpout = sys.stdout
     sys.stdout = file
     InfoToScreen.handleLearningEvent(self, subject, status)
     sys.stdout = tmpout
     file.close()
Example #3
0
    def loadAll(self, iteration):
        self.grid = self.loadGrid(iteration)
        self.knowledge = self.loadLearnedKnowledge(iteration)
        self.learner = self.__loadLearner(iteration)
        self.learner.setGrid(self.grid)
        self.learner.setLearnedKnowledge(self.knowledge)
        self.learner.attachEventController(self)
        # setting C operator here, since the knowledge about grid is needed
        # recreation of B operator is not necessary since it will be set in learnData()
        cOperatorType = self.__getCOperatorType(iteration)
        if cOperatorType == 'laplace':
            self.learner.specification.setCOperator(
                createOperationLaplace(self.learner.grid))
            self.learner.specification.setCOperatorType('laplace')

        elif cOperatorType == 'identity':
            self.learner.specification.setCOperator(
                createOperationIdentity(self.learner.grid))
            self.learner.specification.setCOperatorType('identity')

        else:
            raise Exception('C Operator type is unknown')

        for controller in self.__getLearnerEventControllers(iteration):
            if controller['module'] == 'bin.controller.InfoToScreenRegressor':
                self.learner.attachEventController(InfoToScreenRegressor())
            elif controller['module'] == 'bin.controller.InfoToScreen':
                self.learner.attachEventController(InfoToScreen())
            elif controller['module'] == 'bin.controller.InfoToFile':
                self.learner.attachEventController(
                    InfoToFile(controller['filename']))
            elif controller['module'] == 'bin.controller.InfoToGraph':
                self.learner.attachEventController(
                    InfoToGraph(controller['filename']))

        for controller in self.__getSolverEventControllers(iteration):
            if controller['module'] == 'bin.controller.InfoToScreenRegressor':
                self.learner.solver.attachEventController(
                    InfoToScreenRegressor())
            elif controller['module'] == 'bin.controller.InfoToScreen':
                self.learner.solver.attachEventController(InfoToScreen())
            elif controller['module'] == 'bin.controller.InfoToFile':
                self.learner.solver.attachEventController(
                    InfoToFile(controller['filename']))
            elif controller['module'] == 'bin.controller.InfoToGraph':
                self.learner.solver.attachEventController(
                    InfoToGraph(controller['filename']))

        return self.learner
Example #4
0
 def toString(self):
     serializationString = InfoToScreen.toString(self).rstrip().lstrip(
         "{").rstrip("}")
     serializationString += ", 'filename' : '" + self.filename + "'"
     serializationString = "{" + serializationString + "}\n"
     return serializationString
Example #5
0
 def toString(self):
     serializationString = InfoToScreen.toString(self).rstrip().lstrip("{").rstrip("}")
     serializationString += ", 'filename' : '" + self.filename + "'"
     serializationString = "{" + serializationString + "}\n"
     return serializationString