예제 #1
0
        private static BiometricResult Evaluate(ClassifierInstance classifier, List <ISample> testingSamples, double minInterval, double interval, BiometricResult result)
        {
            if (interval < minInterval)
            {
                // the threshold found for the smallest interval represents the best guess at the EER
                return(result);
            }
            else
            {
                // recurse until the smallest allowable interval is hit
                ErrorRatePair delta1 = CalculateErrorRate(classifier, testingSamples, (result.GetThreshold() - (interval / 2.0)));
                ErrorRatePair delta2 = CalculateErrorRate(classifier, testingSamples, (result.GetThreshold() + (interval / 2.0)));

                Console.WriteLine("delta1 : " + delta1.GetFAR() + " " + delta1.GetFRR() + " \n " + delta2.GetFAR() + " " + delta2.GetFRR());
                Console.WriteLine("threshold: " + result.GetThreshold());
                Console.WriteLine("errorDelta1: " + delta1.GetErrorDelta() + " errorDelta2: " + delta2.GetErrorDelta());

                if (delta1.GetErrorDelta() < delta2.GetErrorDelta())
                {
                    Console.WriteLine("Choose delta1");
                    return(Evaluate(classifier, testingSamples, minInterval, (interval / 2.0), new BiometricResult((result.GetThreshold() - (interval / 2.0)), new List <ErrorRatePair> {
                        delta1
                    })));
                }
                else
                {
                    Console.WriteLine("Choose delta2");
                    return(Evaluate(classifier, testingSamples, minInterval, (interval / 2.0), new BiometricResult((result.GetThreshold() + (interval / 2.0)), new List <ErrorRatePair> {
                        delta2
                    })));
                }
            }
        }
예제 #2
0
        private static Tuple <ErrorRatePair, List <ErrorRatePair> > CalculateErrorRate <T>(SampleSet <T> sampleSet, ClassifierFactory <T> classifier, int trainingSize, double threshold, int xValidationStart, int xValidationLength) where T : ISample
        {
            // test classifier instances with testing samples and threshold asynchronously to get cross validated result
            List <ErrorRatePair> errorRates = Enumerable.Range(xValidationStart, xValidationLength).AsParallel()
                                              .Select(x => CalculateErrorRate(classifier.GetInstance(x), SampleSetHelpers.GetSampleSetTestingSamples(sampleSet, trainingSize, x), threshold))
                                              .ToList();

            ErrorRatePair totalError = errorRates[0];

            for (int i = 1; i < errorRates.Count; i++)
            {
                totalError = totalError + errorRates[i];
            }
            return(new Tuple <ErrorRatePair, List <ErrorRatePair> >(totalError, errorRates));
        }