private static double Evaluate(List<WordsearchImage> wordsearchImages, AlgorithmCombination algorithms)
        {
            DefaultLog.Info("Evaluating System Stages from Segmentation to Solver . . .");

            int numCorrect = 0;
            List<WordsearchSolutionEvaluator> evaluators = new List<WordsearchSolutionEvaluator>();

            foreach(WordsearchImage wordsearchImage in wordsearchImages)
            {
                //Register an interest in the Bitmap of the image
                wordsearchImage.RegisterInterestInBitmap();

                //Perform the evaluation (happens in a method from EvaluateFullSystem)
                WordsearchSolutionEvaluator evaluator = EvaluateFullSystem.EvaluateWordsearchBitmap(wordsearchImage.Bitmap,
                    wordsearchImage.Wordsearch.Words, wordsearchImage.Wordsearch.Solutions, algorithms);

                //Log Evaluation
                evaluators.Add(evaluator);

                DefaultLog.Info(evaluator.ToString());

                if (evaluator.Correct)
                {
                    numCorrect++;
                }

                //Clean up
                wordsearchImage.DeregisterInterestInBitmap();
            }

            DefaultLog.Info("System found all words correctly for {0} / {1} Wordsearch Images correctly", numCorrect, wordsearchImages.Count);

            //Calculate some extra statistics
            int numWordsearchesNoWordsFound = 0;
            double fMeasureSum = 0;
            int numValidFMeasures = 0;

            foreach (WordsearchSolutionEvaluator evaluator in evaluators)
            {
                //If no words were found correctly
                if (evaluator.TruePositive == 0)
                {
                    numWordsearchesNoWordsFound++;
                }

                //If there was a valid F-Measure
                if (!double.IsNaN(evaluator.FMeasure))
                {
                    fMeasureSum += evaluator.FMeasure;
                    numValidFMeasures++;
                }
            }

            DefaultLog.Info("In {0} wordsearches no words were found correctly at all", numWordsearchesNoWordsFound);
            DefaultLog.Info("Average F-Measure (when not NaN): {0}", fMeasureSum / numValidFMeasures);

            DefaultLog.Info("Segmentation to Solver Evaluation Completed");

            return (double)numCorrect / wordsearchImages.Count;
        }
Exemplo n.º 2
0
 internal static WordsearchSolutionEvaluator EvaluateWordsearchBitmap(Bitmap wordsearchBitmap, string[] wordsToFind,
     Dictionary<string, List<WordPosition>> correctSolutions, AlgorithmCombination algorithms)
 {
     return EvaluateWordsearchBitmap(wordsearchBitmap, wordsToFind, correctSolutions,
         algorithms.SegmentationAlgorithm, algorithms.SegmentationRemoveSmallRowsAndCols, 
         algorithms.SegmentationMethod, algorithms.ProbabilisticRotationCorrectionClassifier, 
         algorithms.Classifier, algorithms.WordsearchSolver);
 }
Exemplo n.º 3
0
 private static double Evaluate(List<Image> images, AlgorithmCombination algorithms)
 {
     return Evaluate(images, algorithms.DetectionSegmentationAlgorithm, algorithms.DetectionSegmentationRemoveSmallRowsAndCols,
         algorithms.SegmentationAlgorithm, algorithms.SegmentationRemoveSmallRowsAndCols,
         algorithms.SegmentationMethod, algorithms.ProbabilisticRotationCorrectionClassifier, algorithms.Classifier,
         algorithms.WordsearchSolver);
 }