
PCA projection (Geron Ch 8, morie.fn grpcap)
Source:R/geron_train_native.R
morie_geron_pca_projection.RdCentre, SVD, project on the first d right singular vectors; each component's sign is pinned so its largest-magnitude entry is positive, which makes the projection deterministic across BLAS builds.
Value
List with projection, components, explained_variance,
explained_variance_ratio, cumulative_ratio, singular_values,
mean.
Examples
set.seed(1)
X <- matrix(rnorm(60), 20, 3)
morie_geron_pca_projection(X, d = 2)
#> $projection
#> [,1] [,2]
#> [1,] -1.20311026 0.14697593
#> [2,] -0.64135876 0.60345441
#> [3,] -0.43153112 -0.68200222
#> [4,] 2.23152391 -0.53036199
#> [5,] -0.67984221 0.61927611
#> [6,] -1.07147782 -0.65265268
#> [7,] 0.39343239 0.07377909
#> [8,] 1.49156333 -0.74974222
#> [9,] 0.38416277 -0.06292519
#> [10,] -0.17822269 -0.08668523
#> [11,] 0.24740569 1.87193333
#> [12,] -0.20196965 0.12600241
#> [13,] -0.64650888 -0.27888789
#> [14,] -2.20507848 -1.56176383
#> [15,] 2.03530942 -0.47339198
#> [16,] 1.01763148 -0.60829051
#> [17,] -0.18183249 -0.38219753
#> [18,] -0.08436412 0.56858669
#> [19,] 0.02496970 1.20080648
#> [20,] -0.30070221 0.85808684
#>
#> $components
#> [,1] [,2] [,3]
#> [1,] 0.6565885 -0.5519002 0.51409893
#> [2,] 0.6779490 0.7305700 -0.08156353
#>
#> $explained_variance
#> [1] 1.1518689 0.6210151
#>
#> $explained_variance_ratio
#> [1] 0.5121781 0.2761341
#>
#> $cumulative_ratio
#> [1] 0.5121781 0.7883122
#>
#> $singular_values
#> [1] 4.678195 3.435009
#>
#> $mean
#> [1] 0.190523876 -0.006471519 0.138796773
#>
#> $estimate
#> [,1] [,2]
#> [1,] -1.20311026 0.14697593
#> [2,] -0.64135876 0.60345441
#> [3,] -0.43153112 -0.68200222
#> [4,] 2.23152391 -0.53036199
#> [5,] -0.67984221 0.61927611
#> [6,] -1.07147782 -0.65265268
#> [7,] 0.39343239 0.07377909
#> [8,] 1.49156333 -0.74974222
#> [9,] 0.38416277 -0.06292519
#> [10,] -0.17822269 -0.08668523
#> [11,] 0.24740569 1.87193333
#> [12,] -0.20196965 0.12600241
#> [13,] -0.64650888 -0.27888789
#> [14,] -2.20507848 -1.56176383
#> [15,] 2.03530942 -0.47339198
#> [16,] 1.01763148 -0.60829051
#> [17,] -0.18183249 -0.38219753
#> [18,] -0.08436412 0.56858669
#> [19,] 0.02496970 1.20080648
#> [20,] -0.30070221 0.85808684
#>
#> $n
#> [1] 20
#>