00cce06892217b891c8a85ead8c51b28d556bd64,skopt/dummy_opt.py,,dummy_minimize,#,16

Before Change


    y = np.array(y)

    // Pack results
    res = OptimizeResult()
    best = np.argmin(y)
    res.x = X[best]
    res.fun = y[best]
    res.func_vals = y
    res.x_iters = X
    res.models = []  // Create attribute even though it is empty
    res.space = space
    res.random_state = rng
    res.specs = specs

    return res

After Change


             "function": inspect.currentframe().f_code.co_name}

    // Check params
    rng = check_random_state(random_state)
    space = Space(dimensions)

    if x0 is None:
        x0 = []
    elif not isinstance(x0[0], list):
        x0 = [x0]

    if not isinstance(x0, list):
        raise ValueError("`x0` should be a list, got %s" % type(x0))

    if len(x0) > 0 and y0 is not None:
        if isinstance(y0, Iterable):
            y0 = list(y0)
        elif isinstance(y0, numbers.Number):
            y0 = [y0]
        else:
            raise ValueError("`y0` should be an iterable or a scalar, got %s"
                             % type(y0))
        if len(x0) != len(y0):
            raise ValueError("`x0` and `y0` should have the same length")

        if not all(map(np.isscalar, y0)):
            raise ValueError("`y0` elements should be scalars")

    elif len(x0) > 0 and y0 is None:
        y0 = []
        n_calls -= len(x0)

    elif len(x0) == 0 and y0 is not None:
        raise ValueError("`x0`cannot be `None` when `y0` is provided")

    else:  // len(x0) == 0 and y0 is None
        y0 = []

    X = x0
    y = y0

    // Random search
    X = X + space.rvs(n_samples=n_calls, random_state=rng)
    first = True

    for i in range(len(y0), len(X)):

        if verbose:
            print("Function evaluation no: %d started" % (i + 1))
            t = time()

        y_i = func(X[i])

        if first:
            first = False
            if not np.isscalar(y_i):
                raise ValueError("`func` should return a scalar")

        if verbose:
            print("Function evaluation no: %d ended" % (i + 1))
            print("Time taken: %0.4f" % (time() - t))
            print("Function value obtained: %0.4f" % y_i)

        y.append(y_i)

        if callback is not None:
            callback(pack_optimize_result(X[: i + 1], y, space, rng, specs))

    y = np.array(y)
    return pack_optimize_result(X, y, space, rng, specs)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 27

Instances


Project Name: scikit-optimize/scikit-optimize
Commit Name: 00cce06892217b891c8a85ead8c51b28d556bd64
Time: 2016-08-08
Author: manojkumarsivaraj334@gmail.com
File Name: skopt/dummy_opt.py
Class Name:
Method Name: dummy_minimize


Project Name: scikit-optimize/scikit-optimize
Commit Name: 00cce06892217b891c8a85ead8c51b28d556bd64
Time: 2016-08-08
Author: manojkumarsivaraj334@gmail.com
File Name: skopt/tree_opt.py
Class Name:
Method Name: _tree_minimize


Project Name: scikit-optimize/scikit-optimize
Commit Name: 00cce06892217b891c8a85ead8c51b28d556bd64
Time: 2016-08-08
Author: manojkumarsivaraj334@gmail.com
File Name: skopt/gp_opt.py
Class Name:
Method Name: gp_minimize