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
Location:
branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis.Views/3.4
Files:
4 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
  • branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/ClassificationEnsembleSolutionView.Designer.cs

    r7259 r7464  
    4444    /// </summary>
    4545    private void InitializeComponent() {
    46       components = new System.ComponentModel.Container();
     46      this.cmbWeightCalculator = new System.Windows.Forms.ComboBox();
     47      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
     48      this.splitContainer.Panel1.SuspendLayout();
     49      this.splitContainer.Panel2.SuspendLayout();
     50      this.splitContainer.SuspendLayout();
     51      this.itemsGroupBox.SuspendLayout();
     52      this.detailsGroupBox.SuspendLayout();
     53      this.SuspendLayout();
     54      //
     55      // splitContainer
     56      //
     57      //
     58      // splitContainer.Panel2
     59      //
     60      this.splitContainer.Panel2.Controls.Add(this.cmbWeightCalculator);
     61      //
     62      // addButton
     63      //
     64      this.toolTip.SetToolTip(this.addButton, "Add");
     65      //
     66      // removeButton
     67      //
     68      this.toolTip.SetToolTip(this.removeButton, "Remove");
     69      //
     70      // cmbWeightCalculator
     71      //
     72      this.cmbWeightCalculator.FormattingEnabled = true;
     73      this.cmbWeightCalculator.Location = new System.Drawing.Point(9, 6);
     74      this.cmbWeightCalculator.Name = "cmbWeightCalculator";
     75      this.cmbWeightCalculator.Size = new System.Drawing.Size(180, 21);
     76      this.cmbWeightCalculator.TabIndex = 1;
     77      this.cmbWeightCalculator.SelectedIndexChanged += new System.EventHandler(this.cmbWeightCalculator_SelectedIndexChanged);
     78      //
     79      // ClassificationEnsembleSolutionView
     80      //
     81      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    4782      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     83      this.Name = "ClassificationEnsembleSolutionView";
     84      this.splitContainer.Panel1.ResumeLayout(false);
     85      this.splitContainer.Panel2.ResumeLayout(false);
     86      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
     87      this.splitContainer.ResumeLayout(false);
     88      this.itemsGroupBox.ResumeLayout(false);
     89      this.detailsGroupBox.ResumeLayout(false);
     90      this.ResumeLayout(false);
     91
    4892    }
    4993
    5094    #endregion
     95
     96    private System.Windows.Forms.ComboBox cmbWeightCalculator;
    5197  }
    5298}
  • branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/ClassificationEnsembleSolutionView.cs

    r7259 r7464  
    2020#endregion
    2121
     22using System.Linq;
    2223using System.Windows.Forms;
     24using HeuristicLab.Common;
    2325using HeuristicLab.Core;
    2426using HeuristicLab.MainForm;
     27using HeuristicLab.PluginInfrastructure;
     28using HeuristicLab.Problems.DataAnalysis.Interfaces.Classification;
    2529
    2630namespace HeuristicLab.Problems.DataAnalysis.Views {
     
    3741    }
    3842
     43    protected override void SetEnabledStateOfControls() {
     44      base.SetEnabledStateOfControls();
     45      cmbWeightCalculator.Enabled = !Locked && !ReadOnly && Content != null;
     46    }
     47
    3948    protected override void OnContentChanged() {
    4049      base.OnContentChanged();
    4150      itemsListView.Items.Remove(itemsListView.FindItemWithText("Model: ClassificationEnsembleModel"));
     51      if (cmbWeightCalculator.Items.Count == 0) {
     52        cmbWeightCalculator.Items.AddRange(ApplicationManager.Manager.GetInstances<IClassificationEnsembleSolutionWeightCalculator>().OrderBy(b => b.Name, new NaturalStringComparer()).ToArray());
     53        if (cmbWeightCalculator.Items.Count > 0)
     54          cmbWeightCalculator.SelectedIndex = 0;
     55      } else {
     56        Content.WeightCalculator = (IClassificationEnsembleSolutionWeightCalculator)cmbWeightCalculator.SelectedItem;
     57      }
     58    }
     59
     60    private void cmbWeightCalculator_SelectedIndexChanged(object sender, System.EventArgs e) {
     61      if (cmbWeightCalculator.SelectedItem != null)
     62        Content.WeightCalculator = (IClassificationEnsembleSolutionWeightCalculator)cmbWeightCalculator.SelectedItem;
    4263    }
    4364
  • branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/DiscriminantFunctionClassificationSolutionView.cs

    r7259 r7464  
    2424namespace HeuristicLab.Problems.DataAnalysis.Views {
    2525  [View("ClassificationSolution View")]
    26   [Content(typeof(DiscriminantFunctionClassificationSolutionBase), false)]
     26  [Content(typeof(DiscriminantFunctionClassificationSolutionBase), true)]
    2727  public partial class DiscriminantFunctionClassificationSolutionView : ClassificationSolutionView {
    2828    public DiscriminantFunctionClassificationSolutionView() {
Note: See TracChangeset for help on using the changeset viewer.