-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsamKriging.py
More file actions
27 lines (22 loc) · 883 Bytes
/
Copy pathsamKriging.py
File metadata and controls
27 lines (22 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import pyKriging
from pyKriging.krige import kriging
from pyKriging.samplingplan import samplingplan
# The Kriging model starts by defining a sampling plan, we use an optimal Latin Hypercube here
sp = samplingplan(6)
X = sp.optimallhc(20)
# Next, we define the problem we would like to solve
testfun = pyKriging.testfunctions().branin
y = testfun(X)
# Now that we have our initial data, we can create an instance of a Kriging model
k = kriging(X, y, testfunction=testfun, name='simple')
k.train()
# # Now, five infill points are added. Note that the model is re-trained after each point is added
# numiter = 5
# for i in range(numiter):
# print ('Infill iteration {0} of {1}....'.format(i + 1, numiter))
# newpoints = k.infill(1)
# for point in newpoints:
# k.addPoint(point, testfun(point)[0])
# k.train()
# And plot the results
k.plot()