human
I am working on the file "Hyperparameter Optimization.ipynb".
The first task is:
evaluation functions
Can you write Python code for it?
assistant
#Here is the Python code you requested.

def branin_hoo(params, noisy=False):
    """
    http://www.sfu.ca/~ssurjano/branin.html
    """
    unscaled_x1, unscaled_x2 = params

    x1 = unscaled_x1 * 15 - 5
    x2 = unscaled_x2 * 15

    a = 1
    b = 5.1 / (4 * np.pi ** 2)
    c = 5 / np.pi
    r = 6
    s = 10
    t = 1 / (8 * np.pi)

    term1 = a * (x2 - b * x1 ** 2 + c * x1 - r) ** 2
    term2 = s * (1 - t) * np.cos(x1)
    return term1 + term2 + s

branin_hoo([(np.pi + 5) / 15, 2.275 / 15])

def branin_hoo_with_useless_dimensions(total_dims):
    assert total_dims > 2

    p1 = np.random.randint(total_dims)
    p2 = np.random.randint(total_dims)

    def inner(params, noisy=False):
        return branin_hoo([params[p1], params[p2]], noisy)

    return inner