Exemplo n.º 1
0
        private void LoadMatrixValidTest()
        {
            validY = MatrixCal.MatrixCreate(nVal, 1);

            for (int i = 0; i < nVal; i++)
            {
                validA[i]    = new double[nFeature + 1];
                validA[i][0] = 1;
                for (int j = 0; j < 8; j++)
                {
                    validA[i][j + 1] = validData[i][j];
                }
                validY[i][0] = validData[i][8];
            }

            testY = MatrixCal.MatrixCreate(nTest, 1);

            for (int i = 0; i < nTest; i++)
            {
                testA[i]    = new double[nFeature + 1];
                testA[i][0] = 1;
                for (int j = 0; j < 8; j++)
                {
                    testA[i][j + 1] = testData[i][j];
                }
                testY[i][0] = testData[i][8];
            }
        }
Exemplo n.º 2
0
        private void CalculateMatrixTrain()
        {
            trainY = MatrixCal.MatrixCreate(nTrain, 1);

            for (int i = 0; i < nTrain; i++)
            {
                trainA[i]    = new double[nFeature + 1];
                trainA[i][0] = 1;
                for (int j = 0; j < 8; j++)
                {
                    trainA[i][j + 1] = trainData[i][j];
                }
                trainY[i][0] = trainData[i][8];
            }

            trainAT  = MatrixCal.MatrixTranspose(trainA);
            trainATA = MatrixCal.MatrixProduct(trainAT, trainA);
        }
Exemplo n.º 3
0
        private void CalculateResult()
        {
            CalculateRidgeRegression(lamdaVal[nMinIndex]);
            testY            = MatrixCal.MatrixCreate(nTest, 1);
            labelResult.Text = "";

            for (int i = 0; i < nTest; i++)
            {
                double[][] testAi = new double[1][];
                testAi[0] = new double[nFeature + 1];
                for (int j = 0; j < nFeature + 1; j++)
                {
                    testAi[0][j] = testA[i][j];
                }

                double[][] testAiw = MatrixCal.MatrixProduct(testAi, matrixWeight);
                testY[i][0]       = testAiw[0][0];
                labelResult.Text += testY[i][0].ToString() + "\n";
            }
        }