Accord.Tests.Statistics.KernelDiscriminantAnalysisTest.ThresholdTest C# (CSharp) Method

ThresholdTest() private method

private ThresholdTest ( ) : void
return void
        public void ThresholdTest()
        {
            double[,] inputs = 
            {
                { 1 },
                { 2 },
                { 3 },
            };

            int[] output = { 0, 1, 1 };

            IKernel kernel = new Gaussian(0.1);
            var target = new KernelDiscriminantAnalysis(inputs, output, kernel);

            bool thrown = false;
            try { target.Threshold = -1; }
            catch (ArgumentOutOfRangeException) { thrown = true; }
            Assert.IsTrue(thrown);

            thrown = false;
            try { target.Threshold = 1.1; }
            catch (ArgumentOutOfRangeException) { thrown = true; }
            Assert.IsTrue(thrown);

            target.Threshold = 1.0;

            target.Compute();

            Assert.AreEqual(2, target.Classes.Count);
            Assert.AreEqual(0, target.Classes[0].Number);
            Assert.AreEqual(1, target.Classes[0].Indices.Length);
            Assert.AreEqual(0, target.Classes[0].Indices[0]);
            Assert.AreEqual(1, target.Classes[1].Number);
            Assert.AreEqual(2, target.Classes[1].Indices.Length);
            Assert.AreEqual(1, target.Classes[1].Indices[0]);
            Assert.AreEqual(2, target.Classes[1].Indices[1]);
            Assert.AreEqual(0, target.CumulativeProportions.Length);
            Assert.AreEqual(0, target.DiscriminantMatrix.GetLength(0)); // dimension
            Assert.AreEqual(0, target.DiscriminantMatrix.GetLength(1)); // components kept
            Assert.AreEqual(0, target.DiscriminantProportions.Length);
            Assert.AreEqual(0, target.Discriminants.Count);
        }