Пример #1
0
        /// <summary>
        ///     Deserialize the ROC curve from the specified file name.
        /// </summary>
        /// <param name="fileName">
        ///     The file name where the ROC curve is serialized.
        /// </param>
        /// <param name="xLabel">
        ///     The label of horizontal axis in the ROC curve.
        /// </param>
        /// <param name="yLabel">
        ///     The label of vertical axis in the ROC curve.
        /// </param>
        /// <param name="matcherName">
        ///     The name of the fingerprint matcher.
        /// </param>
        /// <returns>
        ///     The points composing the ROC curve.
        /// </returns>
        public static List <ROCPoint> Deserialize(string fileName, out string xLabel, out string yLabel, out string matcherName)
        {
            var roc = new List <ROCPoint>();

            using (var sr = new StreamReader(fileName))
            {
                matcherName = sr.ReadLine();
                var line             = sr.ReadLine();
                var splitStringArray = new string[1] {
                    ";"
                };
                var members = line.Split(splitStringArray, StringSplitOptions.None);
                xLabel = members[0];
                yLabel = members[1];

                // Read lines from the file until the end of the file is reached.
                while ((line = sr.ReadLine()) != null)
                {
                    members = line.Split(splitStringArray, StringSplitOptions.None);
                    var rocPoint = new ROCPoint(Convert.ToDouble(members[0]), Convert.ToDouble(members[1]), Convert.ToDouble(members[2]));
                    roc.Add(rocPoint);
                }
                sr.Close();
            }
            return(roc);
        }
Пример #2
0
        private List <ROCPoint> BuildROC(IList <MatchingResult> sortedResults, int negativeCount, int positiveCount)
        {
            int    fp     = 0;
            int    tp     = 0;
            var    curve  = new List <ROCPoint>();
            double latter = double.MinValue;

            for (int i = 0; i < sortedResults.Count; i++)
            {
                MatchingResult mr = sortedResults[i];
                if (mr.ComparissonValue != latter)
                {
                    ROCPoint rocPoint = new ROCPoint(100.0 * fp / negativeCount, 100.0 * tp / positiveCount, mr.ComparissonValue);
                    if (curve.Count > 1)
                    {
                        if (curve[curve.Count - 2].x == rocPoint.x)
                        {
                            curve[curve.Count - 1] = rocPoint;
                        }
                        else
                        if (curve[curve.Count - 2].y == rocPoint.y)
                        {
                            curve[curve.Count - 1] = rocPoint;
                        }
                        else
                        {
                            curve.Add(rocPoint);
                        }
                    }
                    else
                    {
                        curve.Add(rocPoint);
                    }
                    latter = mr.ComparissonValue;
                }
                if (mr.Type == MatchingType.Positive)
                {
                    tp++;
                }
                else
                {
                    fp++;
                }
            }
            curve.Add(new ROCPoint(100, curve[curve.Count - 1].y, curve[curve.Count - 1].matchingValue));
            curve.Add(new ROCPoint(100, 100, curve[curve.Count - 1].matchingValue));

            return(curve);
        }