示例#1
0
 def measure(individual):
     func = numpy_phenotype(individual)
     data = load_boston()
     yhat = func(*data.data.T)
     if np.isscalar(yhat):
         yhat = np.ones_like(data.target) * yhat
     fit = nrmse(data.target, yhat), len(individual)
     return replace_nan(fit)
示例#2
0
def measure(ind):
    g = lambda x: x**2 - 1.1
    points = np.linspace(-1, 1, 100, endpoint=True)
    y = g(points)
    f = gp.individual.numpy_phenotype(ind)
    yhat = f(points)
    if np.isscalar(yhat):
        yhat = np.ones_like(y) * yhat
    return nrmse(y, yhat), len(gp.individual.resolve_sc(ind))
示例#3
0
def error(ind, *args):
    g = lambda x: x**2 - 1.1
    points = np.linspace(-1, 1, 100, endpoint=True)
    y = g(points)
    f = gp.individual.numpy_phenotype(ind)
    yhat = f(points, *args)

    if np.isscalar(yhat):
        yhat = np.ones_like(y) * yhat
    return nrmse(y, yhat)
示例#4
0
def error(ind, *args):
    g = lambda x: x**2 - 1.1
    points = np.linspace(-1, 1, 100, endpoint=True).reshape(ind.arity, -1)
    y = g(points)
    f = phenotype(ind)
    args[0].dot(points) + args[
        1]  # ??? without this there will be segmentation fault
    yhat = f(points, *args).reshape(y.shape)

    return nrmse(y, yhat)