repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
scikit-optimize | doc/sphinxext/github_link.py | .py | from operator import attrgetter
import inspect
import subprocess
import os
import sys
from functools import partial
REVISION_CMD = 'git rev-parse --short HEAD'
def _get_git_revision():
try:
revision = subprocess.check_output(REVISION_CMD.split()).strip()
except (subprocess.CalledProcessError, OSError... | 85 | 2,672 |
scikit-optimize | doc/sphinxext/custom_references_resolver.py | .py | """Adapted from
sphinx.transforms.post_transforms.ReferencesResolver.resolve_anyref
If 'py' is one of the domains and `py:class` is defined,
the Python domain will be processed before the 'std' domain.
License for Sphinx
==================
Copyright (c) 2007-2019 by the Sphinx team (see AUTHORS file).
All rights res... | 123 | 5,232 |
scikit-optimize | doc/sphinxext/sphinx_issues.py | .py | # -*- coding: utf-8 -*-
"""A Sphinx extension for linking to your project's issue tracker.
Copyright 2014 Steven Loria
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, includi... | 219 | 8,118 |
scikit-optimize | build_tools/circle/list_versions.py | .py | #!/usr/bin/env python3
# Copied from https://github.com/scikit-learn/scikit-learn/blob/master/
# build_tools/circle/list_versions.sh
# The scikit-learn developers.
# License: BSD-style
# List all available versions of the documentation
import json
import re
import sys
from distutils.version import LooseVersion
from ur... | 105 | 3,501 |
scikit-optimize | examples/sklearn-gridsearchcv-replacement.py | .py | """
==========================================
Scikit-learn hyperparameter search wrapper
==========================================
Iaroslav Shcherbatyi, Tim Head and Gilles Louppe. June 2017.
Reformatted by Holger Nahrstaedt 2020
.. currentmodule:: skopt
Introduction
============
This example assumes basic famili... | 213 | 7,105 |
scikit-optimize | examples/utils.py | .py | # Module to import functions from in examples for multiprocessing backend
import numpy as np
def obj_fun(x, noise_level=0.1):
return np.sin(5 * x[0]) * (1 - np.tanh(x[0] ** 2)) +\
np.random.randn() * noise_level
| 8 | 229 |
scikit-optimize | examples/exploration-vs-exploitation.py | .py | """
===========================
Exploration vs exploitation
===========================
Sigurd Carlen, September 2019.
Reformatted by Holger Nahrstaedt 2020
.. currentmodule:: skopt
We can control how much the acqusition function favors exploration and
exploitation by tweaking the two parameters kappa and xi. Highe... | 188 | 8,244 |
scikit-optimize | examples/hyperparameter-optimization.py | .py | """
============================================
Tuning a scikit-learn estimator with `skopt`
============================================
Gilles Louppe, July 2016
Katie Malone, August 2016
Reformatted by Holger Nahrstaedt 2020
.. currentmodule:: skopt
If you are looking for a :obj:`sklearn.model_selection.GridSearc... | 115 | 4,312 |
scikit-optimize | examples/ask-and-tell.py | .py | """
=======================
Async optimization Loop
=======================
Bayesian optimization is used to tune parameters for walking robots or other
experiments that are not a simple (expensive) function call.
Tim Head, February 2017.
Reformatted by Holger Nahrstaedt 2020
.. currentmodule:: skopt
They often foll... | 146 | 5,108 |
scikit-optimize | examples/parallel-optimization.py | .py | """
=====================
Parallel optimization
=====================
Iaroslav Shcherbatyi, May 2017.
Reviewed by Manoj Kumar and Tim Head.
Reformatted by Holger Nahrstaedt 2020
.. currentmodule:: skopt
Introduction
============
For many practical black box optimization problems expensive objective can be
evaluated... | 82 | 3,174 |
scikit-optimize | examples/store-and-load-results.py | .py | """
===========================================
Store and load `skopt` optimization results
===========================================
Mikhail Pak, October 2016.
Reformatted by Holger Nahrstaedt 2020
.. currentmodule:: skopt
Problem statement
=================
We often want to store optimization results in a file.... | 144 | 5,427 |
scikit-optimize | examples/optimizer-with-different-base-estimator.py | .py | """
==============================================
Use different base estimators for optimization
==============================================
Sigurd Carlen, September 2019.
Reformatted by Holger Nahrstaedt 2020
.. currentmodule:: skopt
To use different base_estimator or create a regressor with different paramete... | 140 | 4,857 |
scikit-optimize | examples/bayesian-optimization.py | .py | """
==================================
Bayesian optimization with `skopt`
==================================
Gilles Louppe, Manoj Kumar July 2016.
Reformatted by Holger Nahrstaedt 2020
.. currentmodule:: skopt
Problem statement
-----------------
We are interested in solving
.. math::
x^* = arg \min_x f(x)
und... | 214 | 7,424 |
scikit-optimize | examples/interruptible-optimization.py | .py | """
================================================
Interruptible optimization runs with checkpoints
================================================
Christian Schell, Mai 2018
Reformatted by Holger Nahrstaedt 2020
.. currentmodule:: skopt
Problem statement
=================
Optimization runs can take a very long ... | 124 | 4,670 |
scikit-optimize | examples/strategy-comparison.py | .py | """
==========================
Comparing surrogate models
==========================
Tim Head, July 2016.
Reformatted by Holger Nahrstaedt 2020
.. currentmodule:: skopt
Bayesian optimization or sequential model-based optimization uses a surrogate
model to model the expensive to evaluate function `func`. There are se... | 148 | 4,686 |
scikit-optimize | examples/plots/partial-dependence-plot-with-categorical.py | .py | """
=================================================
Partial Dependence Plots with categorical values
=================================================
Sigurd Carlsen Feb 2019
Holger Nahrstaedt 2020
.. currentmodule:: skopt
Plot objective now supports optional use of partial dependence as well as
different methods... | 98 | 3,741 |
scikit-optimize | examples/plots/partial-dependence-plot-2D.py | .py | """
===========================
Partial Dependence Plots 2D
===========================
Hvass-Labs Dec 2017
Holger Nahrstaedt 2020
.. currentmodule:: skopt
Simple example to show the new 2D plots.
"""
print(__doc__)
import numpy as np
from math import exp
from skopt import gp_minimize
from skopt.space import Real, ... | 106 | 3,291 |
scikit-optimize | examples/plots/visualizing-results.py | .py | """
================================
Visualizing optimization results
================================
Tim Head, August 2016.
Reformatted by Holger Nahrstaedt 2020
.. currentmodule:: skopt
Bayesian optimization or sequential model-based optimization uses a surrogate
model to model the expensive to evaluate objective... | 225 | 8,574 |
scikit-optimize | examples/plots/partial-dependence-plot.py | .py | """
========================
Partial Dependence Plots
========================
Sigurd Carlsen Feb 2019
Holger Nahrstaedt 2020
.. currentmodule:: skopt
Plot objective now supports optional use of partial dependence as well as
different methods of defining parameter values for dependency plots.
"""
print(__doc__)
impo... | 116 | 4,460 |
scikit-optimize | examples/sampler/initial-sampling-method-integer.py | .py | """
===================================================
Comparing initial sampling methods on integer space
===================================================
Holger Nahrstaedt 2020 Sigurd Carlsen October 2019
.. currentmodule:: skopt
When doing baysian optimization we often want to reserve some of the
early part o... | 179 | 6,096 |
scikit-optimize | examples/sampler/initial-sampling-method.py | .py | """
==================================
Comparing initial sampling methods
==================================
Holger Nahrstaedt 2020 Sigurd Carlsen October 2019
.. currentmodule:: skopt
When doing baysian optimization we often want to reserve some of the
early part of the optimization to pure exploration. By default... | 170 | 5,407 |
scikit-optimize | examples/sampler/sampling_comparison.py | .py | """
==========================================
Comparing initial point generation methods
==========================================
Holger Nahrstaedt 2020
.. currentmodule:: skopt
Bayesian optimization or sequential model-based optimization uses a surrogate
model to model the expensive to evaluate function `func`. ... | 192 | 6,903 |
deap | setup.py | .py | #!/usr/bin/env python
# read the contents of README file
from os import path
import codecs
import deap
try:
from setuptools import setup, find_packages
modules = find_packages(exclude=['examples'])
except ImportError:
from distutils.core import setup
modules = ['deap', 'deap.benchmarks', 'deap.tests'... | 44 | 1,597 |
deap | deap/creator.py | .py | # This file is part of DEAP.
#
# DEAP is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# DEAP is distributed ... | 194 | 7,187 |
deap | deap/cma.py | .py | # This file is part of DEAP.
#
# DEAP is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# DEAP is distributed ... | 869 | 41,801 |
deap | deap/gp.py | .py | # This file is part of DEAP.
#
# DEAP is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# DEAP is distributed ... | 1,354 | 52,433 |
deap | deap/algorithms.py | .py | # This file is part of DEAP.
#
# DEAP is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# DEAP is distributed ... | 504 | 23,000 |
deap | deap/base.py | .py | # This file is part of DEAP.
#
# DEAP is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# DEAP is distributed ... | 359 | 14,167 |
deap | deap/tools/mutation.py | .py | import math
import random
from itertools import repeat
try:
from collections.abc import Sequence
except ImportError:
from collections import Sequence
######################################
# GA Mutations #
######################################
def mutGaussian(individual, mu, sigma, i... | 248 | 9,837 |
deap | deap/tools/constraint.py | .py |
from functools import wraps
from itertools import repeat
try:
from collections.abc import Sequence
except ImportError:
from collections import Sequence
class DeltaPenalty(object):
r"""This decorator returns penalized fitness for invalid individuals and the
original fitness value for valid individual... | 180 | 7,941 |
deap | deap/tools/selection.py | .py | import random
import numpy as np
from functools import partial
from operator import attrgetter
######################################
# Selections #
######################################
def selRandom(individuals, k):
"""Select *k* individuals at random from the input *individuals* with... | 327 | 13,325 |
deap | deap/tools/indicator.py | .py | import numpy
import moocore
def hypervolume(front, **kargs):
"""Returns the index of the individual with the least the hypervolume
contribution. The provided *front* should be a set of non-dominated
individuals having each a :attr:`fitness` attribute.
The hypervolume is computed using the `moocore` p... | 33 | 1,158 |
deap | deap/tools/emo.py | .py | import bisect
from collections import defaultdict, namedtuple
from itertools import chain
import math
from operator import attrgetter, itemgetter
import random
import numpy
######################################
# Non-Dominated Sorting (NSGA-II) #
######################################
def selNSGA2(individuals, ... | 863 | 33,160 |
deap | deap/tools/support.py | .py | from bisect import bisect_right
from collections import defaultdict
from copy import deepcopy
from functools import partial
from itertools import chain
from operator import eq
def identity(obj):
"""Returns directly the argument *obj*.
"""
return obj
class History(object):
"""The :class:`History` cla... | 653 | 26,498 |
deap | deap/tools/init.py | .py | def initRepeat(container, func, n):
"""Call the function *func* *n* times and return the results in a
container type `container`
:param container: The type to put in the data from func.
:param func: The function that will be called n times to fill the
container.
:param n: The numbe... | 90 | 3,283 |
deap | deap/tools/crossover.py | .py | import random
import warnings
try:
from collections.abc import Sequence
except ImportError:
from collections import Sequence
from itertools import repeat
######################################
# GA Crossovers #
######################################
def cxOnePoint(ind1, ind2):
"""... | 463 | 17,311 |
deap | deap/tools/migration.py | .py | def migRing(populations, k, selection, replacement=None, migarray=None):
"""Perform a ring migration between the *populations*. The migration first
select *k* emigrants from each population using the specified *selection*
operator and then replace *k* individuals from the associated population
in the *m... | 52 | 2,726 |
deap | deap/benchmarks/movingpeaks.py | .py | # This file is part of DEAP.
#
# DEAP is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# DEAP is distributed ... | 402 | 18,331 |
deap | deap/benchmarks/binary.py | .py | # This file is part of DEAP.
#
# DEAP is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# DEAP is distributed ... | 143 | 4,928 |
deap | deap/benchmarks/__init__.py | .py | # This file is part of DEAP.
#
# DEAP is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# DEAP is distributed ... | 737 | 25,820 |
deap | deap/benchmarks/gp.py | .py | # This file is part of DEAP.
#
# DEAP is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# DEAP is distributed ... | 137 | 3,825 |
deap | deap/benchmarks/tools.py | .py | """Module containing tools that are useful when benchmarking algorithms
"""
from math import hypot, sqrt
from functools import wraps
from itertools import repeat
try:
import numpy
numpy_imported = True
except ImportError:
numpy_imported = False
try:
import scipy.spatial
scipy_imported = True
except... | 326 | 12,127 |
deap | tests/test_convergence.py | .py | # This file is part of DEAP.
#
# DEAP is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# DEAP is distributed ... | 443 | 16,010 |
deap | tests/test_operators.py | .py | import unittest
from unittest import mock
import random
from deap.tools import crossover
class TestCxOrdered(unittest.TestCase):
def setUp(self):
pass
def test_crossover(self):
a = [8, 7, 3, 4, 5, 6, 0, 2, 1, 9]
b = [7, 6, 0, 1, 2, 9, 8, 4, 3, 5]
expected_ap = [4, 5, 6, 1, 2,... | 37 | 1,069 |
deap | tests/test_multiproc.py | .py | import multiprocessing
from deap import base
from deap import creator
def _evalOneMax(individual):
return sum(individual),
def test_multiproc():
creator.create("FitnessMax", base.Fitness, weights=(1.0,))
creator.create("Individual", list, fitness=creator.FitnessMax)
toolbox = base.Toolbox()
to... | 26 | 644 |
deap | tests/test_creator.py | .py | # This file is part of DEAP.
#
# DEAP is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# DEAP is distributed ... | 78 | 2,611 |
deap | tests/test_mutation.py | .py | import unittest
from unittest import mock
from deap.tools.mutation import mutInversion
class MutationTest(unittest.TestCase):
def test_mutInverstion_size_zero_chromosome_returns_unchanged_chromosome_in_tuple(self):
chromosome = []
expected = []
self.assertEqual((expected,), mutInversion(... | 46 | 1,937 |
deap | tests/test_statistics.py | .py | from operator import itemgetter
import unittest
import numpy
from deap import tools
class LogbookTest(unittest.TestCase):
def test_statistics_compile(self):
s = tools.Statistics()
s.register("mean", numpy.mean)
s.register("max", max)
res = s.compile([1, 2, 3, 4])
self.ass... | 28 | 957 |
deap | tests/test_logbook.py | .py | import unittest
from deap import tools
class LogbookTest(unittest.TestCase):
def setUp(self):
self.logbook = tools.Logbook()
print()
def test_multi_chapters(self):
self.logbook.record(gen=0, evals=100, fitness={'obj 1': {'avg': 1.0, 'max': 10},
... | 42 | 1,732 |
deap | tests/test_algorithms.py | .py | # This file is part of DEAP.
#
# DEAP is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# DEAP is distributed ... | 244 | 8,745 |
deap | tests/test_benchmarks.py | .py | """Test functions from deap/benchmarks."""
import sys
import unittest
from deap import base
from deap import creator
from deap.benchmarks import binary
class BenchmarkTest(unittest.TestCase):
"""Test object for unittest of deap/benchmarks."""
def setUp(self):
@binary.bin2float(0, 1023, 10)
... | 62 | 2,356 |
deap | tests/test_pickle.py | .py |
import sys
import unittest
import array
import pickle
import operator
import functools
import numpy
from deap import creator
from deap import base
from deap import gp
from deap import tools
def func():
return "True"
class Pickling(unittest.TestCase):
def setUp(self):
creator.create("FitnessMax",... | 171 | 7,281 |
deap | tests/test_init.py | .py | from functools import partial
import random
import unittest
from deap import tools
class LogbookTest(unittest.TestCase):
def test_statistics_compile(self):
length = 10
gen_idx = partial(random.sample, list(range(length)), length)
i = tools.initIterate(list, gen_idx)
self.assertSet... | 14 | 354 |
deap | doc/code/tutorials/part_4/4_5_home_made_eval_func.py | .py | # This file is part of DEAP.
#
# DEAP is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# DEAP is distributed ... | 159 | 5,529 |
deap | doc/code/tutorials/part_4/installSN.py | .py | from distutils.core import setup, Extension
module1 = Extension('SNC',
sources = ['SNC.cpp'])
setup (name = 'SNC',
version = '1.0',
description = 'Sorting network evaluator',
ext_modules = [module1])
| 10 | 244 |
deap | doc/code/tutorials/part_4/4_4_Using_Cpp_NSGA.py | .py | # This file is part of DEAP.
#
# DEAP is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# DEAP is distributed ... | 145 | 4,932 |
deap | doc/code/tutorials/part_4/sortingnetwork.py | .py | # This file is part of DEAP.
#
# DEAP is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# DEAP is distributed ... | 129 | 4,640 |
deap | doc/code/tutorials/part_3/3_7_variations.py | .py | ## 3.7 Variations
import random
from deap import base
from deap import creator
from deap import tools
## Data structure and initializer creation
creator.create("FitnessMax", base.Fitness, weights=(1.0,))
creator.create("Individual", list, fitness=creator.FitnessMax)
toolbox = base.Toolbox()
toolbox.register("attr_f... | 49 | 1,598 |
deap | doc/code/tutorials/part_3/stats.py | .py | import random
import numpy
from deap import algorithms
from deap import base
from deap import creator
from deap import tools
random.seed(0)
stats = tools.Statistics(key=lambda ind: ind.fitness.values)
stats.register("avg", numpy.mean)
stats.register("std", numpy.std)
stats.register("min", numpy.min)
stats.register(... | 51 | 1,426 |
deap | doc/code/tutorials/part_3/3_6_2_tool_decoration.py | .py | from deap import base
from deap import creator
from deap import tools
toolbox = base.Toolbox()
MIN, MAX = -5, 5
def checkBounds(min, max):
def decorator(func):
def wrapper(*args, **kargs):
offspring = func(*args, **kargs)
for child in offspring:
for i in range(len(c... | 27 | 771 |
deap | doc/code/tutorials/part_3/logbook.py | .py | import pickle
from deap import tools
from stats import record
logbook = tools.Logbook()
logbook.record(gen=0, evals=30, **record)
print(logbook)
gen, avg = logbook.select("gen", "avg")
with open("logbook.pkl", "w") as lb_file:
pickle.dump(logbook, lb_file)
# Cleaning the pickle file ...
import os
os.remove("log... | 62 | 1,407 |
deap | doc/code/tutorials/part_3/3_6_using_the_toolbox.py | .py | ## 3.6 Using the Toolbox
from deap import base
from deap import tools
toolbox = base.Toolbox()
def evaluateInd(individual):
# Do some computation
result = sum(individual)
return result,
toolbox.register("mate", tools.cxTwoPoint)
toolbox.register("mutate", tools.mutGaussian, mu=0, sigma=1, indpb=0.2)
tool... | 56 | 1,907 |
deap | doc/code/tutorials/part_3/3_next_step.py | .py | ## 3.1 A First Individual
import random
from deap import base
from deap import creator
from deap import tools
IND_SIZE = 5
creator.create("FitnessMin", base.Fitness, weights=(-1.0, -1.0))
creator.create("Individual", list, fitness=creator.FitnessMin)
toolbox = base.Toolbox()
toolbox.register("attr_float", random.ra... | 58 | 1,523 |
deap | doc/code/tutorials/part_3/multistats.py | .py | import operator
import random
import numpy
from deap import algorithms
from deap import base
from deap import creator
from deap import gp
from deap import tools
random.seed(0)
stats_fit = tools.Statistics(key=lambda ind: ind.fitness.values)
stats_size = tools.Statistics(key=len)
mstats = tools.MultiStatistics(fitne... | 56 | 1,792 |
deap | doc/code/tutorials/part_3/3_8_algorithms.py | .py | ## 3.7 Variations
import random
from deap import base
from deap import creator
from deap import tools
## Data structure and initializer creation
creator.create("FitnessMax", base.Fitness, weights=(1.0,))
creator.create("Individual", list, fitness=creator.FitnessMax)
toolbox = base.Toolbox()
toolbox.register("attr_f... | 36 | 1,050 |
deap | doc/code/tutorials/part_1/1_where_to_start.py | .py | ## 1.1 Types
from deap import base, creator
creator.create("FitnessMin", base.Fitness, weights=(-1.0,))
creator.create("Individual", list, fitness=creator.FitnessMin)
## 1.2 Initialization
import random
from deap import tools
IND_SIZE = 10
toolbox = base.Toolbox()
toolbox.register("attribute", random.random)
toolbox... | 68 | 2,147 |
deap | doc/code/tutorials/part_2/2_3_2_grid.py | .py | ## 2.3.2 Grid
import random
from deap import base
from deap import creator
from deap import tools
creator.create("FitnessMin", base.Fitness, weights=(-1.0,))
creator.create("Individual", list, fitness=creator.FitnessMin)
IND_SIZE = 20
toolbox = base.Toolbox()
toolbox.register("attr_float", random.random)
toolbox.re... | 25 | 658 |
deap | doc/code/tutorials/part_2/2_2_1_list_of_floats.py | .py | ## 2.2.1 List of floats
import random
import array
import numpy
from deap import base
from deap import creator
from deap import tools
creator.create("FitnessMax", base.Fitness, weights=(1.0,))
creator.create("Individual", list, fitness=creator.FitnessMax)
IND_SIZE=10
toolbox = base.Toolbox()
toolbox.register("attr_... | 21 | 617 |
deap | doc/code/tutorials/part_2/2_3_1_bag.py | .py | ## 2.3.1 Bag
import random
from deap import base
from deap import creator
from deap import tools
creator.create("FitnessMin", base.Fitness, weights=(-1.0,))
creator.create("Individual", list, fitness=creator.FitnessMin)
IND_SIZE = 20
toolbox = base.Toolbox()
toolbox.register("attr_int", random.randint, -20, 20)
too... | 20 | 535 |
deap | doc/code/tutorials/part_2/2_2_6_funky_one.py | .py | ## 2.2.6 Funky one
import random
from deap import base
from deap import creator
from deap import tools
creator.create("FitnessMax", base.Fitness, weights=(1.0, 1.0))
creator.create("Individual", list, fitness=creator.FitnessMax)
toolbox = base.Toolbox()
INT_MIN, INT_MAX = 5, 10
FLT_MIN, FLT_MAX = -0.2, 0.8
N_CYCLES... | 21 | 587 |
deap | doc/code/tutorials/part_2/2_3_5_seeding_a_population.py | .py | # 2.3.5 Seeding a population
import json
from deap import base
from deap import creator
creator.create("FitnessMax", base.Fitness, weights=(1.0, 1.0))
creator.create("Individual", list, fitness=creator.FitnessMax)
def initIndividual(icls, content):
return icls(content)
def initPopulation(pcls, ind_init, filenam... | 24 | 695 |
deap | doc/code/tutorials/part_2/2_3_3_swarm.py | .py | ## 2.2.6 Particle
import random
from deap import base
from deap import creator
from deap import tools
creator.create("FitnessMax", base.Fitness, weights=(1.0, 1.0))
creator.create("Particle", list, fitness=creator.FitnessMax, speed=None,
smin=None, smax=None, best=None)
creator.create("Swarm", list, gb... | 24 | 827 |
deap | doc/code/tutorials/part_2/2_2_5_particle.py | .py | ## 2.2.6 Particle
import random
from deap import base
from deap import creator
from deap import tools
creator.create("FitnessMax", base.Fitness, weights=(1.0, 1.0))
creator.create("Particle", list, fitness=creator.FitnessMax, speed=None,
smin=None, smax=None, best=None)
def initParticle(pcls, size, pm... | 22 | 679 |
deap | doc/code/tutorials/part_2/2_2_4_evolution_strategy.py | .py | ## 2.2.4 Evolution Strategy
import array
import random
from deap import base
from deap import creator
from deap import tools
creator.create("FitnessMin", base.Fitness, weights=(-1.0,))
creator.create("Individual", array.array, typecode="d",
fitness=creator.FitnessMin, strategy=None)
creator.create("Str... | 27 | 832 |
deap | doc/code/tutorials/part_2/2_2_2_permutation.py | .py | ## 2.2.2 Permutation
import random
from deap import base
from deap import creator
from deap import tools
creator.create("FitnessMin", base.Fitness, weights=(-1.0,))
creator.create("Individual", list, fitness=creator.FitnessMin)
IND_SIZE=10
toolbox = base.Toolbox()
toolbox.register("indices", random.sample, range(IN... | 17 | 443 |
deap | doc/code/tutorials/part_2/2_2_3_arithmetic_expression.py | .py | ## 2.2.3 Arithmetic expression
import operator
from deap import base
from deap import creator
from deap import gp
from deap import tools
pset = gp.PrimitiveSet("MAIN", arity=1)
pset.addPrimitive(operator.add, 2)
pset.addPrimitive(operator.sub, 2)
pset.addPrimitive(operator.mul, 2)
creator.create("FitnessMin", base.F... | 22 | 644 |
deap | doc/code/tutorials/part_2/2_3_4_demes.py | .py | ## 2.3.4 Demes
import random
from deap import base
from deap import creator
from deap import tools
creator.create("FitnessMin", base.Fitness, weights=(-1.0,))
creator.create("Individual", list, fitness=creator.FitnessMin)
IND_SIZE=10
toolbox = base.Toolbox()
toolbox.register("indices", random.sample, range(IND_SIZE... | 21 | 585 |
deap | doc/code/benchmarks/kursawe.py | .py | from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
import matplotlib.pyplot as plt
try:
import numpy as np
except:
exit()
from deap import benchmarks
X = np.arange(-5, 5, 0.1)
Y = np.arange(-5, 5, 0.1)
X, Y = np.meshgrid(X, Y)
Z1 = np.zeros(X.shape)
Z2 = np.zeros(X.shape)
for i in range(X.sha... | 35 | 855 |
deap | doc/code/benchmarks/h1.py | .py | from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
from matplotlib.colors import LogNorm
import matplotlib.pyplot as plt
try:
import numpy as np
except:
exit()
from deap import benchmarks
def h1_arg0(sol):
return benchmarks.h1(sol)[0]
fig = plt.figure()
# ax = Axes3D(fig, azim = -29, elev... | 29 | 671 |
deap | doc/code/benchmarks/himmelblau.py | .py | from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
from matplotlib.colors import LogNorm
import matplotlib.pyplot as plt
try:
import numpy as np
except:
exit()
from deap import benchmarks
def himmelblau_arg0(sol):
return benchmarks.himmelblau(sol)[0]
fig = plt.figure()
ax = Axes3D(fig, az... | 28 | 671 |
deap | doc/code/benchmarks/shekel.py | .py | from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
from matplotlib.colors import LogNorm
import matplotlib.pyplot as plt
try:
import numpy as np
except:
exit()
from deap import benchmarks
#NUMMAX = 5
#A = 10 * np.random.rand(NUMMAX, 2)
#C = np.random.rand(NUMMAX)
A = [[0.5, 0.5], [0.25, 0.25]... | 36 | 876 |
deap | doc/code/benchmarks/rastrigin.py | .py | from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
import matplotlib.pyplot as plt
try:
import numpy as np
except:
exit()
from deap import benchmarks
def rastrigin_arg0(sol):
return benchmarks.rastrigin(sol)[0]
fig = plt.figure()
ax = Axes3D(fig, azim = -29, elev = 50)
X = np.arange(-5, 5... | 27 | 614 |
deap | doc/code/benchmarks/griewank.py | .py | from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
import matplotlib.pyplot as plt
try:
import numpy as np
except:
exit()
from deap import benchmarks
def griewank_arg0(sol):
return benchmarks.griewank(sol)[0]
fig = plt.figure()
ax = Axes3D(fig, azim = -29, elev = 40)
# ax = Axes3D(fig)
X ... | 28 | 634 |
deap | doc/code/benchmarks/rosenbrock.py | .py | from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
from matplotlib.colors import LogNorm
import matplotlib.pyplot as plt
try:
import numpy as np
except:
exit()
from deap import benchmarks
def rosenbrock_arg0(sol):
return benchmarks.rosenbrock(sol)[0]
fig = plt.figure()
# ax = Axes3D(fig, ... | 29 | 691 |
deap | doc/code/benchmarks/bohachevsky.py | .py | from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
from matplotlib.colors import LogNorm
import matplotlib.pyplot as plt
try:
import numpy as np
except:
exit()
from deap import benchmarks
def bohachevsky_arg0(sol):
return benchmarks.bohachevsky(sol)[0]
fig = plt.figure()
ax = Axes3D(fig, ... | 30 | 699 |
deap | doc/code/benchmarks/schaffer.py | .py | from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
import matplotlib.pyplot as plt
try:
import numpy as np
except:
exit()
from deap import benchmarks
def schaffer_arg0(sol):
return benchmarks.schaffer(sol)[0]
fig = plt.figure()
ax = Axes3D(fig, azim = -29, elev = 60)
# ax = Axes3D(fig)
X ... | 28 | 636 |
deap | doc/code/benchmarks/schwefel.py | .py | from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
import matplotlib.pyplot as plt
try:
import numpy as np
except:
exit()
from deap import benchmarks
def schwefel_arg0(sol):
return benchmarks.schwefel(sol)[0]
fig = plt.figure()
# ax = Axes3D(fig, azim = -29, elev = 50)
ax = Axes3D(fig)
X ... | 28 | 636 |
deap | doc/code/benchmarks/ackley.py | .py | from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
from matplotlib.colors import LogNorm
import matplotlib.pyplot as plt
try:
import numpy as np
except:
exit()
from deap import benchmarks
def ackley_arg0(sol):
return benchmarks.ackley(sol)[0]
fig = plt.figure()
# ax = Axes3D(fig, azim = -... | 29 | 683 |
deap | doc/code/benchmarks/movingsc1.py | .py | from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
import matplotlib.pyplot as plt
try:
import numpy as np
except:
exit()
import random
rnd = random.Random()
rnd.seed(128)
from deap.benchmarks import movingpeaks
sc = movingpeaks.SCENARIO_1
sc["uniform_height"] = 0
sc["uniform_width"] = 0
mp ... | 34 | 727 |
deap | doc/code/examples/nsga3_ref_points_combined.py | .py | import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy
from deap import tools
NOBJ = 3
P = [2, 1]
SCALES = [1, 0.5]
fig = plt.figure(figsize=(7, 7))
ax = fig.add_subplot(111, projection="3d")
# the coordinate origin
ax.scatter(0, 0, 0, c="k", marker="+", s=100)
# reference points
# Pa... | 43 | 1,080 |
deap | doc/code/examples/nsga3_ref_points_combined_plot.py | .py | import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy
from deap import tools
NOBJ = 3
P = [2, 1]
SCALES = [1, 0.5]
fig = plt.figure(figsize=(7, 7))
ax = fig.add_subplot(111, projection="3d")
# the coordinate origin
ax.scatter(0, 0, 0, c="k", marker="+", s=100)
# reference points
# Pa... | 43 | 1,086 |
deap | doc/code/examples/nsga3_ref_points.py | .py | import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy
from deap import tools
NOBJ = 3
P = [12]
SCALES = [1]
fig = plt.figure(figsize=(7, 7))
ax = fig.add_subplot(111, projection="3d")
# the coordinate origin
ax.scatter(0, 0, 0, c="k", marker="+", s=100)
# reference points
ref_points ... | 34 | 875 |
deap | examples/bbob.py | .py |
# This file is part of DEAP.
#
# DEAP is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# DEAP is distributed... | 140 | 5,020 |
deap | examples/ga/onemax_island_scoop.py | .py | # This file is part of DEAP.
#
# DEAP is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# DEAP is distributed ... | 73 | 2,336 |
deap | examples/ga/nsga2.py | .py | # This file is part of DEAP.
#
# DEAP is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# DEAP is distributed ... | 145 | 5,160 |
deap | examples/ga/xkcd.py | .py | # This file is part of DEAP.
#
# DEAP is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# DEAP is distributed ... | 115 | 4,336 |
deap | examples/ga/onemax_short.py | .py | # This file is part of DEAP.
#
# DEAP is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# DEAP is distributed ... | 64 | 2,067 |
deap | examples/ga/kursawefct.py | .py | # This file is part of DEAP.
#
# DEAP is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# DEAP is distributed ... | 90 | 2,940 |
deap | examples/ga/nqueens.py | .py | # This file is part of DEAP.
#
# DEAP is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# DEAP is distributed ... | 97 | 3,343 |
deap | examples/ga/evoknn_jmlr.py | .py | #!/usr/bin/env python2.7
# This file is part of DEAP.
#
# DEAP is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
... | 47 | 1,929 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.