/// <summary> /// Creates the report from metrics given, using averaging computation specified /// </summary> /// <param name="_metrics">The metrics to build report entry from</param> /// <param name="averageComputation">The average computation method to apply for F1, P and R</param> public classificationReport(classificationEvalMetricSet _metrics, classificationMetricComputation averageComputation) { Name = _metrics.name; GetSetMetrics(_metrics); this.AddValues(_metrics, averageComputation); method = averageComputation; }
/// <summary> /// Sets (if specified <c>_metrics</c> is not null) and Gets (earlier or just set) metrics object. Makes no change to report content, just stores the metrics temporarrly /// </summary> /// <param name="_metrics">The metrics.</param> /// <returns></returns> public classificationEvalMetricSet GetSetMetrics(classificationEvalMetricSet _metrics = null) { if (_metrics != null) { metrics = _metrics; } return(metrics); }
/// <summary> /// Sets or Adds the values from specified <c>metrics</c> object. /// </summary> /// <param name="a">a.</param> /// <param name="metrics">The metrics.</param> /// <param name="method">The method of ratios computation (F1, Precision, Recall)</param> public static void AddValues(this IClassificationReport a, classificationEvalMetricSet metrics, classificationMetricComputation method) { a.Precision += metrics.GetPrecision(method); a.Recall += metrics.GetRecall(method); a.F1measure += metrics.GetF1(method); foreach (var p in metrics) { a.Correct += p.Value.correct; a.Wrong += p.Value.wrong; a.Targets += p.Value.correct + p.Value.wrong; } a.method = method; }