Expand description
Kernel Principal Component Analysis (Scholkopf, Smola & Muller, 1998).
This module provides a fully self-contained implementation of Kernel PCA
that operates through the crate’s Kernel trait.
Any kernel in the crate (RBF, Linear, Polynomial, Symbolic, etc.) can be
plugged in; the only additional requirement for fitting is Clone + 'static,
which every shipped kernel satisfies.
§Module map
| Submodule | Purpose |
|---|---|
centering | Double-centering of the Gram matrix + test-time centering |
eigendecomp | Wrapper around scirs2_linalg::eigh for top-k eigenpairs |
error | KernelPcaError / KernelPcaResult types |
model | KernelPCA, KernelPcaConfig, FittedKernelPCA |
§Minimal example
use tensorlogic_sklears_kernels::kernel_pca::{KernelPCA, KernelPcaConfig};
use tensorlogic_sklears_kernels::RbfKernel;
use tensorlogic_sklears_kernels::RbfKernelConfig;
let kernel = RbfKernel::new(RbfKernelConfig::new(1.0)).expect("kernel");
let config = KernelPcaConfig::new(2);
let model = KernelPCA::build(kernel, config).expect("model");
let data = vec![
vec![1.0, 2.0],
vec![3.0, 4.0],
vec![5.0, 6.0],
];
let fitted = model.fit(&data).expect("fit");
let embedding = fitted.transform(&data).expect("transform");
assert_eq!(embedding.nrows(), 3);
assert_eq!(embedding.ncols(), 2);§References
- Scholkopf, B., Smola, A. & Muller, K.-R. (1998). Nonlinear Component Analysis as a Kernel Eigenvalue Problem. Neural Computation 10(5), 1299–1319.
Re-exports§
pub use centering::center_test_kernel;pub use centering::double_center;pub use centering::KernelCenteringStats;pub use eigendecomp::symmetric_eigendecomp;pub use eigendecomp::TopKEigen;pub use error::KernelPcaError;pub use error::KernelPcaResult;pub use model::FittedKernelPCA;pub use model::KernelPCA;pub use model::KernelPcaConfig;
Modules§
- centering
- Double-centering utilities for Kernel PCA.
- eigendecomp
- Wrappers around
scirs2_linalg::eightailored to Kernel PCA. - error
- Error type for the Kernel PCA research-preview module.
- model
- The
KernelPCAestimator and its fitted counterpartFittedKernelPCA.