示例#1
0
 public static OptimizationResult GetOptimalFeatures <T, C>(int bestNFeatures, SampleSet <T> sampleSet, C classifier, int trainingSize, int xValidationStart = 0, int xValidationLength = 1, double minInterval = Evaluator.DEFAULT_MIN_INTERVAL)
     where T : ISample
     where C : ClassifierFactory <T>
 {
     return(GetOptimalFeatures <T>(bestNFeatures, sampleSet, (reducedSet, index) => {
         BiometricResult res = Evaluator.Evaluate(reducedSet, classifier.Train(reducedSet, trainingSize), trainingSize, xValidationStart, xValidationLength, minInterval);
         return new Tuple <int, double>(index, res.GetERR());
     }));
 }
示例#2
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
                    })));
                }
            }
        }
示例#3
0
        private static BiometricResult Evaluate <T>(SampleSet <T> sampleSet, ClassifierFactory <T> classifier, int trainingSize, double minInterval, double interval, BiometricResult result, int xValidationStart, int xValidationLength) where T : ISample
        {
            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 found
                Tuple <ErrorRatePair, List <ErrorRatePair> > delta1 = CalculateErrorRate(sampleSet, classifier, trainingSize, (result.GetThreshold() - (interval / 2.0)), xValidationStart, xValidationLength);
                Tuple <ErrorRatePair, List <ErrorRatePair> > delta2 = CalculateErrorRate(sampleSet, classifier, trainingSize, (result.GetThreshold() + (interval / 2.0)), xValidationStart, xValidationLength);

                if (delta1.Item1.GetErrorDelta() < delta2.Item1.GetErrorDelta())
                {
                    return(Evaluate(sampleSet, classifier, trainingSize, minInterval, (interval / 2.0), new BiometricResult((result.GetThreshold() - (interval / 2.0)), delta1.Item2), xValidationStart, xValidationLength));
                }
                else
                {
                    return(Evaluate(sampleSet, classifier, trainingSize, minInterval, (interval / 2.0), new BiometricResult((result.GetThreshold() + (interval / 2.0)), delta2.Item2), xValidationStart, xValidationLength));
                }
            }
        }