Example #1
0
        public void Test()
        {
            int testSize = 10;

            for (int i = 0; i < testSize; i++)
            {
                int      index      = _rnd.Next(_dataMgr.count - 1);
                double[] testInput  = _dataMgr.GetInputData(index);
                double   testOutput = _dataMgr.GetLabelData(index);

                double predictOuput = _regressionMachine.Predict(testInput);

                Console.WriteLine("Test Index:" + index + ", Expected:" + testOutput + " Predict:" + predictOuput);
            }

            double mse = 0.0;

            for (int i = 0; i < _output.Length; i++)
            {
                double[] testInput    = _dataMgr.GetInputData(i);
                double   testOutput   = _dataMgr.GetLabelData(i);
                double   predictOuput = _regressionMachine.Predict(testInput);

                mse += (testOutput - predictOuput) * (testOutput - predictOuput);
            }

            mse = Math.Sqrt(mse) / _output.Length;

            Console.WriteLine("MSE:" + mse);
        }
Example #2
0
        public void Test()
        {
            double mse = 0.0;

            for (int i = 0; i < testInput.Length; i++)
            {
                double predictOuput = _regressionMachine.Predict(testInput[i]);

                Console.WriteLine(testOutput[i] - predictOuput);
                mse += (testOutput[i] - predictOuput) * (testOutput[i] - predictOuput);
            }

            mse = Math.Sqrt(mse) / testInput.Length;

            Console.WriteLine("MSE:" + mse);
        }
Example #3
0
        public void Test()
        {
            double[][] testDataX    = new double[_testDataSize][];
            double[]   testDataY    = new double[_testDataSize];
            double[]   testDataRefY = new double[_testDataSize];

            for (int i = 0; i < _testDataSize; i++)
            {
                testDataX[i]    = new double[1];
                testDataX[i][0] = -1.0 + (double)((2 * i)) / (double)(_testDataSize);
            }

            testDataY    = _dataGnr.Calc(testDataX);
            testDataRefY = _regressionMachine.Predict(testDataX);

            DataAnalyzer analyzer = new DataAnalyzer();

            double[] err = analyzer.GetDifference(testDataY, testDataRefY);

            double mean     = analyzer.Mean(err);
            double variance = analyzer.Variance(err);

            Console.WriteLine("testDataX:");
            for (int i = 0; i < testDataX.Length; i++)
            {
                Console.Write(testDataX[i][0] + ",");
            }
            Console.Write("\n");
            Console.Write("\n");

            Console.WriteLine("testDataY:");
            for (int i = 0; i < testDataY.Length; i++)
            {
                Console.Write(testDataY[i] + ",");
            }
            Console.Write("\n");
            Console.Write("\n");

            Console.WriteLine("testDataRefY:");
            for (int i = 0; i < testDataRefY.Length; i++)
            {
                Console.Write(testDataRefY[i] + ",");
            }
            Console.Write("\n");
            Console.Write("\n");

            Console.WriteLine("testDataError:");
            for (int i = 0; i < err.Length; i++)
            {
                Console.Write(err[i] + ",");
            }
            Console.Write("\n");
            Console.Write("\n");

            Console.WriteLine("Mean: " + mean);
            Console.WriteLine("Variance: " + variance);
        }
Example #4
0
 public double RespondQuery()
 {
     return(_machine.Predict(_pos));
 }