Exemplo n.º 1
0
            public void PrecisionTest()
            {
                var actual   = new Matrix(100, 1);
                var expected = new Matrix(100, 1);

                actual.InRandomize(0.25, 0.75);
                expected.InFill(1);

                var metric = new Precision();
                var e      = metric.Evaluate(actual, expected);

                var val = 0.0;
                var div = 0.0;

                for (var i = 0; i < actual.Rows; i++)
                {
                    for (var j = 0; j < actual.Columns; j++)
                    {
                        if (!(actual[i, j] >= 0.5))
                        {
                            continue;
                        }
                        div++;
                        if (Math.Abs(expected[i, j] - 1.0) < 0.1)
                        {
                            val++;
                        }
                    }
                }

                val /= div;

                Assert.IsTrue(Math.Abs(e - val) < 0.01, metric.Type().ToString() + " Evaluate.");

                // Precision 0-1 test
                new Precision().Evaluate(actual.Fill(0), actual.Fill(1));
            }