[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] Re: Data set/ Dimensional Reduction / PCA (Principal Component Analysis)




There are matrix math implementations in the MathLib quark.

There are some standard ways to calculate PCA:

https://people.cs.pitt.edu/~milos/courses/cs3750-Fall2007/lectures/PCA.pdf

involving covariance matrix, eigenvalues and what not.  I did this once (but not in sc)
There is a .cov(ariance) method on Matrix in MathLib

If this makes your head hurt then try porting a full solution from some other language:

https://github.com/mljs/pca/blob/master/src/pca.js

Hope that helps or gets you started.

- felix



On Thu, Dec 21, 2017 at 11:07 PM, <kewping@xxxxxxxxx> wrote:
Thank you for your reply.

I have a dataset (training set) of 286 (column) * 56 (row), meaning:
- 56 training example.
- Each training example have 286 data of different number

My code:

a = CSVFileReader.read("C:\\Users\\ID977\\Data_Coffee.csv",skipEmptyLines:
true).postcs;
b = a.collect { |row| row.collect { |s| s.asFloat } };
b.postcs;

(
Pbind(
        \instrument, \fmgrain1,
        \carrfreq, 10 * Pseq(b).trace / 4,
                \modfreq, Pkey(\carrfreq) / 5,
            \index, 2.5,
        \attack, 0.001,    // and fixed values as desired
        \decay, 0.2,       // for the other parameters
        \dur, 0.1
).trace.play
)

--> I need to generate a sequences of sound of 256.