示例#1
0
        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);
            }
        }
示例#2
0
 /// <summary>
 /// TrainMore, but with a single example
 /// </summary>
 public static void TrainMore(this IOnlineClassifier classifier, Example labeledExample)
 {
     classifier.TrainMore(labeledExample.NCopies(1));
 }