Пример #1
0
class ProperSurrogateModel(SurrogateModel):

    def __init__(self, fitness, configuration, controller):
        super(ProperSurrogateModel, self).__init__(fitness, configuration,
                                                   controller)

        if configuration.classifier == 'SupportVectorMachine':
            self.classifier = SupportVectorMachineClassifier()
        else:
            logging.error('Classifier type {} not found'.format(
                configuration.classifier))

        if configuration.regressor == 'GaussianProcess':
            self.regressor = GaussianProcessRegressor(controller)
        else:
            logging.error('Regressor type {} not found'.format(
                configuration.regressor))

    def train(self, pop):
        dimensions = self.fitness.dimensions
        return self.classifier.train(pop) and self.regressor.train(
            pop, self.configuration, dimensions)

    def add_training_instance(self, part, code, fitness):
        self.classifier.add_training_instance(part, code)
        self.regressor.add_training_instance(part, fitness)
Пример #2
0
    def __init__(self, fitness, configuration, controller):
        super(ProperSurrogateModel, self).__init__(fitness, configuration,
                                                   controller)

        if configuration.classifier == 'SupportVectorMachine':
            self.classifier = SupportVectorMachineClassifier()
        else:
            logging.error('Classifier type {} not found'.format(
                configuration.classifier))

        if configuration.regressor == 'GaussianProcess':
            self.regressor = GaussianProcessRegressor(controller)
        else:
            logging.error('Regressor type {} not found'.format(
                configuration.regressor))