public static void TestOnlineTraining(this IOnlineClassifier c)
        {
            // train on an initial set of random examples
            c.Train(GetExamples(10));

            // now try a new set with no correlation to the previous one
            var examples = GetExamples();
            var test = examples.SubView(0, (.1 * examples.Count).Rounded());
            var train = examples.SubView(test.Count, examples.Count - test.Count);
            c.TrainMore(train);

            // accuracy test
            double minAccuracy = 0.6;
            if (c.AccuracyOn(train) < minAccuracy)
                throw new Exception("Training accuracy < " + minAccuracy);
            if (c.AccuracyOn(test) < minAccuracy)
                throw new Exception("Test accuray < " + minAccuracy);
        }
        public static void TestTraining(this IClassifier c)
        {
            if (c.IsTrained)
                throw new Exception("Already trained");

            // IsTrained test
            var examples = GetExamples();
            var test = examples.SubView(0, (.1 * examples.Count).Rounded());
            var train = examples.SubView(test.Count, examples.Count - test.Count);
            c.Train(train);
            if (!c.IsTrained)
                throw new Exception("Classifier is trained");

            // accuracy test
            double minAccuracy = 0.6;
            if (c.AccuracyOn(train) < minAccuracy && !(c.GetType() == typeof(DecisionStump) && c.AccuracyOn(train) > 0.5))
                throw new Exception("Training accuracy < " + minAccuracy);
            if (c.AccuracyOn(test) < minAccuracy && c.GetType() != typeof(DecisionStump))
                throw new Exception("Test accuray < " + minAccuracy);
        }
 /// <summary>
 /// Computes the classifier's error in predicting the set of examples
 /// </summary>
 public static double ErrorOn(this IClassifier classifier, IEnumerable<Example> labeledExamples)
 {
     return 1.0 - classifier.AccuracyOn(labeledExamples);
 }