kriging_ny
This is the Kriging surrogate model. It is based on the DACE matlab toolbox. It can handle numerical and categorical variables.
Kriging
¶
Kriging class with optional Nyström approximation for scalability. This class implements the Kriging surrogate model, also known as Gaussian Process regression. It is adapted to handle both numerical (ordered) and categorical (factor) variables, a key feature of spotpython. The Nyström approximation is added as an optional feature to handle large datasets efficiently.
Source code in spotpython/surrogate/kriging_ny.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
|
__init__(fun_control, n_theta=None, theta=None, p=2.0, corr='squared_exponential', isotropic=False, approximation='None', n_landmarks=100)
¶
Initialize the Kriging model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fun_control
|
dict
|
Control dictionary from spotpython, containing problem dimensions, variable types (‘var_type’), etc. |
required |
n_theta
|
int
|
Number of correlation parameters (theta). Defaults to problem dimension for anisotropic model. |
None
|
theta
|
ndarray
|
Initial correlation parameters. Defaults to 0.1 for all dimensions. |
None
|
p
|
float
|
Power for the correlation function. Defaults to 2.0. |
2.0
|
corr
|
str
|
Correlation function type. Defaults to “squared_exponential”. |
'squared_exponential'
|
isotropic
|
bool
|
Whether to use an isotropic model (one theta for all dimensions). Defaults to False. |
False
|
approximation
|
str
|
Type of approximation to use. “None” for standard Kriging, “nystroem” for Nyström approximation. Defaults to “None”. |
'None'
|
n_landmarks
|
int
|
Number of landmark points for Nyström. Only used if approximation=”nystroem”. Defaults to 100. |
100
|
Source code in spotpython/surrogate/kriging_ny.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
build_Psi(X1, X2)
¶
Builds the covariance matrix Psi between two sets of points.
Source code in spotpython/surrogate/kriging_ny.py
207 208 209 210 211 212 213 |
|
build_psi_vec(x, X_)
¶
Builds a covariance vector between a point x and a set of points X_. This method correctly handles mixed (ordered/factor) variable types.
Source code in spotpython/surrogate/kriging_ny.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
|
fit(X, y)
¶
Fit the Kriging model to the training data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X
|
ndarray
|
Training data of shape (n_samples, n_features). |
required |
y
|
ndarray
|
Target values of shape (n_samples,). |
required |
Source code in spotpython/surrogate/kriging_ny.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|
predict(X_star)
¶
Make predictions with the fitted Kriging model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X_star
|
ndarray
|
Test data of shape (n_test_samples, n_features). |
required |
Returns:
Name | Type | Description |
---|---|---|
tuple |
A tuple containing: - y_pred (np.ndarray): Predicted mean values. - y_mse (np.ndarray): Mean squared error (predictive variance). |
Source code in spotpython/surrogate/kriging_ny.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
|