コード例 #1
0
        public void CountOutputsFromClassLabels_CountCorrectOutputs()
        {
            Params.inputDataDimension = 3;

            Samples samples = new Samples();

            samples.Items.Add(new Sample(new double[] { 1, 2, 3 }, 1, 0));
            samples.Items.Add(new Sample(new double[] { 2, 3, 4 }, 1, 0));
            samples.Items.Add(new Sample(new double[] { 1, 2, 3 }, 2, 0));
            samples.Items.Add(new Sample(new double[] { 3, 4, 5 }, 2, 0));
            samples.Items.Add(new Sample(new double[] { 5, 6, 7 }, 2, 0));
            samples.Items.Add(new Sample(new double[] { 6, 3, 7 }, 3, 0));

            samples.CountOutputsFromClassLabels();
            Assert.IsTrue(samples.Items[1].Y.EqualsToVector(new Vector(new double[] { 1.5, 2.5, 3.5 })));
            Assert.IsTrue(samples.Items[2].Y.EqualsToVector(new Vector(new double[] { 3.0, 4.0, 5.0 })));
            Assert.IsTrue(samples.Items[3].Y.EqualsToVector(new Vector(new double[] { 3.0, 4.0, 5.0 })));
            Assert.IsTrue(samples.Items[4].Y.EqualsToVector(new Vector(new double[] { 3.0, 4.0, 5.0 })));
            Assert.IsTrue(samples.Items[5].Y.EqualsToVector(new Vector(new double[] { 6.0, 3.0, 7.0 })));
        }