[−][src]Module smartcore::decomposition::svd
Dimensionality reduction using SVD
Similar to PCA
, SVD is a technique that can be used to reduce the number of input variables p to a smaller number k, while preserving
the most important structure or relationships between the variables observed in the data.
Contrary to PCA, SVD does not center the data before computing the singular value decomposition.
Example:
use smartcore::linalg::naive::dense_matrix::*; use smartcore::decomposition::svd::*; // Iris data let iris = DenseMatrix::from_2d_array(&[ &[5.1, 3.5, 1.4, 0.2], &[4.9, 3.0, 1.4, 0.2], &[4.7, 3.2, 1.3, 0.2], &[4.6, 3.1, 1.5, 0.2], &[5.0, 3.6, 1.4, 0.2], &[5.4, 3.9, 1.7, 0.4], &[4.6, 3.4, 1.4, 0.3], &[5.0, 3.4, 1.5, 0.2], &[4.4, 2.9, 1.4, 0.2], &[4.9, 3.1, 1.5, 0.1], &[7.0, 3.2, 4.7, 1.4], &[6.4, 3.2, 4.5, 1.5], &[6.9, 3.1, 4.9, 1.5], &[5.5, 2.3, 4.0, 1.3], &[6.5, 2.8, 4.6, 1.5], &[5.7, 2.8, 4.5, 1.3], &[6.3, 3.3, 4.7, 1.6], &[4.9, 2.4, 3.3, 1.0], &[6.6, 2.9, 4.6, 1.3], &[5.2, 2.7, 3.9, 1.4], ]); let svd = SVD::fit(&iris, SVDParameters::default(). with_n_components(2)).unwrap(); // Reduce number of features to 2 let iris_reduced = svd.transform(&iris).unwrap();
Structs
SVD | SVD |
SVDParameters | SVD parameters |