Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/15/08 13:19:09 (16 years ago)
Author:
gkronber
Message:

fixed a problem with brushing in histograms and added variable selection pressure

Location:
trunk/sources/HeuristicLab.CEDMA.Charting
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.CEDMA.Charting/Histogram.cs

    r573 r575  
    3232    private static readonly Color defaultColor = Color.Blue;
    3333    private static readonly Color selectionColor = Color.Red;
     34    private static readonly Pen defaultPen = new Pen(defaultColor);
     35    private static readonly Brush defaultBrush = defaultPen.Brush;
     36    private static readonly Pen selectionPen = new Pen(selectionColor);
     37    private static readonly Brush selectionBrush = selectionPen.Brush;
    3438
    3539    private double minX;
     
    4347    private Dictionary<Record, IPrimitive> recordToPrimitiveDictionary;
    4448    private Group bars;
    45     private double[] limits;
    46     private int[] buckets;
    4749    private string dimension;
    4850
     
    6264      results.OnRecordAdded += new EventHandler<RecordAddedEventArgs>(results_OnRecordAdded);
    6365      results.Changed += new EventHandler(results_Changed);
    64       limits = new double[N_BUCKETS - 1];
    65       buckets = new int[N_BUCKETS];
    6666    }
    6767
    6868    void results_Changed(object sender, EventArgs e) {
     69      ResetViewSize();
    6970      Repaint();
    7071      EnforceUpdate();
     
    9697        Group.Add(new Axis(this, 0, 0, AxisType.Both));
    9798        UpdateViewSize(0, 0);
    98         Pen defaultPen = new Pen(defaultColor);
    99         Brush defaultBrush = defaultPen.Brush;
    100         PaintHistogram(records, defaultPen, defaultBrush);
    101         Pen selectionPen = new Pen(selectionColor);
    102         Brush selectionBrush = selectionPen.Brush;
    103         PaintHistogram(records.Where(r => r.Selected), selectionPen, selectionBrush);
     99        PaintHistogram(records);
    104100        Group.Add(bars);
    105101        UpdateEnabled = true;
     
    107103    }
    108104
    109     private void PaintHistogram(IEnumerable<Record> records, Pen pen, Brush brush) {
     105    private void PaintHistogram(IEnumerable<Record> records) {
    110106      var values = records.Select(r => new { Record = r, Value = r.Get(dimension) }).Where(
    111107        x => !double.IsNaN(x.Value) && !double.IsInfinity(x.Value) && x.Value != double.MinValue && x.Value != double.MaxValue).OrderBy(x => x.Value);
     
    121117      foreach(var g in frequencies) {
    122118        double freq = g.Count();
     119        double selectedFreq = g.Where(r=>r.Record.Selected).Count();
    123120        double lower = g.Key;
    124121        double upper = g.Key + bucketSize;
    125         HeuristicLab.Charting.Rectangle bar = new HeuristicLab.Charting.Rectangle(this, lower, 0, upper, freq, pen, brush);
     122        HeuristicLab.Charting.Rectangle bar = new HeuristicLab.Charting.Rectangle(this, lower, 0, upper, freq, defaultPen, defaultBrush);
    126123        primitiveToRecordsDictionary[bar] = g.Select(r => r.Record).ToList();
    127124        primitiveToRecordsDictionary[bar].ForEach(x => recordToPrimitiveDictionary[x] = bar);
    128         if(lower == frequencies.First().Key) bar.ToolTipText = " x < " + upper + " : " + freq;
    129         else if(lower == frequencies.Last().Key) bar.ToolTipText = "x >= " + lower + " : " + freq;
    130         else bar.ToolTipText = "x in [" + lower + " .. " + upper + "[ : " + freq;
     125        HeuristicLab.Charting.Rectangle selectedBar = new HeuristicLab.Charting.Rectangle(this, lower, 0, upper, selectedFreq, selectionPen, selectionBrush);
     126        primitiveToRecordsDictionary[selectedBar] = g.Select(r => r.Record).Where(r=>r.Selected).ToList();
     127        primitiveToRecordsDictionary[selectedBar].ForEach(x => recordToPrimitiveDictionary[x] = bar);
     128        if(lower == frequencies.First().Key) {
     129          selectedBar.ToolTipText = " x < " + upper + " : " + selectedFreq;
     130           bar.ToolTipText = " x < " + upper + " : " + freq;
     131        } else if(lower == frequencies.Last().Key) {
     132          selectedBar.ToolTipText = "x >= " + lower + " : " + selectedFreq;
     133          bar.ToolTipText = "x >= " + lower + " : " + freq;
     134        } else {
     135          selectedBar.ToolTipText = "x in [" + lower + " .. " + upper + "[ : " + selectedFreq;
     136           bar.ToolTipText = "x in [" + lower + " .. " + upper + "[ : " + freq;
     137        }
    131138        bars.Add(bar);
     139        bars.Add(selectedBar);
    132140        UpdateViewSize(lower, freq);
    133141        UpdateViewSize(upper, freq);
  • trunk/sources/HeuristicLab.CEDMA.Charting/Record.cs

    r573 r575  
    6464    public const string TREE_SIZE = "Tree size";
    6565    public const string TREE_HEIGHT = "Tree height";
     66    public const string SELECTIONPRESSURE = "Selection pressure";
    6667
    6768    public const string X_JITTER = "__X_JITTER";
  • trunk/sources/HeuristicLab.CEDMA.Charting/ResultList.cs

    r567 r575  
    6060    private readonly Entity treeSizePredicate = new Entity(cedmaNS + "TreeSize");
    6161    private readonly Entity treeHeightPredicate = new Entity(cedmaNS + "TreeHeight");
    62     private readonly Entity rawDataPredicate = new Entity(cedmaNS + "rawData");
    63     private readonly Entity hasModelPredicate = new Entity(cedmaNS + "hasModel");
     62    private readonly Entity selectionPressurePredicate = new Entity(cedmaNS + "SelectionPressure");
     63    private readonly Entity rawDataPredicate = new Entity(cedmaNS + "RawData");
     64    private readonly Entity hasModelPredicate = new Entity(cedmaNS + "Model");
    6465    private readonly Entity anyEntity = new Entity(null);
    6566    private Dictionary<Record, Dataset> datasets;
     
    7576    }
    7677
    77     private List<string> variableNames = new List<string>() { Record.TARGET_VARIABLE, Record.TREE_SIZE, Record.TREE_HEIGHT,
     78    private List<string> variableNames = new List<string>() { Record.TARGET_VARIABLE, Record.TREE_SIZE, Record.TREE_HEIGHT, Record.SELECTIONPRESSURE,
    7879    Record.MAPE_TRAINING, Record.MAPE_VALIDATION, Record.MAPE_TEST,
    7980    Record.R2_TRAINING, Record.R2_VALIDATION, Record.R2_TEST};
     
    102103      .Select(x => store.Select(new SelectFilter(
    103104        new Entity[] { new Entity(x.Subject.Uri) },
    104         new Entity[] { targetVariablePredicate, treeSizePredicate, treeHeightPredicate,
     105        new Entity[] { targetVariablePredicate, treeSizePredicate, treeHeightPredicate, selectionPressurePredicate,
    105106          trainingMAPEPredicate, validationMAPEPredicate, testMAPEPredicate,
    106107          trainingR2Predicate, validationR2Predicate, testR2Predicate },
     
    145146      predicateToVariableName[treeSizePredicate] = Record.TREE_SIZE;
    146147      predicateToVariableName[treeHeightPredicate] = Record.TREE_HEIGHT;
     148      predicateToVariableName[selectionPressurePredicate] = Record.SELECTIONPRESSURE;
    147149      predicateToVariableName[trainingMAPEPredicate] = Record.MAPE_TRAINING;
    148150      predicateToVariableName[validationMAPEPredicate] = Record.MAPE_VALIDATION;
Note: See TracChangeset for help on using the changeset viewer.