Passed
Push — master ( 17bc31...d7387e )
by Simon
03:25
created

search_space_example.function_()   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nop 0
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
import numpy as np
2
import pandas as pd
3
from hyperactive import Hyperactive
4
5
6
def function_():
7
    pass
8
9
10
class class_:
11
    def __init__(self):
12
        pass
13
14
15
# Hyperactive can handle python objects in the search space
16
search_space = {
17
    "int": list(range(1, 10)),
18
    "float": [0.1, 0.01, 0.001],
19
    "string": ["string1", "string2"],
20
    "function": [function_],
21
    "class": [class_],
22
    "list": [[1, 1, 1], [1, 1, 2], [1, 2, 1]],
23
    "numpy": [np.array([1, 2, 3])],
24
    "pandas": [pd.DataFrame([[1, 2], [3, 4]], columns=["y1", "y2"])],
25
}
26
27
28
def objective_function(para):
29
    # score must be a single number
30
    score = 1
31
    return score
32
33
34
hyper = Hyperactive()
35
hyper.add_search(objective_function, search_space, n_iter=20)
36
hyper.run()
37
38
search_data = hyper.results(objective_function)
39
40
for col_name in search_data.columns:
41
    print("\nColumn name:", col_name, "\n", search_data[col_name][0])
42