regressor
GPRegressor
¶
Source code in spotpython/gp/regressor.py
8 9 10 11 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 |
|
fit(X, y)
¶
Fit the Gaussian Process model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
ndarray
|
Training input matrix of shape (n, m). |
required |
y |
ndarray
|
Training response vector of shape (n,). |
required |
Returns:
Name | Type | Description |
---|---|---|
self |
GPRegressor
|
Fitted model. |
Source code in spotpython/gp/regressor.py
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 |
|
predict(XX)
¶
Predict using the Gaussian Process model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
XX |
ndarray
|
Test input matrix of shape (n_test, m). |
required |
Returns:
Name | Type | Description |
---|---|---|
tuple |
tuple
|
Predicted mean (mup2) and covariance (Sigmap2). |
Raises:
Type | Description |
---|---|
RuntimeError
|
If the model is not fitted. |
Examples:
>>> import numpy as np
>>> from spotpython.gp.regressor import GPRegressor
>>> X = np.array([[1, 2], [3, 4], [5, 6]])
>>> y = np.array([1, 2, 3])
>>> XX = np.array([[1, 2], [3, 4]])
>>> gp_model = GPRegressor()
>>> gp_model.fit(X, y)
>>> mup2, Sigmap2 = gp_model.predict(XX)
>>> print(mup2)
[1. 2.]
>>> print(Sigmap2)
[[1. 1.]
[1. 1.]]
Source code in spotpython/gp/regressor.py
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 |
|