-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from jungtaekkim/0.1.5
0.1.5
- Loading branch information
Showing
72 changed files
with
562 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,32 @@ | ||
# | ||
# author: Jungtaek Kim ([email protected]) | ||
# last updated: November 5, 2020 | ||
# last updated: June 24, 2021 | ||
# | ||
|
||
__version__ = '0.1.4' | ||
__version__ = '0.1.5' | ||
|
||
|
||
from bayeso_benchmarks.inf_dim_ackley import Ackley | ||
from bayeso_benchmarks.inf_dim_cosines import Cosines | ||
from bayeso_benchmarks.inf_dim_rosenbrock import Rosenbrock | ||
from bayeso_benchmarks.inf_dim_sphere import Sphere | ||
|
||
from bayeso_benchmarks.one_dim_constant import Constant | ||
from bayeso_benchmarks.one_dim_gramacyandlee2012 import GramacyAndLee2012 | ||
from bayeso_benchmarks.one_dim_linear import Linear | ||
from bayeso_benchmarks.one_dim_step import Step | ||
|
||
from bayeso_benchmarks.two_dim_beale import Beale | ||
from bayeso_benchmarks.two_dim_bohachevsky import Bohachevsky | ||
from bayeso_benchmarks.two_dim_branin import Branin | ||
from bayeso_benchmarks.two_dim_dejong5 import DeJong5 | ||
from bayeso_benchmarks.two_dim_dropwave import DropWave | ||
from bayeso_benchmarks.two_dim_eggholder import Eggholder | ||
from bayeso_benchmarks.two_dim_goldsteinprice import GoldsteinPrice | ||
from bayeso_benchmarks.two_dim_holdertable import HolderTable | ||
from bayeso_benchmarks.two_dim_michalewicz import Michalewicz | ||
from bayeso_benchmarks.two_dim_sixhumpcamel import SixHumpCamel | ||
from bayeso_benchmarks.two_dim_threehumpcamel import ThreeHumpCamel | ||
|
||
from bayeso_benchmarks.three_dim_hartmann3d import Hartmann3D | ||
from bayeso_benchmarks.six_dim_hartmann6d import Hartmann6D |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# | ||
# author: Jungtaek Kim ([email protected]) | ||
# last updated: February 8, 2021 | ||
# last updated: May 1, 2021 | ||
# | ||
|
||
import numpy as np | ||
|
@@ -126,7 +126,7 @@ def output_sparse_gaussian_noise(self, X, scale_noise=0.1, sparsity=0.01): | |
num_X = X.shape[0] | ||
else: | ||
num_X = 1 | ||
|
||
noise = self.random_state.randn(num_X) | ||
mask = self.random_state.uniform(low=0.0, high=1.0, size=num_X) < sparsity | ||
noise *= mask.astype(np.float) | ||
|
@@ -138,6 +138,44 @@ def output_sparse_gaussian_noise(self, X, scale_noise=0.1, sparsity=0.01): | |
assert Y.shape[1] == 1 | ||
return Y | ||
|
||
def output_student_t_noise(self, X, scale_noise=0.01, dof=4.0): | ||
assert isinstance(scale_noise, float) | ||
assert isinstance(dof, float) | ||
|
||
by = self._output(X) | ||
by += scale_noise * self.random_state.standard_t(dof, size=by.shape[0]) | ||
|
||
Y = np.expand_dims(by, axis=1) | ||
|
||
assert len(Y.shape) == 2 | ||
assert Y.shape[1] == 1 | ||
return Y | ||
|
||
def output_sparse_student_t_noise(self, X, scale_noise=0.1, dof=4.0, sparsity=0.01): | ||
assert isinstance(scale_noise, float) | ||
assert isinstance(dof, float) | ||
assert isinstance(sparsity, float) | ||
assert sparsity >= 0.0 and sparsity <= 1.0 | ||
assert sparsity < 0.5 | ||
|
||
by = self._output(X) | ||
|
||
if len(X.shape) == 2: | ||
num_X = X.shape[0] | ||
else: | ||
num_X = 1 | ||
|
||
noise = self.random_state.standard_t(dof, size=num_X) | ||
mask = self.random_state.uniform(low=0.0, high=1.0, size=num_X) < sparsity | ||
noise *= mask.astype(np.float) | ||
by += scale_noise * noise | ||
|
||
Y = np.expand_dims(by, axis=1) | ||
|
||
assert len(Y.shape) == 2 | ||
assert Y.shape[1] == 1 | ||
return Y | ||
|
||
def validate_properties(self): | ||
shape_bounds = self.get_bounds().shape | ||
|
||
|
@@ -154,7 +192,7 @@ def validate_properties(self): | |
else: | ||
assert self.dimensionality == shape_bounds[0] == shape_global_minimizers[1] | ||
|
||
def get_grids(self, num_grids): | ||
def sample_grids(self, num_grids): | ||
assert isinstance(num_grids, int) | ||
|
||
list_grids = [] | ||
|
@@ -167,3 +205,21 @@ def get_grids(self, num_grids): | |
grids = np.vstack(tuple(list_grids)) | ||
grids = grids.T | ||
return grids | ||
|
||
def sample_uniform(self, num_points, seed=None): | ||
assert isinstance(num_points, int) | ||
assert isinstance(seed, (type(None), int)) | ||
|
||
random_state_ = np.random.RandomState(seed) | ||
|
||
if self.dimensionality is np.inf: | ||
dim_problem = self.dim_problem | ||
else: | ||
dim_problem = self.dimensionality | ||
|
||
bounds = self.get_bounds() | ||
|
||
points = random_state_.uniform(size=(num_points, dim_problem)) | ||
points = (bounds[:, 0] + (bounds[:, 1] - bounds[:, 0])) * points | ||
|
||
return points |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.