Skip to content
This repository has been archived by the owner on Feb 28, 2024. It is now read-only.

Commit

Permalink
New skopt.learning module
Browse files Browse the repository at this point in the history
  • Loading branch information
betatim committed Apr 20, 2016
1 parent 98c3d1f commit 079c531
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
12 changes: 6 additions & 6 deletions skopt/gbrt_opt.py
Expand Up @@ -9,7 +9,7 @@
from sklearn.base import clone
from sklearn.utils import check_random_state

from .gbrt import GradientBoostingQuantileRegressor
from .learning import GradientBoostingQuantileRegressor
from .utils import extract_bounds


Expand Down Expand Up @@ -49,7 +49,7 @@ def _expected_improvement(X, surrogate, y_opt, xi=0.01):
return ei


def _random_point(lower, upper, n_points=1, random_state=None):
def _random_points(lower, upper, n_points=1, random_state=None):
"""Sample a random point"""
rng = check_random_state(random_state)

Expand Down Expand Up @@ -88,7 +88,7 @@ def gbrt_minimize(func, bounds, base_estimator=None, maxiter=100,
n_start: int, default 10
Number of random points to draw before fitting `base_estimator`
for the first time. If `n_start < maxiter` this degrades to
for the first time. If `n_start > maxiter` this degrades to
a random search for the minimum.
n_points: int, default 20
Expand Down Expand Up @@ -133,10 +133,10 @@ def gbrt_minimize(func, bounds, base_estimator=None, maxiter=100,

n_start = min(n_start, maxiter)

Xi[:n_start] = _random_point(
Xi[:n_start] = _random_points(
lower_bounds, upper_bounds, n_points=n_start, random_state=rng)
best_x = Xi[:n_start].ravel()
yi[:n_start] = [func(xi) for xi in (Xi[:n_start])]
yi[:n_start] = [func(xi) for xi in Xi[:n_start]]
best_y = np.min(yi[:n_start])

models = []
Expand All @@ -151,7 +151,7 @@ def gbrt_minimize(func, bounds, base_estimator=None, maxiter=100,
# has zero gradient over large distances. As a result we can not
# use gradient based optimisers like BFGS, use random sampling
# for the moment.
x0 = _random_point(lower_bounds, upper_bounds,
x0 = _random_points(lower_bounds, upper_bounds,
n_points=n_points,
random_state=rng)
aq = _expected_improvement(x0, rgr, best_y)
Expand Down
1 change: 1 addition & 0 deletions skopt/learning/__init__.py
@@ -0,0 +1 @@
from .gbrt import GradientBoostingQuantileRegressor
File renamed without changes.
2 changes: 1 addition & 1 deletion skopt/tests/test_gbrt.py
Expand Up @@ -6,7 +6,7 @@
from sklearn.utils.testing import assert_array_equal
from sklearn.utils.testing import assert_almost_equal

from skopt.gbrt import GradientBoostingQuantileRegressor
from skopt.learning import GradientBoostingQuantileRegressor


def truth(X):
Expand Down
2 changes: 1 addition & 1 deletion skopt/tests/test_gbrt_opt.py
Expand Up @@ -12,7 +12,7 @@
from skopt.benchmarks import bench3
from skopt.benchmarks import branin
from skopt.benchmarks import hart6
from skopt.gbrt import GradientBoostingQuantileRegressor
from skopt.learning import GradientBoostingQuantileRegressor
from skopt.gbrt_opt import gbrt_minimize
from skopt.gbrt_opt import _expected_improvement
from skopt.utils import extract_bounds
Expand Down

0 comments on commit 079c531

Please sign in to comment.