Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/07/12 16:50:35 (12 years ago)
Author:
sforsten
Message:

#1776:

  • selection of a voting strategy is now possible
  • a more sophisticated strategy as discussed with gkronber will be implemented soon
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationEnsembleSolutionEstimatedClassValuesView.cs

    r7259 r7464  
    102102      List<List<double?>> estimatedValuesVector = GetEstimatedValues(SamplesComboBox.SelectedItem.ToString(), indizes,
    103103                                                            Content.ClassificationSolutions);
     104      List<double> weights = Content.Weights.ToList();
     105      double weightSum = weights.Sum();
    104106
    105107      for (int i = 0; i < indizes.Length; i++) {
     
    111113          values[i, 2] = estimatedClassValues[i].ToString();
    112114          values[i, 3] = (target[i].IsAlmost(estimatedClassValues[i])).ToString();
     115
     116          IEnumerable<int> indices = FindAllIndices(estimatedValuesVector[i], estimatedClassValues[i]);
     117          double confidence = 0.0;
     118          foreach (var index in indices) {
     119            confidence += weights[index];
     120          }
     121          values[i, 4] = (confidence / weightSum).ToString();
     122          //var estimationCount = groups.Where(g => g.Key != null).Select(g => g.Count).Sum();
     123          //values[i, 4] =
     124          //  (((double)groups.Where(g => g.Key == estimatedClassValues[i]).Single().Count) / estimationCount).ToString();
     125
    113126          var groups =
    114127            estimatedValuesVector[i].GroupBy(x => x).Select(g => new { Key = g.Key, Count = g.Count() }).ToList();
    115           var estimationCount = groups.Where(g => g.Key != null).Select(g => g.Count).Sum();
    116           values[i, 4] =
    117             (((double)groups.Where(g => g.Key == estimatedClassValues[i]).Single().Count) / estimationCount).ToString();
    118128          for (int classIndex = 0; classIndex < Content.ProblemData.ClassValues.Count; classIndex++) {
    119129            var group = groups.Where(g => g.Key == Content.ProblemData.ClassValues[classIndex]).SingleOrDefault();
     
    136146      matrix.SortableView = true;
    137147      matrixView.Content = matrix;
     148    }
     149
     150    private IEnumerable<int> FindAllIndices(List<double?> list, double value) {
     151      List<int> indices = new List<int>();
     152      for (int i = 0; i < list.Count; i++) {
     153        if (list[i].Equals(value))
     154          indices.Add(i);
     155      }
     156      return indices;
    138157    }
    139158
Note: See TracChangeset for help on using the changeset viewer.