Ejemplo n.º 1
0
        public void testOverlapPattern()
        {
            var classifier = new CLAClassifier <double>();

            ClassificationExperiment <Double> result = compute(classifier, 0, new int[] { 1, 5 }, 9, 9);

            result = compute(classifier, 1, new int[] { 1, 5 }, 9, 9);
            result = compute(classifier, 1, new int[] { 1, 5 }, 9, 9);
            result = compute(classifier, 2, new int[] { 3, 5 }, 2, 2);

            // Since overlap - should be previous with 100%
            checkValue(result, 9, 9.0, 1.0);

            result = compute(classifier, 3, new int[] { 3, 5 }, 2, 2);

            // Second example: now new value should be more probable than old
            Assert.IsTrue(result.getStat(1, 2) > result.getStat(1, 9));
        }
Ejemplo n.º 2
0
        public void TestSingleValue()
        {
            var classifier = new CLAClassifier <double>(new List <int> {
                0
            }, 0.001, 0.3);

            ClassificationExperiment <double> retVal = null;

            for (int recordNum = 0; recordNum < 10; recordNum++)
            {
                retVal = compute(classifier, recordNum, new int[] { 1, 5 }, 0, 10);
            }

            Assert.AreEqual(10.0, retVal.getActualValue(0), .00001);
            Assert.AreEqual(1.0, retVal.getStat(0, 0), .00001);
        }
Ejemplo n.º 3
0
        public void testComputeComplex()
        {
            var classifier = new CLAClassifier <double>(new List <int> {
                1
            }, 0.1, 0.1);
            int recordNum = 0;
            Dictionary <string, object> classification = new Dictionary <string, object>();

            classification.Add("bucketIdx", 4);
            classification.Add("actValue", 34.7);
            ClassificationExperiment <double> result = classifier.Compute(recordNum, classification, new int[] { 1, 5, 9 }, true, true);

            recordNum += 1;

            classification["bucketIdx"] = 5;
            classification["actValue"]  = 41.7;
            result     = classifier.Compute(recordNum, classification, new int[] { 0, 6, 9, 11 }, true, true);
            recordNum += 1;


            classification["bucketIdx"] = 5;
            classification["actValue"]  = 44.9;
            result     = classifier.Compute(recordNum, classification, new int[] { 6, 9 }, true, true);
            recordNum += 1;


            classification["bucketIdx"] = 4;
            classification["actValue"]  = 42.9;
            result     = classifier.Compute(recordNum, classification, new int[] { 1, 5, 9 }, true, true);
            recordNum += 1;


            classification["bucketIdx"] = 4;
            classification["actValue"]  = 34.7;
            result = classifier.Compute(recordNum, classification, new int[] { 1, 5, 9 }, true, true);



            Assert.AreEqual(35.520000457763672, result.getActualValue(4), 0.00001);
            Assert.AreEqual(42.020000457763672, result.getActualValue(5), 0.00001);
            Assert.AreEqual(6, result.getStatCount(1));
            Assert.AreEqual(0.0, result.getStat(1, 0), 0.00001);
            Assert.AreEqual(0.0, result.getStat(1, 1), 0.00001);
            Assert.AreEqual(0.0, result.getStat(1, 2), 0.00001);
            Assert.AreEqual(0.0, result.getStat(1, 3), 0.00001);
            Assert.AreEqual(0.12300123, result.getStat(1, 4), 0.00001);
            Assert.AreEqual(0.87699877, result.getStat(1, 5), 0.00001);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// general method for checking expected probability and value
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="retVal">Result of compute method</param>
 /// <param name="index">value of particular bucket index</param>
 /// <param name="value">expected value</param>
 /// <param name="probability">expected probability</param>
 public void checkValue <T>(ClassificationExperiment <T> retVal, int index, Object value, double probability)
 {
     Assert.AreEqual(retVal.getActualValue(index), value);
     Assert.AreEqual(probability, retVal.getStat(1, index), 0.01);
 }