framework icon indicating copy to clipboard operation
framework copied to clipboard

Add an example for PCA

Open WowItsDoge opened this issue 8 years ago • 1 comments

What would you like to submit? (put an 'x' inside the bracket that applies)

  • [ ] question
  • [ ] bug report
  • [x] feature request

Issue description

Can you provide an example for a Principal Component Analysis? Like reducing datasets with 10 dimensions to 2 dimensions (for visualizing and clustering).

I found this posting on stackoverflow, but it is confusing.

Thank you in advance!

WowItsDoge avatar Jul 14 '18 15:07 WowItsDoge

Like is this an valid example, to reduce 10 datasets with 3 dimensions to 2 dimensions?

double[][] data =
{
    new double[] { 2.5,  2.4, 1.0 },
    new double[] { 0.5,  0.7, 0.0 },
    new double[] { 2.2,  2.9, 1.0 },
    new double[] { 1.9,  2.2, 0.0 },
    new double[] { 3.1,  3.0, 1.0 },
    new double[] { 2.3,  2.7, 0.5 },
    new double[] { 2.0,  1.6, 1.0 },
    new double[] { 1.0,  1.1, 0.5 },
    new double[] { 1.5,  1.6, 1.0 },
    new double[] { 1.1,  0.9, 0.0 }
};
var pcaTool = new KernelPrincipalComponentAnalysis();
pcaTool.Learn(data);
pcaTool.NumberOfOutputs = 2;
var outputMatrix = pcaTool.Transform(data);

outputMatrix[10][2]

-0,904877747083884, -0,208657108793525 1,87348512247059, 0,143821076246587 -1,06057837276037, -0,012675004828758 -0,106084053022853, 0,661870339582841 -1,72300919638498, -0,00265300430351045 -0,853623522976191, 0,373059691388326 -0,0113141579603298, -0,492446254447201 1,13078199854883, -0,18540159358537 0,317483080836186, -0,477251243891104 1,33773684833301, 0,200333102631714

WowItsDoge avatar Jul 15 '18 19:07 WowItsDoge