Search code examples
lsa

How to calculate LSA Word score as seen in "LSA Intro AI Seminar"


If you check http://www.cs.nmsu.edu/~mmartin/LSA_Intro_AI_Seminar.ppt they show the calculated score for each word on Slide 25.

I have not been able to find how to calculate this summary.

Recently, I have completed a LSA implementation and can produce all the other results in this PPT, but not Slive 25.

The reason why I ask this is because I would like to use this to indicate the 'top reasons' why a document scored high.


Solution

  • Ok; I've decided to write the author of the powerpoint (Dr. Melanie J Martin) and she pointed out page 406 of the Deerwester et al paper she based it on; the "X hat" section.

    To test it, I've written out the example to see if I could get the same values, and it worked :)

    Test code:

    static void XHatTest()
    {
        double[,] testT = new double[12, 2], testD = new double[2, 9], testS = new double[2, 2];
        testT[0, 0] = 0.22;
        testT[0, 1] = -0.11;
        testT[1, 0] = 0.20;
        testT[1, 1] = -0.07;
        testT[2, 0] = 0.24;
        testT[2, 1] = 0.04;
        testT[3, 0] = 0.40;
        testT[3, 1] = 0.06;
        testT[4, 0] = 0.64;
        testT[4, 1] = -0.17;
        testT[5, 0] = 0.27;
        testT[5, 1] = 0.11;
        testT[6, 0] = 0.27;
        testT[6, 1] = 0.11;
        testT[7, 0] = 0.30;
        testT[7, 1] = -0.14;
        testT[8, 0] = 0.21;
        testT[8, 1] = 0.27;
        testT[9, 0] = 0.01;
        testT[9, 1] = 0.49;
        testT[10, 0] = 0.04;
        testT[10, 1] = 0.62;
        testT[11, 0] = 0.03;
        testT[11, 1] = 0.45;
    
        testD[0, 0] = 0.20;
        testD[0, 1] = 0.61;
        testD[0, 2] = 0.46;
        testD[0, 3] = 0.54;
        testD[0, 4] = 0.28;
        testD[0, 5] = 0.00;
        testD[0, 6] = 0.02;
        testD[0, 7] = 0.02;
        testD[0, 8] = 0.08;
        testD[1, 0] = -0.06;
        testD[1, 1] = 0.17;
        testD[1, 2] = -0.13;
        testD[1, 3] = -0.23;
        testD[1, 4] = 0.11;
        testD[1, 5] = 0.19;
        testD[1, 6] = 0.44;
        testD[1, 7] = 0.62;
        testD[1, 8] = 0.53;
    
        testS[0, 0] = 3.34;
        testS[0, 1] = 0;
        testS[1, 0] = 0;
        testS[1, 1] = 2.54;
    
        Matrix A = new Matrix(testT), B = new Matrix(testD), C = new Matrix(testS);
        Matrix Result = A * C * B;
        for (int row = 0; row < Result.NoRows; row++)
        {
            for (int col = 0; col < Result.NoCols; col++)
            {
                Console.Write(Math.Round(Result[row, col], 2) + " ");
            }
            Console.WriteLine();
        }
    }