Mix
src.geostat.kernel.Mix
Bases: Kernel
Mix kernel class for combining multiple Gaussian Process (GP) kernels.
The Mix
class defines a kernel that allows combining multiple input kernels, either using
specified weights or by directly mixing the component kernels. This provides a flexible way to
create complex covariance structures by blending the properties of different kernels.
Parameters:
-
inputs
(list of Kernel objects
) –A list of kernel objects to be combined.
-
weights
(matrix
, default:None
) –A matrix specifying how the input kernels should be combined. If not provided, the kernels are combined without weighting.
Examples:
Combining multiple kernels with specified weights:
from geostat.kernel import Mix, SquaredExponential, Noise
# Create individual kernels
kernel1 = SquaredExponential(sill=1.0, range=2.0)
kernel2 = Noise(nugget=0.1)
# Combine kernels using the Mix class
mixed_kernel = Mix(inputs=[kernel1, kernel2], weights=[[0.6, 0.4], [0.4, 0.6]])
locs1 = np.array([[0.0], [1.0], [2.0]])
locs2 = np.array([[0.0], [1.0], [2.0]])
covariance_matrix = mixed_kernel({'locs1': locs1, 'locs2': locs2, 'weights': [[0.6, 0.4], [0.4, 0.6]]})
Using the Mix
kernel without weights:
Notes:
- The
call
method computes the covariance matrix by either using the specified weights to combine the input kernels or directly combining them when weights are not provided. - The
vars
method gathers the parameters from all input kernels, allowing for easy access and manipulation of their coefficients. - The
Mix
kernel is useful for creating complex, multi-faceted covariance structures by blending different types of kernels, providing enhanced modeling flexibility.
Source code in src/geostat/kernel.py
1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 |
|