// Path: src/main/java/com/tom_e_white/set_game/predict/PredictCardFeaturesOnTestData.java
// public class PredictCardFeaturesOnTestData {
// 
//     public static double[] predict(File testFile) throws IOException, ParseException {
//         return predict(testFile, 1);
//     }
// 
//     public static double[] predict(File testFile, int version) throws IOException, ParseException {
// 
//         FeatureFinder[] finders = new FeatureFinder[] {
//                 new FindCardNumberFeatures(),
//                 new FindCardColourFeatures(version),
//                 new FindCardShadingFeatures(),
//                 new FindCardShapeFeatures()
//         };
//         double[] accuracies = new double[finders.length];
//         int index = 0;
//         for (FeatureFinder finder : finders) {
//             System.out.println(finder.getClass().getSimpleName());
// 
//             Classifier<double[]> classifier = finder.getClassifier();
// 
//             CardDetector cardDetector = new CardDetector();
//             List<CardImage> images = cardDetector.detect(testFile.getAbsolutePath(), false);
//             List<String> testDescriptions = Files.lines(Paths.get(testFile.getAbsolutePath().replace(".jpg", ".txt"))).collect(Collectors.toList());
// 
//             int correct = 0;
//             int total = 0;
//             for (int i = 0; i < testDescriptions.size(); i++) {
//                 double[] features = finder.find(images.get(i).getImage(), false);
//                 int predictedLabel = classifier.predict(features);
//                 int actualLabel = finder.getLabelFromDescription(testDescriptions.get(i));
//                 if (predictedLabel == actualLabel) {
//                     correct++;
//                 } else {
//                     System.out.println("Incorrect, predicted " + predictedLabel + " but was " + actualLabel + " for card " + (i + 1));
//                 }
//                 total++;
//             }
//             System.out.println("Correct: " + correct);
//             System.out.println("Total: " + total);
//             double accuracy = ((double) correct)/total * 100;
//             accuracies[index++] = accuracy;
//             System.out.println("Accuracy: " + ((int) accuracy) + " percent");
//             System.out.println("------------------------------------------");
//         }
//         return accuracies;
//     }
// 
//     public static void main(String[] args) throws Exception {
//         int version = args.length > 1 ? Integer.parseInt(args[1]) : 1;
//         predict(new File(args[0]), version);
// 
//     }
// }


import com.tom_e_white.set_game.predict.PredictCardFeaturesOnTestData;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import static org.junit.Assert.assertArrayEquals;
package com.tom_e_white.set_game.predict;




public class PredictCardFeaturesOnTestDataTest {
    @Test
    public void testV1() throws IOException, ParseException {
// Path: src/main/java/com/tom_e_white/set_game/predict/PredictCardFeaturesOnTestData.java
// public class PredictCardFeaturesOnTestData {
// 
//     public static double[] predict(File testFile) throws IOException, ParseException {
//         return predict(testFile, 1);
//     }
// 
//     public static double[] predict(File testFile, int version) throws IOException, ParseException {
// 
//         FeatureFinder[] finders = new FeatureFinder[] {
//                 new FindCardNumberFeatures(),
//                 new FindCardColourFeatures(version),
//                 new FindCardShadingFeatures(),
//                 new FindCardShapeFeatures()
//         };
//         double[] accuracies = new double[finders.length];
//         int index = 0;
//         for (FeatureFinder finder : finders) {
//             System.out.println(finder.getClass().getSimpleName());
// 
//             Classifier<double[]> classifier = finder.getClassifier();
// 
//             CardDetector cardDetector = new CardDetector();
//             List<CardImage> images = cardDetector.detect(testFile.getAbsolutePath(), false);
//             List<String> testDescriptions = Files.lines(Paths.get(testFile.getAbsolutePath().replace(".jpg", ".txt"))).collect(Collectors.toList());
// 
//             int correct = 0;
//             int total = 0;
//             for (int i = 0; i < testDescriptions.size(); i++) {
//                 double[] features = finder.find(images.get(i).getImage(), false);
//                 int predictedLabel = classifier.predict(features);
//                 int actualLabel = finder.getLabelFromDescription(testDescriptions.get(i));
//                 if (predictedLabel == actualLabel) {
//                     correct++;
//                 } else {
//                     System.out.println("Incorrect, predicted " + predictedLabel + " but was " + actualLabel + " for card " + (i + 1));
//                 }
//                 total++;
//             }
//             System.out.println("Correct: " + correct);
//             System.out.println("Total: " + total);
//             double accuracy = ((double) correct)/total * 100;
//             accuracies[index++] = accuracy;
//             System.out.println("Accuracy: " + ((int) accuracy) + " percent");
//             System.out.println("------------------------------------------");
//         }
//         return accuracies;
//     }
// 
//     public static void main(String[] args) throws Exception {
//         int version = args.length > 1 ? Integer.parseInt(args[1]) : 1;
//         predict(new File(args[0]), version);
// 
//     }
// }


// Path: src/test/java/com/tom_e_white/set_game/predict/PredictCardFeaturesOnTestDataTest.java
import com.tom_e_white.set_game.predict.PredictCardFeaturesOnTestData;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import static org.junit.Assert.assertArrayEquals;

package com.tom_e_white.set_game.predict;




public class PredictCardFeaturesOnTestDataTest {
    @Test
    public void testV1() throws IOException, ParseException {
        double[] accuracies = PredictCardFeaturesOnTestData.predict(new File("data/20170106_205743.jpg"));