/// <inheritdoc /> public override bool Equals(object obj) { if (object.ReferenceEquals(null, obj)) { return(false); } if (object.ReferenceEquals(this, obj)) { return(true); } if (!(obj is RejectCurveTarget)) { return(false); } RejectCurveTarget other = (RejectCurveTarget)obj; return(this.Target == other.Target && this.Point == other.Point); }
/// <summary> /// Writes all reject curves. /// </summary> /// <param name="writer">A stream to write the report to.</param> /// <param name="all">Classification results for all classes.</param> /// <param name="classes">Classification results for each class.</param> private static void WriteRejectCurves(TextWriter writer, ClassSummary <T> all, IList <ClassSummary <T> > classes) { float[] errorRates = { 0.001f, 0.005f, 0.01f, 0.02f, 0.03f, 0.04f, 0.05f, 0.06f, 0.07f, 0.08f, 0.09f, 0.10f, 0.11f }; List <ClassSummary <T> > combined = new List <ClassSummary <T> >() { all }; combined.AddRange(classes); string separator = new string('-', 10 + (30 * combined.Count)); // write class names writer.Write("{0,-10}", string.Empty); foreach (ClassSummary <T> cls in combined) { writer.Write("{0,-30}", cls.Label); } writer.WriteLine(); writer.WriteLine(separator); // write header writer.Write("{0,-10}", "Target"); for (int i = 0, ii = combined.Count; i < ii; i++) { writer.Write("{0,-10}{1,-10}{2,-10}", "Error", "Accept", "Thresh"); } writer.WriteLine(); // write targets foreach (float errorRate in errorRates) { writer.Write("{0,-10:P2}", errorRate); foreach (ClassSummary <T> cls in combined) { RejectCurveTarget target = cls.Statistics.RejectCurveTruth.GetTarget(errorRate); if (target.Point.HasValue) { writer.Write( "{0,-10:P2}{1,-10:P2}{2,-10:N0}", target.Point.Value.ErrorRate, target.Point.Value.AcceptRate, target.Point.Value.Threshold); } else { writer.Write( "{0,-10}{0,-10}{0,-10}", "N/A"); } } writer.WriteLine(); } writer.WriteLine(separator); // write area writer.Write("{0,-10}", "Area:"); foreach (ClassSummary <T> cls in combined) { float average = cls.Statistics.RejectCurveTruth.GetArea(0.0f, errorRates.Last(), 100); writer.Write("{0,-30:P2}", average); } writer.WriteLine(); }