himalaya.kernel_ridge.Kernelizer¶
- class himalaya.kernel_ridge.Kernelizer(kernel='linear', kernel_params=None, force_cpu=False)[source]¶
Transform tabular data into a kernel.
- Parameters
- kernelstr or callable, default=”linear”
Kernel mapping. Available kernels are: ‘linear’, ‘polynomial, ‘poly’, ‘rbf’, ‘sigmoid’, ‘cosine’, or ‘precomputed’. Set to ‘precomputed’ in order to pass a precomputed kernel matrix to the estimator methods instead of samples. A callable should accept two arguments and the keyword arguments passed to this object as kernel_params, and should return a floating point number.
- kernel_paramsdict or None
Additional parameters for the kernel function. See more details in the docstring of the function: Kernelizer.ALL_KERNELS[kernel]
- force_cpubool
If True, computations will be performed on CPU, ignoring the current backend. If False, use the current backend.
Examples
>>> from himalaya.kernel_ridge import Kernelizer >>> import numpy as np >>> n_samples, n_features, n_targets = 10, 5, 3 >>> X = np.random.randn(n_samples, n_features) >>> model = Kernelizer() >>> model.fit_transform(X).shape (10, 10)
- Attributes
- X_fit_array of shape (n_samples, n_features)
Training data. If kernel == “precomputed” this is None.
- n_features_in_int
Number of features (or number of samples if kernel == “precomputed”) used during the fit.
- dtype_str
Dtype of input data.
Methods
fit
(X[, y])Compute the kernel on the training set.
fit_transform
(X[, y])Compute the kernel on the training set.
get_X_fit
()Helper to get the input data X seen during the fit.
get_params
([deep])Get parameters for this estimator.
set_params
(**params)Set the parameters of this estimator.
transform
(X)Compute the kernel on any data set.