コード例 #1
0
def meta_val(n_deg, x_pred, y_real, x_exp, data, x_prob, a, setting, lower_bound, upper_bound):

        if len(a) == 0:
            setting['exp_x'] = x_exp
            setting['exp_y'] = data[:,2]
            y_exp = data[:,2]
            PCE_lars = calPCE.collocation(n_deg, x_prob, x_exp, y_exp, 'LARS')
            setting['bounds'] = [(lower_bound, upper_bound), (lower_bound, upper_bound), (lower_bound, upper_bound)]
            model = createKriging.createKriging(setting, PCE_lars)
            PCE_pred, y_PCE_pred = utilPCE.predictor(PCE_lars, x_pred)
            y_kriging, ci_kriging, var_kriging = createKriging.predictor(x_pred, model, setting, PCE_lars, PCE_pred)
            y_pred = y_kriging
            y_Real = y_real[:,2]
            rmse, nrmse = utilPCE.validation(y_Real, y_pred)
        else:
            rmse = npy.zeros(len(a))
            nrmse = npy.zeros(len(a))
            for i in xrange(0, len(a)):
               setting['exp_x'] = x_exp
               setting['exp_y'] = data[i*len(x_exp):(i+1)*len(x_exp), 2]
               y_exp = data[i*len(x_exp):(i+1)*len(x_exp), 2]
               PCE_lars = calPCE.collocation(n_deg, x_prob, x_exp, y_exp, 'LARS')
               setting['bounds'] = [(lower_bound, upper_bound), (lower_bound, upper_bound)]
               model = createKriging.createKriging(setting, PCE_lars)
               PCE_pred, y_PCE_pred = utilPCE.predictor(PCE_lars, x_pred)
               y_kriging, ci_kriging, var_kriging = createKriging.predictor(x_pred, model, setting, PCE_lars, PCE_pred)
               y_pred = y_kriging
               y_Real = y_real[i*len(x_pred):(i+1)*len(x_pred), 2]
               rmse[i], nrmse[i] = utilPCE.validation(y_Real, y_pred)
        return rmse, nrmse
コード例 #2
0
ファイル: pyPCE.py プロジェクト: Auto-SK/pyMAPOD
def meta_gen(n_deg, x_pred, x_exp, data, x_prob, a, meta_type):
    if len(a) == 0:
        x_experiment = x_exp
        y_experiment = data[:, 2]
        PCE = calPCE.collocation(n_deg, x_prob, x_experiment, y_experiment, meta_type)
        PCE_pred, y_pred = utilPCE.predictor(PCE, x_pred)
        y_pred = y_pred.reshape(len(x_pred), 1)
        y_pred[y_pred < 0.0001] = min(y_pred[y_pred > 0.0001])
        index = npy.arange(1, len(x_pred) + 1)
        index.shape = (len(x_pred), 1)
        x_a = x_pred[:, 0].reshape(len(x_pred), 1)
        data_meta = npy.concatenate((index, x_a, y_pred), axis=1)
    else:
        data_meta = npy.zeros((len(a) * len(x_pred), 3))
        for i in xrange(0, len(a)):
            x_experiment = x_exp
            print(x_experiment.shape)
            y_experiment = data[i * len(x_exp):(i + 1) * len(x_exp), 2]
            print(y_experiment.shape)
            PCE = calPCE.collocation(n_deg, x_prob, x_experiment, y_experiment, meta_type)
            PCE_pred, y_pred = utilPCE.predictor(PCE, x_pred)
            y_pred = y_pred.reshape(len(x_pred), 1)
            y_pred[y_pred < 0.0001] = min(y_pred[y_pred > 0.0001])
            index = npy.arange(1 + i * len(x_pred), (i + 1) * len(x_pred) + 1)
            index.shape = (len(x_pred), 1)
            data_meta[i * len(x_pred):(i + 1) * len(x_pred), :] = npy.concatenate(
                (index, a[i] * npy.ones((len(x_pred), 1)), y_pred), axis=1)

    data = data_meta[data_meta[:, 2] > min(data_meta[:, 2])]
    return data
コード例 #3
0
def sobol_gen(a, x_prob, dim, n_exp, x_mix, *args):
    x_exp1 = args[0]
    x_exp2 = args[1]
    n_deg = args[2]
    x_exp = args[3]
    data = args[4]
    setting = args[5]
    upper_bound = args[6]
    lower_bound = args[7]
    y  = npy.zeros((n_exp, dim))
    y1 = npy.zeros((n_exp, 1))
    y2 = npy.zeros((n_exp, 1))
    setting['exp_x'] = x_exp
    setting['exp_y'] = data[:,2]
    y_exp = data[:,2]
    PCE_lars = calPCE.collocation(n_deg, x_prob, x_exp, y_exp, 'LARS')
    if len(a) == 0:
        setting['bounds'] = [(lower_bound, upper_bound), (lower_bound, upper_bound), (lower_bound, upper_bound)]
    else:
        setting['bounds'] = [(lower_bound, upper_bound), (lower_bound, upper_bound)]
    model = createKriging.createKriging(setting, PCE_lars)
    PCE_pred_1, y_PCE_pred = utilPCE.predictor(PCE_lars, x_exp1)
    y1, ci_kriging, var_kriging = createKriging.predictor(x_exp1, model, setting, PCE_lars, PCE_pred_1)
    PCE_pred_2, y_PCE_pred = utilPCE.predictor(PCE_lars, x_exp2)
    y2, ci_kriging, var_kriging = createKriging.predictor(x_exp2, model, setting, PCE_lars, PCE_pred_2)
    for i in xrange(0, dim):
        x_mix[:,:] = x_exp1
        x_mix[:,i] = x_exp2[:,i]
        PCE_pred, y_PCE_pred = utilPCE.predictor(PCE_lars, x_mix)
        y[:,i], ci_kriging, var_kriging = createKriging.predictor(x_mix, model, setting, PCE_lars, PCE_pred)

    return y1, y2, y
コード例 #4
0
def meta_gen(n_deg, x_pred, x_exp, data, x_prob, a, setting, lower_bound,
             upper_bound):
    if len(a) == 0:
        setting['exp_x'] = x_exp
        setting['exp_y'] = data[:, 2]
        y_exp = data[:, 2]
        PCE_lars = calPCE.collocation(n_deg, x_prob, x_exp, y_exp, 'LARS')
        setting['bounds'] = [(lower_bound, upper_bound),
                             (lower_bound, upper_bound),
                             (lower_bound, upper_bound)]
        model = createKriging.createKriging(setting, PCE_lars)
        PCE_pred, y_PCE_pred = utilPCE.predictor(PCE_lars, x_pred)
        y_kriging, ci_kriging, var_kriging = createKriging.predictor(
            x_pred, model, setting, PCE_lars, PCE_pred)
        y_pred = y_kriging.reshape(len(x_pred), 1)
        y_pred[y_pred < 0.0001] = min(y_pred[y_pred > 0.0001])
        index = npy.arange(1, len(x_pred) + 1)
        index.shape = (len(x_pred), 1)
        x_a = x_pred[:, 0].reshape(len(x_pred), 1)
        data_meta = npy.concatenate((index, x_a, y_pred), axis=1)
    else:
        data_meta = npy.zeros((len(a) * len(x_pred), 3))
        for i in xrange(0, len(a)):
            setting['exp_x'] = x_exp
            setting['exp_y'] = data[i * len(x_exp):(i + 1) * len(x_exp), 2]
            y_exp = data[i * len(x_exp):(i + 1) * len(x_exp), 2]
            PCE_lars = calPCE.collocation(n_deg, x_prob, x_exp, y_exp, 'LARS')
            setting['bounds'] = [(lower_bound, upper_bound),
                                 (lower_bound, upper_bound)]
            model = createKriging.createKriging(setting, PCE_lars)
            PCE_pred, y_PCE_pred = utilPCE.predictor(PCE_lars, x_pred)
            y_kriging, ci_kriging, var_kriging = createKriging.predictor(
                x_pred, model, setting, PCE_lars, PCE_pred)
            y_pred = y_kriging.reshape(len(x_pred), 1)
            y_pred[y_pred < 0.0001] = min(y_pred[y_pred > 0.0001])
            index = npy.arange(1, len(x_pred) + 1)
            index.shape = (len(x_pred), 1)
            data_meta[i * len(x_pred):(i + 1) *
                      len(x_pred), :] = npy.concatenate(
                          (index, a[i] * npy.ones((len(x_pred), 1)), y_pred),
                          axis=1)

    data = data_meta[data_meta[:, 2] > min(data_meta[:, 2])]
    return data
コード例 #5
0
ファイル: pyPCE.py プロジェクト: Auto-SK/pyMAPOD
def meta_val(n_deg, x_pred, y_real, x_exp, data, x_prob, a, meta_type):
    if len(a) == 0:
        x_experiment = x_exp
        y_experiment = data[:, 2]
        PCE = calPCE.collocation(n_deg, x_prob, x_experiment, y_experiment, meta_type)
        PCE_pred, y_pred = utilPCE.predictor(PCE, x_pred)
        y_Real = y_real[:, 2]
        rmse, nrmse = utilPCE.validation(y_Real, y_pred)
    else:
        rmse = npy.zeros(len(a))
        nrmse = npy.zeros(len(a))
        data_meta = npy.zeros((len(a) * len(x_pred), 3))
        for i in xrange(0, len(a)):
            x_experiment = x_exp
            y_experiment = data[i * len(x_exp):(i + 1) * len(x_exp), 2]
            PCE = calPCE.collocation(n_deg, x_prob, x_experiment, y_experiment, meta_type)
            PCE_pred, y_pred = utilPCE.predictor(PCE, x_pred)
            y_Real = y_real[i * len(x_pred):(i + 1) * len(x_pred), 2]
            rmse[i], nrmse[i] = utilPCE.validation(y_Real, y_pred)

    return rmse, nrmse
コード例 #6
0
ファイル: pyPCE.py プロジェクト: Auto-SK/pyMAPOD
def sobol_gen(a, x_prob, dim, n_exp, x_mix, *args):
    x_exp1 = args[0]
    x_exp2 = args[1]
    n_deg = args[2]
    x_exp = args[3]
    data = args[4]
    meta_type = args[5]
    y = npy.zeros((n_exp, dim))
    y1 = npy.zeros((n_exp, 1))
    y2 = npy.zeros((n_exp, 1))
    x_experiment = x_exp
    y_experiment = data[:, 2]
    PCE = calPCE.collocation(n_deg, x_prob, x_experiment, y_experiment, meta_type)
    PCE_1, y1 = utilPCE.predictor(PCE, x_exp1)
    PCE_2, y2 = utilPCE.predictor(PCE, x_exp2)
    for i in xrange(0, dim):
        x_mix[:, :] = x_exp1
        x_mix[:, i] = x_exp2[:, i]
        PCE_dummy, y[:, i] = utilPCE.predictor(PCE, x_mix)

    return y1, y2, y