ruckus.base.DirectSumRKHS class

class ruckus.base.DirectSumRKHS(subspaces, axis=0, *, copy_X=True)[source]

Bases: ruckus.base.RKHS

Given a sequence of RKHS’s with Hilbert spaces \(H_1\), …, \(H_n\) and feature maps \(\phi_1\), …, \(\phi_n\), their direct sum lives in the tensor product Hilbert space \(H_1\oplus \dots \oplus H_n\) and has feature map of stacked vectors \([\phi_1^T,\ \dots,\ \phi_n^T]^T\) [1]. Correspondingly, the shape_out_ of a DirectRKHS instance is determined the the same manner as when using numpy.concatenate() on the specified axis, while all its subspaces share the same shape_in_.

  1. Aronszajn, N. “Theory of reproducing kernels.” Trans. Amer. Math. Soc. 68 (1950), 337-404.

Parameters
  • subspaces (list of RKHS objects) – The subspace RKHS objects, listed in the order that their indices will appear along the first axis.

  • axis (int) – The axis along which the data will be concatenated. Data dimension must match on all other axes.

  • copy_X (bool) – Default = True. If True, input X is copied and stored by the model in the X_fit_ attribute. If no further changes will be done to X, setting copy_X=False saves memory by storing a reference.

Parameters
  • shape_in_ (tuple) – The required shape of the input datapoints, aka the shape of the domain space \(X\).

  • shape_out_ (tuple) – The final shape of the transformed datapoints, aka the shape of the Hilbert space \(H\).

  • X_fit_ (numpy.ndarray of shape (n_samples,)+self.shape_in_) – The data which was used to fit the model.

fit(X, y=None)[source]

Fit the model from data in X.

Parameters

X (numpy.ndarray of shape (n_samples, n_features_1,...,n_features_d)) – Training vector, where n_samples is the number of samples and (n_features_1,...,n_features_d) is the shape of the input data. Must be consistent with preprocessing instructions in sub.take and sub.filter for each sub in self.subspaces.

Returns

The instance itself

Return type

RKHS

kernel(X, Y=None)[source]

Evaluates the kernel on X and Y (or X and X) by summing the kernels of the factors.

Parameters
  • X (numpy.ndarray of shape (n_samples, n_features_1,...,n_features_d)) – Data vector, where n_samples is the number of samples and (n_features_1,...,n_features_d) is the shape of the input data. These must match self.shape_in_.

  • Y (numpy.ndarray of shape (n_samples, n_features_1,...,n_features_d)) – Default = None. Data vector, where n_samples is the number of samples and (n_features_1,...,n_features_d) is the shape of the input data. These must match self.shape_in_. If None, X is used.

Returns

The matrix K[i,j] = k(X[i],Y[j])

Return type

numpy.ndarray of shape (n_samples_1,n_samples_2)

transform(X)[source]

Transform X.

Parameters

X (numpy.ndarray of shape (n_samples, n_features_1,...,n_features_d)) – Data vector, where n_samples is the number of samples and (n_features_1,...,n_features_d) is the shape of the input data. These must match self.shape_in_.

Returns

The transformed data

Return type

numpy.ndarray of shape (n_samples,)+self.shape_out_