How to use the mlopt.optimization function in mlopt

To help you get started, we’ve selected a few mlopt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pklauke / mlopt / mlopt / blending.py View on Github external
def __init__(self, metric, maximize, optimizer='greedy'):
        self.metric = metric
        self.X = None
        self.y = None

        def _func(*weights):
            return self.metric(self.y, np.average(self.X, axis=0, weights=weights))

        if isinstance(optimizer, str):
            if optimizer.lower() == 'pso':
                self.optimizer = mlopt.optimization.ParticleSwarmOptimizer(func=_func, maximize=maximize)
            elif optimizer.lower() == 'greedy':
                self.optimizer = mlopt.optimization.GreedyOptimizer(func=_func, maximize=maximize)
        else:
            if hasattr(optimizer, 'optimize'):
                self.optimizer = optimizer
            else:
                raise AttributeError('Provided optimizer does not have a optimize method.')
github pklauke / mlopt / mlopt / blending.py View on Github external
def __init__(self, metric, maximize, optimizer='greedy'):
        self.metric = metric
        self.X = None
        self.y = None

        def _func(*weights):
            return self.metric(self.y, np.average(self.X, axis=0, weights=weights))

        if isinstance(optimizer, str):
            if optimizer.lower() == 'pso':
                self.optimizer = mlopt.optimization.ParticleSwarmOptimizer(func=_func, maximize=maximize)
            elif optimizer.lower() == 'greedy':
                self.optimizer = mlopt.optimization.GreedyOptimizer(func=_func, maximize=maximize)
        else:
            if hasattr(optimizer, 'optimize'):
                self.optimizer = optimizer
            else:
                raise AttributeError('Provided optimizer does not have a optimize method.')