Transpose.
authorTom Clegg <tom@tomclegg.ca>
Thu, 17 Sep 2020 16:41:20 +0000 (12:41 -0400)
committerTom Clegg <tom@tomclegg.ca>
Thu, 17 Sep 2020 16:41:20 +0000 (12:41 -0400)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@tomclegg.ca>

pca.go

diff --git a/pca.go b/pca.go
index 4b60327e84e7e2c108204989f54223db5f4f8914..2bb8471d1b21112bd29ae7e166ec4ddd5f125732 100644 (file)
--- a/pca.go
+++ b/pca.go
@@ -151,11 +151,12 @@ func (cmd *goPCA) RunCommand(prog string, args []string, stdin io.Reader, stdout
        if *onehot {
                data, cols = recodeOnehot(data, cols)
        }
-       pca, err := nlp.NewPCA(*components).FitTransform(array2matrix(rows, cols, data))
+       pca, err := nlp.NewPCA(*components).FitTransform(array2matrix(rows, cols, data).T())
        if err != nil {
                return 1
        }
 
+       pca = pca.T()
        rows, cols = pca.Dims()
        out := make([]float64, rows*cols)
        for i := 0; i < rows; i++ {