コード例 #1
0
        /// <summary>
        ///   Computes a ROC curve with the given increment points
        /// </summary>
        ///
        public void Compute(params double[] cutpoints)
        {
            if (cutpoints.Length == 0)
            {
                throw new ArgumentException(
                          "Cutpoints array must have at least one value.", "cutpoints");
            }

            List <ReceiverOperatingCharacteristicPoint> points = new List <ReceiverOperatingCharacteristicPoint>();

            // Create the curve, computing a point for each cut-point
            for (int i = 0; i < cutpoints.Length; i++)
            {
                points.Add(ComputePoint(cutpoints[i]));
            }


            // Sort the curve by descending specificity
            points.Sort(new Comparison <ReceiverOperatingCharacteristicPoint>(order));


            // Create the point collection
            this.collection = new ReceiverOperatingCharacteristicPointCollection(points.ToArray());

            // Calculate area and error associated with this curve
            this.area  = calculateAreaUnderCurve();
            this.error = calculateStandardError();
        }
コード例 #2
0
        /// <summary>
        ///   Computes a ROC curve with 1/increment points
        /// </summary>
        ///
        /// <param name="increment">The increment over the previous point for each point in the curve.</param>
        /// <param name="forceOrigin">True to force the inclusion of the (0,0) point, false otherwise. Default is false.</param>
        ///
        public void Compute(double increment, bool forceOrigin)
        {
            var    points = new List <ReceiverOperatingCharacteristicPoint>();
            double cutoff;

            // Create the curve, computing a point for each cutoff value
            for (cutoff = min; cutoff <= max; cutoff += increment)
            {
                points.Add(ComputePoint(cutoff));
            }


            // Sort the curve by descending specificity
            points.Sort(new Comparison <ReceiverOperatingCharacteristicPoint>(order));

            if (forceOrigin)
            {
                var last = points[points.Count - 1];
                if (last.FalsePositiveRate != 0.0 || last.Sensitivity != 0.0)
                {
                    points.Add(ComputePoint(Double.PositiveInfinity));
                }
            }


            // Create the point collection
            this.collection = new ReceiverOperatingCharacteristicPointCollection(points.ToArray());

            // Calculate area and error associated with this curve
            this.area  = calculateAreaUnderCurve();
            this.error = calculateStandardError();
        }