ruckus.convolution module¶
- class ruckus.convolution.ConvolutionalRKHS(window_shape=(2,), stride=(1,), rkhs=None, *, flatten_samples=True, flatten_features=False, copy_X=True)[source]¶
Bases:
ruckus.base.RKHSKernels can be applied directly to data, or as a filter to a convolution [1]. This class allows one to convolve an RKHS filter over \(N\mathrm{D}\) data.
The dimension of the sample indices is set by the length of the
window_shapeandstrideparameters, which must match. For instance, one can take a \(2\times 3\) dimension window over the first two dimensions of the data by settingwindow_shape = (2,3)andstride=(1,1). After pulling the sliding window data, it is fitted to or transformed by therkhsspecified by the parameters.- Parameters
window_shape (
tuple) – Default = (2,). Specifies the shape of the sliding window to be passed over the firstlen(window_shape)axes of the data.stride (
tuple) – Default = (1,). Specifies how many steps the window takes in each direction during the convolution.rkhs (
RKHSorNone) – Default =None. Specifies theRKHSto be applied to the convolved data. IfNone, a baseRKHSinstance is generated.flatten_samples (
bool) – Default =True. IfTrue, the axes which the window was applied to are flattened after the convolution. Ideal for passing to otherRKHSinstances which only recognize one sample dimension.flatten_features (
bool) – Default =False. IfTrue, the original features ofXand the new window axes are flattened together.copy_X (
bool) – Default =True. IfTrue, inputXis copied and stored by the model in theX_fit_attribute. If no further changes will be done toX, settingcopy_X=Falsesaves 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.ndarrayof 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.ndarrayof shape(n_samples, n_features_1,...,n_features_d)) – Training vector, wheren_samplesis 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 self.rkhs.take and self.rkhs.filter after convolution.- Returns
The instance itself
- Return type
RKHS
- fit_transform(X, y=None)[source]¶
Fit the model from data in
Xand transformX.- Parameters
X (
numpy.ndarrayof shape(n_samples, n_features_1,...,n_features_d)) – Training vector, wheren_samplesis 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 self.rkhs.take and self.rkhs.filter after convolution.- Returns
The transformed data
- Return type
numpy.ndarrayof shape(n_samples,)+self.shape_out_
- transform(X)[source]¶
Transform
X.- Parameters
X (
numpy.ndarrayof shape(n_samples, n_features_1,...,n_features_d)) – Data vector, wheren_samplesis the number of samples and(n_features_1,...,n_features_d)is the shape of the input data. These must matchself.shape_in_.- Returns
The transformed data
- Return type
numpy.ndarrayof shape(n_samples,)+self.shape_out_