Ejemplo n.º 1
0
 public IHDR()
 {
     this.samples = new Samples();
     this.testingSamples = new Samples();
     this.tree = new Tree();
     this.labelOutputVectors = new Dictionary<double, Vector>();
 }
Ejemplo n.º 2
0
        public void GetSamplesOfLabel_ReturnSamplesWithSpecificLabel()
        {
            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[] { 2, 3, 4 }, 2, 0));
            samples.Items.Add(new Sample(new double[] { 5, 6, 7 }, 2, 0));
            samples.Items.Add(new Sample(new double[] { 5, 6, 7 }, 3, 0));

            List<Sample> result = samples.GetSamplesOfLabel(1.0);

            Assert.AreEqual(result.Count, 2);
            Assert.AreEqual(result[0].Label, 1);
            Assert.AreEqual(result[1].Label, 1);
        }
Ejemplo n.º 3
0
        public void GetLabels_FunctionReturnCorrectLabels()
        {
            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[] { 2, 3, 4 }, 2, 0));
            samples.Items.Add(new Sample(new double[] { 5, 6, 7 }, 2, 0));
            samples.Items.Add(new Sample(new double[] { 5, 6, 7 }, 3, 0));

            List<double> result = samples.GetLabels();

            Assert.AreEqual(result.Count, 3);
            Assert.AreEqual(result[0], 1);
            Assert.AreEqual(result[1], 2);
            Assert.AreEqual(result[2], 3);
        }
Ejemplo n.º 4
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 })));
        }
Ejemplo n.º 5
0
        public void GetMeanOfDataWithLabel_ReturnCorrectMean()
        {
            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[] { 2, 3, 4 }, 2, 0));
            samples.Items.Add(new Sample(new double[] { 5, 6, 7 }, 2, 0));
            samples.Items.Add(new Sample(new double[] { 5, 6, 7 }, 3, 0));

            Vector result1 = samples.GetMeanOfDataWithLabel(1.0);

            Vector result2 = new Vector(new double[] { 1.5, 2.5, 3.5 });

            Assert.AreEqual(result1.Values[0], result1.Values[0]);
            Assert.AreEqual(result1.Values[1], result1.Values[1]);
            Assert.AreEqual(result1.Values[2], result1.Values[2]);
        }
Ejemplo n.º 6
0
 public void AddTestingSample(double[] sample, double label)
 {
     if (this.testingSamples == null)
     {
         this.testingSamples = new Samples();
     }
     this.testingSamples.AddSample(new Sample(sample, label, samples.Items.Count + 1));
 }
Ejemplo n.º 7
0
 public IHDR(SerializationInfo info, StreamingContext context)
 {
     samples = (Samples)info.GetValue("samples", typeof(Samples));
     tree = (Tree)info.GetValue("tree", typeof(Tree));
 }