torch.linalg.pca_lowrank
function pca_lowrank<S extends Shape, D extends DType, Dev extends DeviceType>(A: Tensor<S, D, Dev>, options?: PcaLowrankOptions): {
U: Tensor<DynamicShape, D, Dev>;
S: Tensor<DynamicShape, D, Dev>;
V: Tensor<DynamicShape, D, Dev>;
}function pca_lowrank<S extends Shape, D extends DType, Dev extends DeviceType>(A: Tensor<S, D, Dev>, q: number, center: boolean, niter: number): {
U: Tensor<DynamicShape, D, Dev>;
S: Tensor<DynamicShape, D, Dev>;
V: Tensor<DynamicShape, D, Dev>;
}Performs linear Principal Component Analysis (PCA) on a low-rank matrix.
Returns a namedtuple (U, S, V) which is the nearly optimal approximation of a singular value decomposition of a centered matrix A such that A ≈ U @ diag(S) @ V^T
The relation to PCA is: - A is a data matrix with m samples and n features - V columns represent the principal directions - S² / (m - 1) contains the eigenvalues of A^T A / (m - 1) - matmul(A, V[:, :k]) projects data to the first k principal components
Parameters
ATensor<S, D, Dev>- The input tensor of size (*, m, n)
optionsPcaLowrankOptionsoptional
Returns
{ U: Tensor<DynamicShape, D, Dev>; S: Tensor<DynamicShape, D, Dev>; V: Tensor<DynamicShape, D, Dev>; }– Object with U (m x q), S (q), V (n x q) tensors