protected void trainModel(InstanceStream trainStream, AbstractClassifier model) {
        ClassificationPerformanceEvaluator evaluator = new BasicClassificationPerformanceEvaluator();
        evaluator.reset();
        long instancesProcessed = 0;
        System.out.println("Started learning the model...");
        while (trainStream.hasMoreInstances()
                && ((MaxInstances < 0) || (instancesProcessed < MaxInstances))) {
            model.trainOnInstance(trainStream.nextInstance());
            instancesProcessed++;
            if (instancesProcessed % INSTANCES_BETWEEN_MONITOR_UPDATES == 0) {
                long estimatedRemainingInstances = trainStream
                        .estimatedRemainingInstances();
                if (MaxInstances > 0) {
                    long maxRemaining = MaxInstances - instancesProcessed;
                    if ((estimatedRemainingInstances < 0)
                            || (maxRemaining < estimatedRemainingInstances)) {
                        estimatedRemainingInstances = maxRemaining;
                    }
                }
            }
        }
    }