Skip to content

Commit

Permalink
Adds optimize_parameters method in the Kernel baseclass.
Browse files Browse the repository at this point in the history
  • Loading branch information
dimtsap committed Apr 6, 2022
1 parent 1132c56 commit 1a044b3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/source/utilities/kernels/euclidean_kernels.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Methods
~~~~~~~~~

.. autoclass:: UQpy.utilities.kernels.GaussianKernel
:members: optimize_epsilon
:members: optimize_parameters

Attributes
~~~~~~~~~~
Expand Down
8 changes: 4 additions & 4 deletions src/UQpy/utilities/kernels/GaussianKernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ def _kernel_entry(self, xi, xj):
def kernel_function(self, distance_pairs):
return np.exp(-sd.squareform(distance_pairs) / (4 * self.epsilon))

def optimize_epsilon(self, data: np.ndarray, tolerance: float,
n_nearest_neighbors: int,
n_cutoff_samples: int,
random_state: RandomStateType):
def optimize_parameters(self, data: np.ndarray, tolerance: float,
n_nearest_neighbors: int,
n_cutoff_samples: int,
random_state: RandomStateType):
"""
:param data: Cloud of data points.
Expand Down
12 changes: 12 additions & 0 deletions src/UQpy/utilities/kernels/baseclass/Kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ def __init__(self):
def calculate_kernel_matrix(self, points: Union[list, NumpyFloatArray]):
pass

def optimize_parameters(self, data, **kwargs_optimization):
"""
This serves as a blueprint function in case a kernel provides the ability to optimize its parameters. In that
case, the implemented kernel will provide an implementation of this method, that computes the optimized
parameters and stores their values in the kernel's attributes.
:param data: Set of data points.
:param kwargs_optimization: Keyword arguments containing any extra parameters needed to perform the optimization
of the kernel parameters.
"""
pass

@abstractmethod
def _kernel_entry(self, xi, xj):
"""
Expand Down

0 comments on commit 1a044b3

Please sign in to comment.