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 |
|---|---|---|---|---|---|
pyomo | examples/dae/laplace_BVP.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 109 | 2,496 |
pyomo | examples/dae/simulator_ode_multindex_example.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 120 | 3,493 |
pyomo | examples/dae/run_stochpdegas_automatic.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 143 | 3,670 |
pyomo | examples/dae/run_disease.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 30 | 1,074 |
pyomo | examples/dae/distill_DAE.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 130 | 3,885 |
pyomo | examples/dae/PDE_example.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 103 | 2,897 |
pyomo | examples/dae/run_distill.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 60 | 2,005 |
pyomo | examples/dae/car_example.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 119 | 2,760 |
pyomo | examples/dae/run_Optimal_Control.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 48 | 1,444 |
pyomo | examples/dae/dynamic_scheduling.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 145 | 4,017 |
pyomo | examples/dae/Path_Constraint.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 83 | 2,036 |
pyomo | examples/dae/disease_DAE.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 334 | 9,341 |
pyomo | examples/dae/Optimal_Control.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 59 | 1,495 |
pyomo | examples/dae/Heat_Conduction.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 68 | 1,969 |
pyomo | examples/dae/simulator_dae_example.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 109 | 3,200 |
pyomo | examples/dae/simulator_ode_example.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 97 | 2,900 |
pyomo | examples/doc/samples/update.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 96 | 3,606 |
pyomo | examples/doc/samples/comparisons/cutstock/cutstock_grb.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 76 | 2,234 |
pyomo | examples/doc/samples/comparisons/cutstock/cutstock_pulpor.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 65 | 2,028 |
pyomo | examples/doc/samples/comparisons/cutstock/cutstock_lpsolve.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 91 | 2,746 |
pyomo | examples/doc/samples/comparisons/cutstock/cutstock_pyomo.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 80 | 2,581 |
pyomo | examples/doc/samples/comparisons/cutstock/cutstock_util.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 88 | 2,231 |
pyomo | examples/doc/samples/comparisons/cutstock/cutstock_cplex.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 100 | 2,929 |
pyomo | examples/doc/samples/comparisons/sched/pyomo/sched.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 91 | 2,547 |
pyomo | examples/doc/samples/scripts/test_scripts.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 70 | 2,231 |
pyomo | examples/doc/samples/scripts/s2/script.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 54 | 1,780 |
pyomo | examples/doc/samples/scripts/s2/knapsack.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 46 | 1,410 |
pyomo | examples/doc/samples/scripts/s1/knapsack.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 37 | 1,156 |
pyomo | examples/doc/samples/case_studies/diet/DietProblem.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 47 | 1,565 |
pyomo | examples/doc/samples/case_studies/disease_est/DiseaseEstimation.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 58 | 1,711 |
pyomo | examples/doc/samples/case_studies/network_flow/networkFlow1.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 50 | 1,721 |
pyomo | examples/doc/samples/case_studies/transportation/transportation.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 48 | 1,519 |
pyomo | examples/doc/samples/case_studies/deer/DeerProblem.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 102 | 2,587 |
pyomo | examples/doc/samples/case_studies/max_flow/MaxFlow.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 58 | 2,059 |
pyomo | examples/mpec/scholtes4.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 35 | 1,256 |
pyomo | examples/mpec/linear1.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 25 | 840 |
pyomo | examples/mpec/munson1d.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 34 | 1,106 |
pyomo | examples/mpec/bard1.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 46 | 1,545 |
pyomo | examples/mpec/munson1c.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 34 | 1,094 |
pyomo | examples/mpec/munson1b.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 34 | 1,094 |
pyomo | examples/mpec/munson1a.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 34 | 1,102 |
pyomo | examples/mpec/munson1.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 32 | 1,068 |
pyomo | examples/mpec/indexed.py | .py | # ____________________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and Engineering
# Solutions of... | 27 | 896 |
scikit-optimize | setup.py | .py | try:
from setuptools import setup
except ImportError:
from distutils.core import setup
try:
import builtins
except ImportError:
# Python 2 compat: just to be able to declare that Python >=3.5 is needed.
import __builtin__ as builtins
# This is a bit (!) hackish: we are setting a global variable so ... | 53 | 1,870 |
scikit-optimize | conftest.py | .py | # Even if empty this file is useful so that when running from the root folder
# ./sklearn is added to sys.path by pytest. See
# https://docs.pytest.org/en/latest/pythonpath.html for more details. For
# example, this allows to build extensions in place and run pytest
# doc/modules/clustering.rst and use sklearn from th... | 84 | 2,871 |
scikit-optimize | skopt/searchcv.py | .py | import warnings
try:
from collections.abc import Sized
except ImportError:
from collections import Sized
import numpy as np
from scipy.stats import rankdata
from sklearn.model_selection._search import BaseSearchCV
from sklearn.utils import check_random_state
from sklearn.utils.validation import check_is_fit... | 521 | 20,988 |
scikit-optimize | skopt/utils.py | .py | from copy import deepcopy
from functools import wraps
from sklearn.utils import check_random_state
import numpy as np
from scipy.optimize import OptimizeResult
from scipy.optimize import minimize as sp_minimize
from sklearn.base import is_regressor
from sklearn.ensemble import GradientBoostingRegressor
from joblib impo... | 796 | 27,455 |
scikit-optimize | skopt/__init__.py | .py | """
Scikit-Optimize, or `skopt`, is a simple and efficient library to
minimize (very) expensive and noisy black-box functions. It implements
several methods for sequential model-based optimization. `skopt` is reusable
in many contexts and accessible.
"""
try:
# This variable is injected in the __builtins__ by the b... | 83 | 2,357 |
scikit-optimize | skopt/callbacks.py | .py | """Monitor and influence the optimization procedure via callbacks.
Callbacks are callables which are invoked after each iteration of the optimizer
and are passed the results "so far". Callbacks can monitor progress, or stop
the optimization early by returning `True`.
"""
try:
from collections.abc import Callable
... | 320 | 9,377 |
scikit-optimize | skopt/benchmarks.py | .py | # -*- coding: utf-8 -*-
"""A collection of benchmark problems."""
import numpy as np
def bench1(x):
"""A benchmark function for test purposes.
f(x) = x ** 2
It has a single minima with f(x*) = 0 at x* = 0.
"""
return x[0] ** 2
def bench1_with_time(x):
"""Same as bench1 but returns the... | 101 | 2,931 |
scikit-optimize | skopt/acquisition.py | .py | import numpy as np
import warnings
from scipy.stats import norm
def gaussian_acquisition_1D(X, model, y_opt=None, acq_func="LCB",
acq_func_kwargs=None, return_grad=True):
"""
A wrapper around the acquisition function that is called by fmin_l_bfgs_b.
This is because lbfgs allo... | 322 | 11,160 |
scikit-optimize | skopt/plots.py | .py | # -*- encoding: UTF-8 -*-
"""Plotting functions."""
import sys
import numpy as np
from itertools import count
from functools import partial
from scipy.optimize import OptimizeResult
from .acquisition import _gaussian_acquisition
from skopt import expected_minimum, expected_minimum_random_sampling
from .space import Ca... | 1,398 | 51,950 |
scikit-optimize | skopt/space/__init__.py | .py | """
Utilities to define a search space.
"""
from .space import *
| 6 | 66 |
scikit-optimize | skopt/space/transformers.py | .py | from __future__ import division
import numpy as np
from sklearn.preprocessing import LabelBinarizer
from sklearn.utils import column_or_1d
class Transformer(object):
"""Base class for all 1-D transformers.
"""
def fit(self, X):
return self
def transform(self, X):
raise NotImplementedE... | 311 | 8,748 |
scikit-optimize | skopt/space/space.py | .py | import numbers
import numpy as np
import yaml
from scipy.stats.distributions import randint
from scipy.stats.distributions import rv_discrete
from scipy.stats.distributions import uniform
from sklearn.utils import check_random_state
from sklearn.utils.fixes import sp_version
from .transformers import CategoricalEnco... | 1,141 | 38,720 |
scikit-optimize | skopt/tests/test_sampler.py | .py | import pytest
import numbers
import numpy as np
import os
import yaml
from tempfile import NamedTemporaryFile
from numpy.testing import assert_array_almost_equal
from numpy.testing import assert_almost_equal
from numpy.testing import assert_array_equal
from numpy.testing import assert_equal
from numpy.testing import a... | 287 | 9,615 |
scikit-optimize | skopt/tests/test_optimizer.py | .py | import numpy as np
import pytest
from sklearn.multioutput import MultiOutputRegressor
from numpy.testing import assert_array_equal
from numpy.testing import assert_equal
from numpy.testing import assert_raises
from skopt import gp_minimize
from skopt import forest_minimize
from skopt.benchmarks import bench1, bench1_... | 403 | 13,909 |
scikit-optimize | skopt/tests/test_searchcv.py | .py | """Test scikit-optimize based implementation of hyperparameter
search with interface similar to those of GridSearchCV
"""
import pytest
from sklearn.datasets import load_iris, make_classification
from sklearn.model_selection import train_test_split
from sklearn.pipeline import Pipeline
from sklearn.svm import SVC, Li... | 466 | 14,055 |
scikit-optimize | skopt/tests/test_space.py | .py | import pytest
import numbers
import numpy as np
import os
import yaml
from tempfile import NamedTemporaryFile
from numpy.testing import assert_array_almost_equal
from numpy.testing import assert_array_equal
from numpy.testing import assert_equal
from numpy.testing import assert_raises_regex
from skopt import Optimize... | 797 | 27,757 |
scikit-optimize | skopt/tests/test_parallel_cl.py | .py | """This script contains set of functions that test parallel optimization with
skopt, where constant liar parallelization strategy is used.
"""
from numpy.testing import assert_equal
from numpy.testing import assert_raises
from skopt.space import Real
from skopt import Optimizer
from skopt.benchmarks import branin
im... | 165 | 5,399 |
scikit-optimize | skopt/tests/test_transformers.py | .py | import pytest
import numbers
import numpy as np
from numpy.testing import assert_raises
from numpy.testing import assert_array_equal
from numpy.testing import assert_equal
from numpy.testing import assert_raises_regex
from skopt.space import LogN, Normalize
from skopt.space.transformers import StringEncoder, LabelEncod... | 121 | 4,017 |
scikit-optimize | skopt/tests/test_forest_opt.py | .py | from functools import partial
from sklearn.tree import DecisionTreeClassifier
import pytest
from skopt import gbrt_minimize
from skopt import forest_minimize
from skopt.benchmarks import bench1
from skopt.benchmarks import bench2
from skopt.benchmarks import bench3
from skopt.benchmarks import bench4
MINIMIZERS = [(... | 75 | 2,587 |
scikit-optimize | skopt/tests/test_deprecation.py | .py | from functools import partial
from itertools import product
import pytest
from skopt import gp_minimize
from skopt import forest_minimize
from skopt import gbrt_minimize
from skopt import Optimizer
from skopt.learning import ExtraTreesRegressor
# dummy_minimize does not support same parameters so
# treated separate... | 31 | 854 |
scikit-optimize | skopt/tests/test_gpr.py | .py | import pytest
import numpy as np
from skopt.learning import GaussianProcessRegressor
@pytest.mark.fast_test
def test_gpr_uses_noise():
""" Test that gpr is using WhiteKernel"""
X = np.random.normal(size=[100, 2])
Y = np.random.normal(size=[100])
g_gaussian = GaussianProcessRegressor(noise='gaussian... | 18 | 428 |
scikit-optimize | skopt/tests/test_dummy_opt.py | .py | import pytest
from skopt import dummy_minimize
from skopt.benchmarks import bench1
from skopt.benchmarks import bench2
from skopt.benchmarks import bench3
def check_minimize(func, y_opt, dimensions, margin, n_calls):
r = dummy_minimize(func, dimensions, n_calls=n_calls, random_state=1)
assert r.fun < y_opt + ... | 28 | 773 |
scikit-optimize | skopt/tests/test_plots.py | .py | """Scikit-optimize plotting tests."""
import numpy as np
import pytest
from sklearn.datasets import load_breast_cancer
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import cross_val_score
from numpy.testing import assert_array_almost_equal
from skopt.space import Integer, Categorical
from... | 179 | 6,642 |
scikit-optimize | skopt/tests/test_callbacks.py | .py | import pytest
import numpy as np
import os
from collections import namedtuple
from skopt import dummy_minimize
from skopt import gp_minimize
from skopt.benchmarks import bench1
from skopt.benchmarks import bench3
from skopt.callbacks import TimerCallback
from skopt.callbacks import DeltaYStopper
from skopt.callbacks ... | 123 | 3,735 |
scikit-optimize | skopt/tests/test_benchmarks.py | .py | import numpy as np
import pytest
from numpy.testing import assert_array_almost_equal
from numpy.testing import assert_almost_equal
from skopt.benchmarks import branin
from skopt.benchmarks import hart6
@pytest.mark.fast_test
def test_branin():
xstars = np.asarray([(-np.pi, 12.275), (+np.pi, 2.275), (9.42478, 2.... | 24 | 716 |
scikit-optimize | skopt/tests/test_gp_opt.py | .py | import numpy as np
from numpy.testing import assert_array_equal
import pytest
from skopt import gp_minimize
from skopt.benchmarks import bench1
from skopt.benchmarks import bench2
from skopt.benchmarks import bench3
from skopt.benchmarks import bench4
from skopt.benchmarks import branin
from skopt.space.space import R... | 168 | 5,625 |
scikit-optimize | skopt/tests/test_common.py | .py | from functools import partial
from itertools import product
import numpy as np
from scipy.optimize import OptimizeResult
import pytest
from numpy.testing import assert_almost_equal
from numpy.testing import assert_array_less
from numpy.testing import assert_array_equal
from numpy.testing import assert_array_almost_e... | 439 | 15,956 |
scikit-optimize | skopt/tests/test_utils.py | .py | import pytest
import tempfile
from numpy.testing import assert_array_equal
from numpy.testing import assert_equal
from numpy.testing import assert_raises
import numpy as np
from skopt import gp_minimize, forest_minimize
from skopt import load
from skopt import dump
from skopt import expected_minimum, expected_minimum... | 308 | 10,314 |
scikit-optimize | skopt/tests/test_acquisition.py | .py | import numpy as np
import pytest
from scipy import optimize
from sklearn.multioutput import MultiOutputRegressor
from numpy.testing import assert_array_almost_equal
from numpy.testing import assert_array_equal
from numpy.testing import assert_raises
from skopt.acquisition import _gaussian_acquisition
from skopt.acqu... | 177 | 5,891 |
scikit-optimize | skopt/learning/__init__.py | .py | """Machine learning extensions for model-based optimization."""
from .forest import RandomForestRegressor
from .forest import ExtraTreesRegressor
from .gaussian_process import GaussianProcessRegressor
from .gbrt import GradientBoostingQuantileRegressor
__all__ = ("RandomForestRegressor",
"ExtraTreesRegres... | 13 | 413 |
scikit-optimize | skopt/learning/forest.py | .py | import numpy as np
from sklearn.ensemble import RandomForestRegressor as _sk_RandomForestRegressor
from sklearn.ensemble import ExtraTreesRegressor as _sk_ExtraTreesRegressor
def _return_std(X, trees, predictions, min_variance):
"""
Returns `std(Y | X)`.
Can be calculated by E[Var(Y | Tree)] + Var(E[Y | ... | 446 | 18,516 |
scikit-optimize | skopt/learning/gbrt.py | .py | import numpy as np
from sklearn.base import clone
from sklearn.base import BaseEstimator, RegressorMixin
from sklearn.ensemble import GradientBoostingRegressor
from sklearn.utils import check_random_state
from joblib import Parallel, delayed
def _parallel_fit(regressor, X, y):
return regressor.fit(X, y)
class ... | 124 | 4,649 |
scikit-optimize | skopt/learning/tests/test_forest.py | .py | import numpy as np
import pytest
from scipy import stats
from numpy.testing import assert_equal
from numpy.testing import assert_array_equal
from numpy.testing import assert_almost_equal
from skopt.learning import ExtraTreesRegressor, RandomForestRegressor
def truth(X):
return 0.5 * np.sin(1.75*X[:, 0])
@pyt... | 103 | 3,418 |
scikit-optimize | skopt/learning/tests/test_gbrt.py | .py | import numpy as np
import pytest
from scipy import stats
from sklearn.ensemble import GradientBoostingRegressor
from sklearn.ensemble import RandomForestRegressor
from numpy.testing import assert_equal
from numpy.testing import assert_array_equal
from numpy.testing import assert_almost_equal
from skopt.learning imp... | 114 | 3,289 |
scikit-optimize | skopt/learning/gaussian_process/kernels.py | .py | from math import sqrt
import numpy as np
from sklearn.gaussian_process.kernels import Kernel as sk_Kernel
from sklearn.gaussian_process.kernels import ConstantKernel as sk_ConstantKernel
from sklearn.gaussian_process.kernels import DotProduct as sk_DotProduct
from sklearn.gaussian_process.kernels import Exponentiation... | 422 | 14,794 |
scikit-optimize | skopt/learning/gaussian_process/__init__.py | .py | from .gpr import GaussianProcessRegressor
__all__ = ("GaussianProcessRegressor")
| 4 | 82 |
scikit-optimize | skopt/learning/gaussian_process/gpr.py | .py | import numpy as np
import warnings
from scipy.linalg import cho_solve
from scipy.linalg import solve_triangular
import sklearn
from sklearn.gaussian_process import GaussianProcessRegressor as sk_GaussianProcessRegressor
from sklearn.utils import check_array
from .kernels import ConstantKernel
from .kernels import Su... | 369 | 15,238 |
scikit-optimize | skopt/learning/gaussian_process/tests/test_gpr.py | .py | import numpy as np
import pytest
from scipy import optimize
from numpy.testing import assert_almost_equal
from numpy.testing import assert_array_almost_equal
from numpy.testing import assert_array_equal
from skopt.learning import GaussianProcessRegressor
from skopt.learning.gaussian_process.kernels import RBF
from s... | 122 | 3,775 |
scikit-optimize | skopt/learning/gaussian_process/tests/test_kernels.py | .py | import numpy as np
from scipy import optimize
from scipy.spatial.distance import pdist, squareform
try:
from sklearn.preprocessing import OrdinalEncoder
UseOrdinalEncoder = True
except ImportError:
UseOrdinalEncoder = False
from numpy.testing import assert_array_almost_equal
from numpy.testing import assert... | 213 | 7,406 |
scikit-optimize | skopt/sampler/grid.py | .py | """
Inspired by https://github.com/jonathf/chaospy/blob/master/chaospy/
distributions/sampler/sequences/grid.py
"""
import numpy as np
from .base import InitialPointGenerator
from ..space import Space
from sklearn.utils import check_random_state
def _quadrature_combine(args):
args = [np.asarray(arg).reshape(len(a... | 171 | 6,250 |
scikit-optimize | skopt/sampler/__init__.py | .py | """
Utilities for generating initial sequences
"""
from .lhs import Lhs
from .sobol import Sobol
from .halton import Halton
from .hammersly import Hammersly
from .grid import Grid
from .base import InitialPointGenerator
__all__ = [
"Lhs", "Sobol",
"Halton", "Hammersly",
"Grid", "InitialPointGenerator"
]
| 17 | 319 |
scikit-optimize | skopt/sampler/sobol.py | .py | """
Authors:
Original FORTRAN77 version of i4_sobol by Bennett Fox.
MATLAB version by John Burkardt.
PYTHON version by Corrado Chisari
Original Python version of is_prime by Corrado Chisari
Original MATLAB versions of other functions by John Burkardt.
PYTHON versions by Corrado Chisari
... | 429 | 15,086 |
scikit-optimize | skopt/sampler/hammersly.py | .py | # -*- coding: utf-8 -*-
""" Inspired by https://github.com/jonathf/chaospy/blob/master/chaospy/
distributions/sampler/sequences/hammersley.py
"""
import numpy as np
from .halton import Halton
from ..space import Space
from .base import InitialPointGenerator
from sklearn.utils import check_random_state
class Hammersly... | 93 | 3,447 |
scikit-optimize | skopt/sampler/halton.py | .py | """
Inspired by https://github.com/jonathf/chaospy/blob/master/chaospy/
distributions/sampler/sequences/halton.py
"""
import numpy as np
from .base import InitialPointGenerator
from ..space import Space
from sklearn.utils import check_random_state
class Halton(InitialPointGenerator):
"""Creates `Halton` sequence ... | 183 | 5,949 |
scikit-optimize | skopt/sampler/lhs.py | .py | """
Lhs functions are inspired by
https://github.com/clicumu/pyDOE2/blob/
master/pyDOE2/doe_lhs.py
"""
import numpy as np
from sklearn.utils import check_random_state
from scipy import spatial
from ..space import Space, Categorical
from .base import InitialPointGenerator
def _random_permute_matrix(h, random_state=Non... | 146 | 5,689 |
scikit-optimize | skopt/sampler/base.py | .py |
from collections import defaultdict
class InitialPointGenerator(object):
def generate(self, dimensions, n_samples, random_state=None):
raise NotImplemented
def set_params(self, **params):
"""
Set the parameters of this initial point generator.
Parameters
----------
... | 29 | 689 |
scikit-optimize | skopt/optimizer/__init__.py | .py | from .base import base_minimize
from .dummy import dummy_minimize
from .forest import forest_minimize
from .gbrt import gbrt_minimize
from .gp import gp_minimize
from .optimizer import Optimizer
__all__ = [
"base_minimize", "dummy_minimize",
"forest_minimize", "gbrt_minimize", "gp_minimize",
"Optimizer"
]... | 14 | 321 |
scikit-optimize | skopt/optimizer/dummy.py | .py | """Random search."""
from .base import base_minimize
def dummy_minimize(func, dimensions, n_calls=100,
initial_point_generator="random", x0=None, y0=None,
random_state=None, verbose=False, callback=None,
model_queue_size=None, init_point_gen_kwargs=None):
... | 121 | 5,067 |
scikit-optimize | skopt/optimizer/gp.py | .py | """Gaussian process-based minimization algorithms."""
import numpy as np
from sklearn.utils import check_random_state
from .base import base_minimize
from ..utils import cook_estimator
from ..utils import normalize_dimensions
def gp_minimize(func, dimensions, base_estimator=None,
n_calls=100, n_ran... | 269 | 11,787 |
scikit-optimize | skopt/optimizer/forest.py | .py | """Forest based minimization algorithms."""
from sklearn.utils import check_random_state
from .base import base_minimize
from ..utils import cook_estimator
def forest_minimize(func, dimensions, base_estimator="ET", n_calls=100,
n_random_starts=None, n_initial_points=10, acq_func="EI",
... | 197 | 8,477 |
scikit-optimize | skopt/optimizer/gbrt.py | .py |
from sklearn.utils import check_random_state
from .base import base_minimize
from ..utils import cook_estimator
def gbrt_minimize(func, dimensions, base_estimator=None,
n_calls=100, n_random_starts=None,
n_initial_points=10,
initial_point_generator="random",
... | 188 | 8,069 |
scikit-optimize | skopt/optimizer/base.py | .py | """
Abstraction for optimizers.
It is sufficient that one re-implements the base estimator.
"""
import warnings
import numbers
try:
from collections.abc import Iterable
except ImportError:
from collections import Iterable
import numpy as np
from ..callbacks import check_callback
from ..callbacks import Verb... | 306 | 12,529 |
scikit-optimize | skopt/optimizer/optimizer.py | .py | import sys
import warnings
from math import log
from numbers import Number
import numpy as np
from scipy.optimize import fmin_l_bfgs_b
from sklearn.base import clone
from sklearn.base import is_regressor
from joblib import Parallel, delayed
from sklearn.multioutput import MultiOutputRegressor
from sklearn.utils impor... | 677 | 27,738 |
scikit-optimize | benchmarks/bench_ml.py | .py | """
This code implements benchmark for the black box optimization algorithms,
applied to a task of optimizing parameters of ML algorithms for the task
of supervised learning.
The code implements benchmark on 4 datasets where parameters for 6 classes
of supervised models are tuned to optimize performance on datasets. S... | 435 | 15,648 |
scikit-optimize | benchmarks/bench_branin.py | .py | import numpy as np
import argparse
from skopt.benchmarks import branin
from skopt import gp_minimize
from skopt import forest_minimize
from skopt import gbrt_minimize
from skopt import dummy_minimize
def run(n_calls=200, n_runs=10, acq_optimizer="lbfgs"):
bounds = [(-5.0, 10.0), (0.0, 15.0)]
optimizers = [("g... | 67 | 2,586 |
scikit-optimize | benchmarks/bench_hart6.py | .py | import argparse
import numpy as np
from skopt.benchmarks import hart6
from skopt import gp_minimize
from skopt import forest_minimize
from skopt import gbrt_minimize
from skopt import dummy_minimize
def run(n_calls=200, n_runs=10, acq_optimizer="lbfgs"):
bounds = np.tile((0., 1.), (6, 1))
optimizers = [("gp_... | 67 | 2,543 |
scikit-optimize | doc/conf.py | .py | # -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config
# -- Path setup ------------------------------------------------------------... | 384 | 12,427 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.