Kernel Methods

Base Functions

operator_learning.kernel.predict(num_steps, fit_result, K_YX, K_Xin_X, obs_train_Y)
Parameters:
  • num_steps (int)

  • fit_result (FitResult)

  • K_YX (ndarray)

  • K_Xin_X (ndarray)

  • obs_train_Y (ndarray)

Return type:

ndarray

operator_learning.kernel.eig(fit_result, K_X, K_YX)

Computes the eigendecomposition of the transfer operator.

Parameters:
  • fit_result (FitResult) – Fit result as defined in operator_learning.structs.

  • K_X (np.ndarray) – Kernel matrix of the input data.

  • K_YX (np.ndarray) – Kernel matrix between the output data and the input data.

Returns:

EigResult – as defined in operator_learning.structs

Return type:

EigResult

operator_learning.kernel.evaluate_eigenfunction(eig_result, which, K_Xin_X_or_Y)
Parameters:
  • eig_result (EigResult)

  • which (Literal['left', 'right'])

  • K_Xin_X_or_Y (ndarray)

Reduced Rank Regression

operator_learning.kernel.reduced_rank.fit(kernel_X, kernel_Y, tikhonov_reg, rank, svd_solver='arnoldi')

Fits the reduced rank estimator

Parameters:
  • kernel_X (np.ndarray) – Kernel matrix of the input data.

  • kernel_Y (np.ndarray) – Kernel matrix of the output data.

  • tikhonov_reg (float) – Tikhonov (ridge) regularization parameter.

  • rank (int) – Rank of the estimator.

  • svd_solver (Literal[ "arnoldi", "full" ], optional) – Solver for the generalized eigenvalue problem. Defaults to “arnoldi”.

Return type:

FitResult

operator_learning.kernel.reduced_rank.fit_randomized(kernel_X, kernel_Y, tikhonov_reg, rank, n_oversamples=5, optimal_sketching=False, iterated_power=1, rng_seed=None, precomputed_cholesky=None)
Parameters:
  • kernel_X (ndarray)

  • kernel_Y (ndarray)

  • tikhonov_reg (float)

  • rank (int)

  • n_oversamples (int)

  • optimal_sketching (bool)

  • iterated_power (int)

  • rng_seed (int | None)

Return type:

FitResult

operator_learning.kernel.reduced_rank.fit_nystroem(kernel_X, kernel_Y, kernel_Xnys, kernel_Ynys, tikhonov_reg, rank, svd_solver='arnoldi')

Fits the Nyström reduced rank principal components estimator

Parameters:
  • kernel_X (np.ndarray) – Kernel matrix of the input inducing points.

  • kernel_Y (np.ndarray) – Kernel matrix of the output inducing points.

  • kernel_Xnys (np.ndarray) – Kernel matrix between the input data and the input inducing points.

  • kernel_Ynys (np.ndarray) – Kernel matrix between the output data and the output inducing points.

  • tikhonov_reg (float) – Tikhonov (ridge) regularization parameter.

  • rank (int) – Rank of the estimator.

  • svd_solver (Literal[ "arnoldi", "full" ], optional) – Solver for the generalized eigenvalue problem. Defaults to “arnoldi”.

Return type:

FitResult

Principal Component Regression

operator_learning.kernel.principal_components.fit(kernel_X, tikhonov_reg=0.0, rank=None, svd_solver='arnoldi')

Fits the principal components estimator

Parameters:
  • kernel_X (np.ndarray) – Kernel matrix of the input data.

  • tikhonov_reg (float, optional) – Tikhonov (ridge) regularization parameter. Defaults to 0.0.

  • rank (int | None, optional) – Rank of the estimator. Defaults to None.

  • svd_solver (Literal[ "arnoldi", "full" ], optional) – Solver for the generalized eigenvalue problem. Defaults to “arnoldi”.

Return type:

FitResult

operator_learning.kernel.principal_components.fit_nystroem(kernel_X, kernel_Y, kernel_Xnys, kernel_Ynys, tikhonov_reg=0.0, rank=None, svd_solver='arnoldi')

Fits the principal components estimator using the Nyström method

Parameters:
  • kernel_X (np.ndarray) – Kernel matrix of the input inducing points.

  • kernel_Y (np.ndarray) – Kernel matrix of the output inducing points.

  • kernel_Xnys (np.ndarray) – Kernel matrix between the input data and the input inducing points.

  • kernel_Ynys (np.ndarray) – Kernel matrix between the output data and the output inducing points.

  • tikhonov_reg (float, optional) – Tikhonov (ridge) regularization parameter. Defaults to 0.0.

  • rank (int | None, optional) – Rank of the estimator. Defaults to None.

  • svd_solver (Literal[ "arnoldi", "full" ], optional) – Solver for the generalized eigenvalue problem. Defaults to “arnoldi”.

Return type:

FitResult

Linear Algebra Utilities

operator_learning.linalg.weighted_norm(A, M=None)

Weighted norm of the columns of A.

Parameters:
  • A (ndarray) – 1D or 2D array. If 2D, the columns are treated as vectors.

  • M (ndarray or LinearOperator, optional) – Weigthing matrix. the norm of the vector \(a\) is given by

:param \(\langle a: no checks are :param Ma\rangle\). Defaults to None: no checks are :param corresponding to the Identity matrix. Warning: no checks are :param performed on M being a PSD operator.:

Returns:

(ndarray or float) – If A.ndim == 2 returns 1D array of floats corresponding to the norms of the columns of A. Else return a float.

Parameters:
  • A (ndarray)

  • M (ndarray | None)

operator_learning.linalg.stable_topk(vec, k_max, rcond=None, ignore_warnings=True)

Takes up to k_max indices of the top k_max values of vec. If the values are below rcond, they are discarded.

Parameters:
  • vec (np.ndarray) – Vector to extract the top k indices from.

  • k (int) – Number of indices to extract.

  • rcond (float, optional) – Value below which the values are discarded. Defaults to None, in which case it is set according to the machine precision of vec’s dtype.

  • k_max (int)

  • ignore_warnings (bool)

Returns:

tuple[np.ndarray, np.ndarray] – top values and their indices.

operator_learning.linalg.add_diagonal_(M, alpha)

Add alpha to the diagonal of M inplace.

Parameters:
  • M (np.ndarray) – The matrix to modify inplace.

  • alpha (float) – The value to add to the diagonal of M.