Exemple #1
0
# Exponential correlation model are used.

# %%

regression_model = ConstantRegression()
kernel = Matern(nu=0.5)

from UQpy.utilities.MinimizeOptimizer import MinimizeOptimizer

optimizer = MinimizeOptimizer(method="L-BFGS-B")
K = GaussianProcessRegression(regression_model=regression_model,
                              optimizer=optimizer,
                              kernel=kernel,
                              optimizations_number=20,
                              hyperparameters=[1, 1, 0.1])
K.fit(samples=x.samples, values=rmodel.qoi_list)
print(K.hyperparameters)

# %% md
#
# This plot shows the actual model which is used to evaluate the samples to identify the function values.

# %%

num = 25
x1 = np.linspace(0, 1, num)
x2 = np.linspace(0, 1, num)

x1g, x2g = np.meshgrid(x1, x2)
x1gv, x2gv = x1g.reshape(x1g.size, 1), x2g.reshape(x2g.size, 1)
Exemple #2
0
# %%

gpr2 = GaussianProcessRegression(kernel=kernel2,
                                 hyperparameters=[1, 1, 0.1],
                                 optimizer=optimizer2,
                                 optimizations_number=10,
                                 noise=True,
                                 regression_model=LinearRegression())

# %% md
#
# Call the 'fit' method to train the surrogate model (GPR).

# %%

gpr2.fit(X_train, y_train)

# %% md
#
# The maximum likelihood estimates of the hyperparameters are as follows:

# %%

print(gpr2.hyperparameters)

print('Length Scale: ', gpr2.hyperparameters[0])
print('Process Variance: ', gpr2.hyperparameters[1])
print('Noise Variance: ', gpr2.hyperparameters[2])

# %% md
#
Exemple #3
0
# %%

gpr1 = GaussianProcessRegression(kernel=kernel1,
                                 hyperparameters=[10**(-3), 10**(-2)],
                                 optimizer=optimizer1,
                                 optimizations_number=10,
                                 noise=False,
                                 regression_model=LinearRegression())

# %% md
#
# Call the 'fit' method to train the surrogate model (GPR).

# %%

gpr1.fit(X_train, y_train)

# %% md
#
# The maximum likelihood estimates of the hyperparameters are as follows:

# %%

gpr1.hyperparameters

print('Length Scale: ', gpr1.hyperparameters[0])
print('Process Variance: ', gpr1.hyperparameters[1])

# %% md
#
# Use 'predict' method to compute surrogate prediction at the test samples. The attribute 'return_std' is a boolean
Exemple #4
0
    kernel=kernel3,
    hyperparameters=[10**(-3), 10**(-2), 10**(-10)],
    optimizer=optimizer3,
    optimizations_number=10,
    optimize_constraints=cons,
    bounds=bounds_3,
    noise=True,
    regression_model=QuadraticRegression())

# %% md
#
# Call the 'fit' method to train the surrogate model (GPR).

# %%

gpr3.fit(X_train, y_train)

# %% md
#
# The maximum likelihood estimates of the hyperparameters are as follows:

# %%

print(gpr3.hyperparameters)

print('Length Scale: ', gpr3.hyperparameters[0])
print('Process Variance: ', gpr3.hyperparameters[1])
print('Noise Variance: ', gpr3.hyperparameters[2])

# %% md
#