Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2295


Ignore:
Timestamp:
08/18/09 18:17:04 (15 years ago)
Author:
mkommend
Message:

adapted CEDMA.BubbleChart to meet needs of new ModelAnalyzer (ticket #723)

Location:
trunk/sources
Files:
6 edited

Legend:

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

    r2289 r2295  
    7171      this.sizeDimension = dimension;
    7272      this.invertSize = inverted;
     73      Refresh();
     74    }
     75
     76    public void Refresh() {
    7377      Repaint();
    7478      EnforceUpdate();
     
    133137        } else if (matrix.MultiDimensionalCategoricalVariables.Contains(xDimension)) {
    134138          var path = xDimension.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim());
    135           IEnumerable<VisualMatrixRow> subRows = (IEnumerable<VisualMatrixRow>)r.Get(path.ElementAt(0));
    136           foreach (VisualMatrixRow subRow in subRows) {
     139          IEnumerable<MatrixRow> subRows = (IEnumerable<MatrixRow>)r.Get(path.ElementAt(0));
     140          foreach (MatrixRow subRow in subRows) {
    137141            if (subRow.Get(path.ElementAt(1)) != null) {
    138142              xs.Add(matrix.IndexOfCategoricalValue(xDimension, subRow.Get(path.ElementAt(1))) + r.YJitter * xJitterFactor);
     
    142146        } else if (matrix.MultiDimensionalOrdinalVariables.Contains(xDimension)) {
    143147          var path = xDimension.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim());
    144           IEnumerable<VisualMatrixRow> subRows = (IEnumerable<VisualMatrixRow>)r.Get(path.ElementAt(0));
    145           foreach (VisualMatrixRow subRow in subRows) {
     148          IEnumerable<MatrixRow> subRows = (IEnumerable<MatrixRow>)r.Get(path.ElementAt(0));
     149          foreach (MatrixRow subRow in subRows) {
    146150            if (subRow.Get(path.ElementAt(1)) != null) {
    147151              xs.Add(Convert.ToDouble(subRow.Get(path.ElementAt(1))) + r.XJitter * xJitterFactor);
     
    158162        } else if (matrix.MultiDimensionalCategoricalVariables.Contains(yDimension)) {
    159163          var path = yDimension.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim());
    160           IEnumerable<VisualMatrixRow> subRows = (IEnumerable<VisualMatrixRow>)r.Get(path.ElementAt(0));
    161           foreach (VisualMatrixRow subRow in subRows) {
     164          IEnumerable<MatrixRow> subRows = (IEnumerable<MatrixRow>)r.Get(path.ElementAt(0));
     165          foreach (MatrixRow subRow in subRows) {
    162166            if (subRow.Get(path.ElementAt(1)) != null) {
    163167              ys.Add(matrix.IndexOfCategoricalValue(yDimension, subRow.Get(path.ElementAt(1))) + r.YJitter * yJitterFactor);
     
    167171        } else if (matrix.MultiDimensionalOrdinalVariables.Contains(yDimension)) {
    168172          var path = yDimension.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim());
    169           IEnumerable<VisualMatrixRow> subRows = (IEnumerable<VisualMatrixRow>)r.Get(path.ElementAt(0));
    170           foreach (VisualMatrixRow subRow in subRows) {
     173          IEnumerable<MatrixRow> subRows = (IEnumerable<MatrixRow>)r.Get(path.ElementAt(0));
     174          foreach (MatrixRow subRow in subRows) {
    171175            if (subRow.Get(path.ElementAt(1)) != null) {
    172176              ys.Add(Convert.ToDouble(subRow.Get(path.ElementAt(1))) + r.YJitter * yJitterFactor);
  • trunk/sources/HeuristicLab.CEDMA.Charting/3.3/BubbleChartView.cs

    r2289 r2295  
    1919      InitializeComponent();
    2020      bubbleChartControl.Chart = new ModelingBubbleChart(results, 0, 0, 100, 100);
    21       xAxisComboBox.Items.AddRange(results.OrdinalVariables);
    22       xAxisComboBox.Items.AddRange(results.CategoricalVariables);
    23       xAxisComboBox.Items.AddRange(results.MultiDimensionalCategoricalVariables);
    24       xAxisComboBox.Items.AddRange(results.MultiDimensionalOrdinalVariables);
    25       yAxisComboBox.Items.AddRange(results.OrdinalVariables);
    26       yAxisComboBox.Items.AddRange(results.CategoricalVariables);
    27       yAxisComboBox.Items.AddRange(results.MultiDimensionalCategoricalVariables);
    28       yAxisComboBox.Items.AddRange(results.MultiDimensionalOrdinalVariables);
     21      xAxisComboBox.Items.AddRange(results.OrdinalVariables.ToArray());
     22      xAxisComboBox.Items.AddRange(results.CategoricalVariables.ToArray());
     23      xAxisComboBox.Items.AddRange(results.MultiDimensionalCategoricalVariables.ToArray());
     24      xAxisComboBox.Items.AddRange(results.MultiDimensionalOrdinalVariables.ToArray());
     25      yAxisComboBox.Items.AddRange(results.OrdinalVariables.ToArray());
     26      yAxisComboBox.Items.AddRange(results.CategoricalVariables.ToArray());
     27      yAxisComboBox.Items.AddRange(results.MultiDimensionalCategoricalVariables.ToArray());
     28      yAxisComboBox.Items.AddRange(results.MultiDimensionalOrdinalVariables.ToArray());
    2929      sizeComboBox.Items.Add(CONSTANT_SIZE);
    30       sizeComboBox.Items.AddRange(results.OrdinalVariables);
     30      sizeComboBox.Items.AddRange(results.OrdinalVariables.ToArray());
    3131      sizeComboBox.SelectedItem = sizeComboBox.Items[0];
    3232      yAxisComboBox.SelectedItem = yAxisComboBox.Items[0];
  • trunk/sources/HeuristicLab.CEDMA.Charting/3.3/ModelingBubbleChart.cs

    r2289 r2295  
    4646
    4747    public void matrix_Changed(object sender, EventArgs e) {
    48       Repaint();
    49       EnforceUpdate();
     48      Refresh();
    5049    }
    5150
  • trunk/sources/HeuristicLab.CEDMA.Charting/3.3/VisualMatrix.cs

    r2289 r2295  
    1111    private Matrix matrix;
    1212
    13     public VisualMatrix(Matrix matrix, string[] categoricalVariables, string[] ordinalVariables,
    14       string[] multiDimensionalCategoricalVariables,string[] multiDimensionalOrdinalVariables) {
     13    public VisualMatrix() {
     14      this.rows = new List<VisualMatrixRow>();
     15      this.categoricalVariables = new List<string>();
     16      this.ordinalVariables = new List<string>();
     17      this.multiDimensionalCategoricalVariables = new List<string>();
     18      this.multiDimensionalOrdinalVariables = new List<string>();
     19      this.categoricalValueIndices = new Dictionary<string, Dictionary<object, double>>();    }
     20
     21    public VisualMatrix(Matrix matrix, IEnumerable<string> categoricalVariables, IEnumerable<string> ordinalVariables,
     22      IEnumerable<string> multiDimensionalCategoricalVariables, IEnumerable<string> multiDimensionalOrdinalVariables)
     23      : this() {
    1524      this.matrix = matrix;
    16       this.rows = new List<VisualMatrixRow>();
    17       foreach(MatrixRow row in matrix.GetRows())
     25      this.matrix.Changed += new EventHandler(MatrixChanged);
     26
     27      foreach (MatrixRow row in matrix.GetRows())
    1828        rows.Add(new VisualMatrixRow(row));
    1929
    20       this.categoricalVariables = categoricalVariables;
    21       this.ordinalVariables = ordinalVariables;
    22       this.multiDimensionalOrdinalVariables = multiDimensionalOrdinalVariables;
    23       this.multiDimensionalCategoricalVariables = multiDimensionalCategoricalVariables;
    24       this.categoricalValueIndices = new Dictionary<string, Dictionary<object, double>>();
    25 
    26       matrix.Changed += new EventHandler(MatrixChanged);
     30      this.categoricalVariables.AddRange(categoricalVariables);
     31      this.ordinalVariables.AddRange(ordinalVariables);
     32      this.multiDimensionalCategoricalVariables.AddRange(multiDimensionalCategoricalVariables);
     33      this.multiDimensionalOrdinalVariables.AddRange(multiDimensionalOrdinalVariables);
    2734    }
    2835
     
    3441    }
    3542
    36     private string[] categoricalVariables;
    37     public string[] CategoricalVariables {
     43    public void AddRow(VisualMatrixRow row) {
     44      this.rows.Add(row);
     45    }
     46
     47    public void RemoveRow(VisualMatrixRow row) {
     48      this.rows.Remove(row);
     49    }
     50
     51    public void ClearAllRows(VisualMatrixRow row) {
     52      this.rows.Clear();
     53    }
     54
     55    private List<string> categoricalVariables;
     56    public IEnumerable<string> CategoricalVariables {
    3857      get { return categoricalVariables; }
    3958    }
    4059
    41     private string[] ordinalVariables;
    42     public string[] OrdinalVariables {
     60    public void AddCategoricalVariable(string name) {     
     61      this.categoricalVariables.Add(name);
     62    }
     63
     64    public void RemoveCategoricalVariable(string name) {
     65      this.categoricalVariables.Remove(name);
     66    }
     67
     68    public void ClearCategoricalVariables() {
     69      this.categoricalVariables.Clear();
     70    }
     71
     72    private List<string> ordinalVariables;
     73    public IEnumerable<string> OrdinalVariables {
    4374      get { return ordinalVariables; }
    4475    }
    4576
    46     private string[] multiDimensionalOrdinalVariables;
    47     public string[] MultiDimensionalOrdinalVariables {
     77    public void AddOrdinalVariable(string name) {
     78      this.ordinalVariables.Add(name);
     79    }
     80
     81    public void RemoveOrdinalVariable(string name) {
     82      this.ordinalVariables.Remove(name);
     83    }
     84
     85    public void ClearOrdinalVariables() {
     86      this.ordinalVariables.Clear();
     87    }
     88
     89    private List<string> multiDimensionalOrdinalVariables;
     90    public IEnumerable<string> MultiDimensionalOrdinalVariables {
    4891      get { return multiDimensionalOrdinalVariables; }
    4992    }
    5093
    51     private string[] multiDimensionalCategoricalVariables;
    52     public string[] MultiDimensionalCategoricalVariables {
     94    public void AddMultiDimensionalOrdinalVariable(string name) {
     95      this.multiDimensionalOrdinalVariables.Add(name);
     96    }
     97
     98    public void RemoveMultiDimensionalOrdinalVariable(string name) {
     99      this.multiDimensionalOrdinalVariables.Remove(name);
     100    }
     101
     102    public void ClearMultiDimensionalOrdinalVariables() {
     103      this.multiDimensionalOrdinalVariables.Clear();
     104    }
     105
     106    private List<string> multiDimensionalCategoricalVariables;
     107    public IEnumerable<string> MultiDimensionalCategoricalVariables {
    53108      get { return multiDimensionalCategoricalVariables; }
    54109    }
    55    
     110
     111    public void AddMultiDimensionalCategoricalVariable(string name) {
     112      this.multiDimensionalCategoricalVariables.Add(name);
     113    }
     114
     115    public void RemoveMultiDimensionalCategoricalVariable(string name) {
     116      this.multiDimensionalCategoricalVariables.Remove(name);
     117    }
     118
     119    public void ClearMultiDimensionalCategoricalVariables() {
     120      this.multiDimensionalCategoricalVariables.Clear();
     121    }
     122
    56123    public double IndexOfCategoricalValue(string variable, object value) {
    57124      if (value == null) return double.NaN;
     
    74141    }
    75142
    76      public IEnumerable<string> Attributes {
    77       get {return CategoricalVariables.Concat(OrdinalVariables);}
     143    public IEnumerable<string> Attributes {
     144      get { return CategoricalVariables.Concat(OrdinalVariables); }
    78145    }
    79146  }
  • trunk/sources/HeuristicLab.CEDMA.Charting/3.3/VisualMatrixRow.cs

    r2289 r2295  
    77
    88namespace HeuristicLab.CEDMA.Charting {
    9   public class VisualMatrixRow {
    10     private MatrixRow row;
     9  public class VisualMatrixRow : ItemBase {
    1110    private static Random random = new Random();
     11    private Dictionary<string, object> dict;
    1212
    13     public VisualMatrixRow(MatrixRow row) {
    14       this.row = row;
     13    public VisualMatrixRow() {
     14      this.dict = new Dictionary<string, object>();
    1515      this.visible = true;
    1616      this.selected = false;
    1717      this.xJitter = random.NextDouble() * 2.0 - 1.0;
    1818      this.yJitter = random.NextDouble() * 2.0 - 1.0;
     19    }
     20
     21    public VisualMatrixRow(MatrixRow row)
     22      : this() {
     23      foreach (KeyValuePair<string, object> value in row.Values)
     24        dict[value.Key] = value.Value;
    1925    }
    2026
     
    4248
    4349    public object Get(string name) {
    44       return row.Get(name);
     50      if (!dict.ContainsKey(name))
     51        return null;
     52      return dict[name];
     53    }
     54
     55    public void Set(string name, object value) {
     56      this.dict[name] = value;
     57    }
     58
     59    public IEnumerable<KeyValuePair<string, object>> Values {
     60      get { return dict; }
    4561    }
    4662
     
    5167    public string GetToolTipText() {
    5268      StringBuilder b = new StringBuilder();
    53       foreach (KeyValuePair<string, object> v in row.Values) {
     69      foreach (KeyValuePair<string, object> v in dict) {
    5470        if (v.Value is string || v.Value is double || v.Value is int) {
    5571          string val = v.Value.ToString();
  • trunk/sources/HeuristicLab.CEDMA.Core/3.3/Console.cs

    r2289 r2295  
    9494        row.Set("TargetVariable", model.TargetVariable.Name);
    9595        row.Set("Algorithm", model.Algorithm.Name);
    96         Dictionary<HeuristicLab.Modeling.Database.IVariable, MatrixRow> inputVariableResultsEntries =
    97           new Dictionary<HeuristicLab.Modeling.Database.IVariable, MatrixRow>();
    98 
    99         foreach (IInputVariableResult inputVariableResult in db.GetInputVariableResults(model)) {
    100           if (!inputVariableResultsEntries.ContainsKey(inputVariableResult.Variable)) {
    101             inputVariableResultsEntries[inputVariableResult.Variable] = new MatrixRow();
    102             inputVariableResultsEntries[inputVariableResult.Variable].Set("InputVariableName", inputVariableResult.Variable.Name);
    103           }
    104           inputVariableResultsEntries[inputVariableResult.Variable].Set(inputVariableResult.Result.Name, inputVariableResult.Value);
    105         }
    106         row.Set("VariableImpacts", inputVariableResultsEntries.Values);
     96       
    10797        matrix.AddRow(row);
    10898      }
     
    113103      DatabaseService db = new DatabaseService(sqlServerCompactConnectionString + database);
    114104      db.Connect();
    115       string[] multiDimensionalCategoricalVariables = new string[] { "VariableImpacts: InputVariableName" };
    116       string[] multiDimensionalOrdinalVariables = db.GetAllResultsForInputVariables().Select(x => "VariableImpacts: " + x.Name).ToArray();
    117       string[] ordinalVariables = db.GetAllResults().Select(r => r.Name).ToArray();
    118       string[] categoricalVariables = new string[] { "TargetVariable", "Algorithm" };
     105      IEnumerable<string> multiDimensionalCategoricalVariables = new List<string> { "VariableImpacts: InputVariableName" };
     106      IEnumerable<string> multiDimensionalOrdinalVariables = db.GetAllResultsForInputVariables().Select(x => "VariableImpacts: " + x.Name);
     107      IEnumerable<string> ordinalVariables = db.GetAllResults().Select(r => r.Name);
     108      IEnumerable<string> categoricalVariables = new List<string> { "TargetVariable", "Algorithm" };
    119109
    120110      db.Disconnect();
Note: See TracChangeset for help on using the changeset viewer.