Skip to content

Commit e551eb3

Browse files
committed
score function takes just one argument
1 parent 1a4f76d commit e551eb3

File tree

5 files changed

+8
-14
lines changed

5 files changed

+8
-14
lines changed

src/hyperactive/base/_experiment.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Base class for experiment."""
2+
23
# copyright: hyperactive developers, MIT License (see LICENSE file)
34

45
import numpy as np
@@ -19,7 +20,7 @@ class BaseExperiment(BaseObject):
1920
def __init__(self):
2021
super().__init__()
2122

22-
def __call__(self, **kwargs):
23+
def __call__(self, kwargs):
2324
"""Score parameters, with kwargs call."""
2425
score, _ = self.score(kwargs)
2526
return score

src/hyperactive/experiment/integrations/sklearn_cv.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Experiment adapter for sklearn cross-validation experiments."""
2+
23
# copyright: hyperactive developers, MIT License (see LICENSE file)
34

45
from sklearn import clone
@@ -8,6 +9,7 @@
89

910
from hyperactive.base import BaseExperiment
1011

12+
1113
class SklearnCvExperiment(BaseExperiment):
1214
"""Experiment adapter for sklearn cross-validation experiments.
1315
@@ -71,8 +73,6 @@ class SklearnCvExperiment(BaseExperiment):
7173
>>> params = {"C": 1.0, "kernel": "linear"}
7274
>>> score, add_info = sklearn_exp.score(params)
7375
74-
Quick call without metadata return or dictionary:
75-
>>> score = sklearn_exp(C=1.0, kernel="linear")
7676
"""
7777

7878
def __init__(self, estimator, X, y, scoring=None, cv=None):

src/hyperactive/experiment/toy/_ackley.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Ackley function, common benchmark for optimization algorithms."""
2+
23
# copyright: hyperactive developers, MIT License (see LICENSE file)
34

45
import numpy as np
@@ -41,8 +42,6 @@ class Ackley(BaseExperiment):
4142
>>> params = {"x0": 1, "x1": 2}
4243
>>> score, add_info = ackley.score(params)
4344
44-
Quick call without metadata return or dictionary:
45-
>>> score = ackley(x0=1, x1=2)
4645
""" # noqa: E501
4746

4847
_tags = {

src/hyperactive/experiment/toy/_parabola.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""2D parabola function, common benchmark for optimization algorithms."""
2+
23
# copyright: hyperactive developers, MIT License (see LICENSE file)
34

45
from hyperactive.base import BaseExperiment
@@ -35,8 +36,6 @@ class Parabola(BaseExperiment):
3536
>>> params = {"x": 1, "y": 2}
3637
>>> score, add_info = parabola.score(params)
3738
38-
Quick call without metadata return or dictionary:
39-
>>> score = parabola(x=1, y=2)
4039
"""
4140

4241
_tags = {

src/hyperactive/experiment/toy/_sphere.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Sphere function, a common benchmark for optimization algorithms."""
2+
23
# copyright: hyperactive developers, MIT License (see LICENSE file)
34

45
import numpy as np
@@ -38,12 +39,6 @@ class Sphere(BaseExperiment):
3839
>>> params = {"x0": 1, "x1": 2, "x2": 3}
3940
>>> score, add_info = sphere.score(params)
4041
41-
Quick call without metadata return or dictionary:
42-
>>> score = sphere(x0=1, x1=2, x2=3)
43-
44-
Different number of dimensions changes the parameter names:
45-
>>> sphere4D = Sphere(const=0, n_dim=4)
46-
>>> score4D = sphere4D(x0=1, x1=2, x2=3, x3=4)
4742
"""
4843

4944
_tags = {
@@ -63,7 +58,7 @@ def _paramnames(self):
6358

6459
def _score(self, params):
6560
params_vec = np.array([params[f"x{i}"] for i in range(self.n_dim)])
66-
return np.sum(params_vec ** 2) + self.const, {}
61+
return np.sum(params_vec**2) + self.const, {}
6762

6863
@classmethod
6964
def get_test_params(cls, parameter_set="default"):

0 commit comments

Comments
 (0)