public void AddFeatureOverflowTest()
        {
            Feature     testFeature     = new DoubleFeature(new AbsoluteDistance(), 4.0);
            Feature     testFeature2    = new DoubleFeature(new AbsoluteDistance(), 3.0);
            Observation testObservation = new Observation(1);

            testObservation.AddFeature(testFeature);
            testObservation.AddFeature(testFeature2);
        }
Exemplo n.º 2
0
        public void ReCalculateCentroidTest()
        {
            // not really testable code ####consider redefining ReCalculate centroid
            Cluster testCluster = new Cluster();

            Feature testFeature  = new DoubleFeature(new AbsoluteDistance(), 4.0);
            Feature testFeature1 = new DoubleFeature(new AbsoluteDistance(), 5.0);
            Feature testFeature2 = new DoubleFeature(new AbsoluteDistance(), 15.0);
            Feature testFeature3 = new DoubleFeature(new AbsoluteDistance(), 25.0);
            Feature testFeature4 = new DoubleFeature(new AbsoluteDistance(), 7.0);
            Feature testFeature5 = new DoubleFeature(new AbsoluteDistance(), 8.0);
            Feature testFeature6 = new DoubleFeature(new AbsoluteDistance(), 8.0);
            Feature testFeature7 = new DoubleFeature(new AbsoluteDistance(), 10.0);

            Observation testObservation  = new Observation(2);
            Observation testObservation1 = new Observation(2);
            Observation testObservation2 = new Observation(2);

            Observation initialCentroid = new Observation(2);

            initialCentroid.AddFeature(testFeature);
            initialCentroid.AddFeature(testFeature1);
            testCluster.ClusterCentroid = initialCentroid;

            testObservation.AddFeature(testFeature2);
            testObservation.AddFeature(testFeature3);
            testCluster.AddMember(testObservation);

            testObservation1.AddFeature(testFeature4);
            testObservation1.AddFeature(testFeature5);
            testCluster.AddMember(testObservation1);

            testObservation2.AddFeature(testFeature6);
            testObservation2.AddFeature(testFeature7);
            testCluster.AddMember(testObservation2);



            //act
            testCluster.ReCalculateCentroid();

            //assert
            Assert.AreEqual(10.0, testCluster.ClusterCentroid.GetFeature(0).FeatureValue);
            Assert.AreSame(initialCentroid, testCluster.OldClusterCentroid);
        }
        public void AddFeatureTest()
        {
            Feature testingFeature = new DoubleFeature(new AbsoluteDistance(), 2.0);

            Observation testingObs = new Observation(1);

            testingObs.AddFeature(testingFeature);

            Assert.AreEqual(testingObs.FeaturesCount, 1);
        }
        public void ReplaceFeatureTest()
        {
            Feature     testingFeature = new DoubleFeature(new AbsoluteDistance(), 2.0);
            Feature     replacement    = new DoubleFeature(new AbsoluteDistance(), 6.0);
            Observation testingObs     = new Observation(1);

            testingObs.AddFeature(testingFeature);
            testingObs.ReplaceFeature(0, replacement);

            Assert.AreSame(replacement, testingObs.GetFeature(0));
            Assert.AreEqual(6.0, testingObs.GetFeature(0).FeatureValue);
        }
        public void GetFeatureTest()
        {
            Feature testingFeature = new DoubleFeature(new AbsoluteDistance(), 2.0);

            Observation testingObs = new Observation(1);

            testingObs.AddFeature(testingFeature);

            Feature returned = testingObs.GetFeature(0);

            Assert.AreSame(returned, testingFeature);
        }
Exemplo n.º 6
0
        public void AddMemberTest()
        {
            Cluster testCluster = new Cluster();

            Feature     testFeature     = new DoubleFeature(new AbsoluteDistance(), 4.0);
            Observation testObservation = new Observation(3);

            testObservation.AddFeature(testFeature);

            //act
            testCluster.AddMember(testObservation);

            //assert
            Assert.AreEqual(testCluster.ClusterCount, 1);
        }