Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8859


Ignore:
Timestamp:
10/30/12 12:41:00 (11 years ago)
Author:
sforsten
Message:

#1978:

  • fixed divide by zero bug
  • estimated class value and correct target value are compared
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationEnsembleSolutionEstimatedClassValuesView.cs

    r8554 r8859  
    106106        int row = indices[i];
    107107        values[i, 0] = row.ToString();
    108         values[i, 1] = target[i].ToString();
     108        values[i, 1] = target[row].ToString();
    109109        //display only indices and target values if no models are present
    110110        if (solutionsCount > 0) {
    111111          values[i, 2] = estimatedClassValues[i].ToString();
    112           values[i, 3] = (target[i].IsAlmost(estimatedClassValues[i])).ToString();
     112          values[i, 3] = (target[row].IsAlmost(estimatedClassValues[i])).ToString();
    113113          var groups =
    114114            estimatedValuesVector[i].GroupBy(x => x).Select(g => new { Key = g.Key, Count = g.Count() }).ToList();
    115115          var estimationCount = groups.Where(g => g.Key != null).Select(g => g.Count).Sum();
    116           values[i, 4] = (((double)groups.Where(g => g.Key == estimatedClassValues[i]).Single().Count) / estimationCount).ToString();
     116          // take care of divide by zero
     117          if (estimationCount != 0) {
     118            values[i, 4] = (((double)groups.Where(g => g.Key == estimatedClassValues[i]).Single().Count) / estimationCount).ToString();
     119          } else {
     120            values[i, 4] = double.NaN.ToString();
     121          }
    117122          for (int classIndex = 0; classIndex < Content.ProblemData.Classes; classIndex++) {
    118123            var group = groups.Where(g => g.Key == Content.ProblemData.ClassValues.ElementAt(classIndex)).SingleOrDefault();
Note: See TracChangeset for help on using the changeset viewer.