pca#
- diffsptk.PCA#
alias of
PrincipalComponentAnalysis
- class diffsptk.PrincipalComponentAnalysis(n_comp, cov_type='sample')[source]#
See this page for details.
- Parameters:
- n_compint >= 1 [scalar]
Number of principal components, \(N\).
- cov_type[‘sample’, ‘unbiased’, ‘correlation’]
Type of covariance.
- forward(x)[source]#
Perform PCA.
- Parameters:
- xTensor [shape=(…, M+1)]
Input vectors.
- Returns:
- eTensor [shape=(N,)]
Eigenvalues ordered in ascending order.
- vTensor [shape=(M+1, N)]
Eigenvectors.
- mTensor [shape=(M+1,)]
Mean vector.
Examples
>>> x = diffsptk.nrand(10, 3) >>> pca = diffsptk.PCA(3) >>> e, _, _ = pca(x) >>> e tensor([0.6240, 1.0342, 1.7350])