Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3979 for trunk


Ignore:
Timestamp:
06/30/10 10:58:01 (14 years ago)
Author:
mkommend
Message:

corrected DataAnalysis.Views.ResultsView to use an internal DoubleMatrix (ticket #1020)

Location:
trunk/sources
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/SupportVectorRegression/SupportVectorRegressionSolution.cs

    r3933 r3979  
    8484                         select double.IsNaN(boundedX) ? UpperEstimationLimit : boundedX).ToList();
    8585      OnEstimatedValuesChanged();
    86       RecalculateResultValues();
    8786    }
    8887
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionSolution.cs

    r3916 r3979  
    5757                         select double.IsNaN(boundedX) ? UpperEstimationLimit : boundedX).ToList();
    5858      OnEstimatedValuesChanged();
    59       RecalculateResultValues();
    6059    }
    6160
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.3/ResultsView.Designer.cs

    r3916 r3979  
    4444    /// </summary>
    4545    private void InitializeComponent() {
    46       components = new System.ComponentModel.Container();
     46      this.matrixView = new HeuristicLab.Data.Views.StringConvertibleMatrixView();
     47      this.SuspendLayout();
     48      //
     49      // matrixView
     50      //
     51      this.matrixView.Caption = "StringConvertibleMatrix View";
     52      this.matrixView.Content = null;
     53      this.matrixView.Dock = System.Windows.Forms.DockStyle.Fill;
     54      this.matrixView.Location = new System.Drawing.Point(0, 0);
     55      this.matrixView.Name = "matrixView";
     56      this.matrixView.ReadOnly = true;
     57      this.matrixView.Size = new System.Drawing.Size(494, 317);
     58      this.matrixView.TabIndex = 0;
     59      //
     60      // ResultsView
     61      //
     62      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    4763      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     64      this.Controls.Add(this.matrixView);
     65      this.Name = "ResultsView";
     66      this.Size = new System.Drawing.Size(494, 317);
     67      this.ResumeLayout(false);
     68
    4869    }
    4970
    5071    #endregion
     72
     73    private HeuristicLab.Data.Views.StringConvertibleMatrixView matrixView;
    5174  }
    5275}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.3/ResultsView.cs

    r3916 r3979  
    3030using HeuristicLab.MainForm.WindowsForms;
    3131using HeuristicLab.Data.Views;
     32using HeuristicLab.Data;
     33using HeuristicLab.Problems.DataAnalysis.Evaluators;
    3234
    3335namespace HeuristicLab.Problems.DataAnalysis.Views {
    3436  [Content(typeof(DataAnalysisSolution),false)]
    3537  [View("Results View")]
    36   public partial class ResultsView : StringConvertibleMatrixView {
     38  public partial class ResultsView : AsynchronousContentView {
     39    private List<string> rowNames = new List<string>() { "MeanSquaredError", "CoefficientOfDetermination", "MeanAbsolutePercentageError" };
     40    private List<string> columnNames = new List<string>() { "Training", "Test" };
     41
    3742    public ResultsView() {
    3843      InitializeComponent();
     
    4348      set { base.Content = value; }
    4449    }
     50
     51    protected override void RegisterContentEvents() {
     52      base.RegisterContentEvents();
     53      Content.ModelChanged += new EventHandler(Content_ModelChanged);
     54      Content.ProblemDataChanged += new EventHandler(Content_ProblemDataChanged);
     55      Content.EstimatedValuesChanged += new EventHandler(Content_EstimatedValuesChanged);
     56    }
     57    protected override void DeregisterContentEvents() {
     58      base.DeregisterContentEvents();
     59      Content.ModelChanged -= new EventHandler(Content_ModelChanged);
     60      Content.ProblemDataChanged -= new EventHandler(Content_ProblemDataChanged);
     61      Content.EstimatedValuesChanged -= new EventHandler(Content_EstimatedValuesChanged);
     62    }
     63
     64    private void Content_ModelChanged(object sender, EventArgs e) {
     65      UpdateView();
     66    }
     67    private void Content_ProblemDataChanged(object sender, EventArgs e) {
     68      UpdateView();
     69    }
     70    private void Content_EstimatedValuesChanged(object sender, EventArgs e) {
     71      UpdateView();
     72    }
     73
     74    protected override void OnContentChanged() {
     75      base.OnContentChanged();
     76      UpdateView();
     77    }
     78    private void UpdateView() {
     79      if (Content != null) {
     80        DoubleMatrix matrix = new DoubleMatrix(rowNames.Count, columnNames.Count);
     81        matrix.RowNames = rowNames;
     82        matrix.ColumnNames = columnNames;
     83        matrix.SortableView = false;
     84
     85        IEnumerable<double> originalTrainingValues = Content.ProblemData.Dataset.GetVariableValues(Content.ProblemData.TargetVariable.Value, Content.ProblemData.TrainingSamplesStart.Value, Content.ProblemData.TrainingSamplesEnd.Value);
     86        IEnumerable<double> originalTestValues = Content.ProblemData.Dataset.GetVariableValues(Content.ProblemData.TargetVariable.Value, Content.ProblemData.TestSamplesStart.Value, Content.ProblemData.TestSamplesEnd.Value);
     87        matrix[0, 0] = SimpleMSEEvaluator.Calculate(originalTrainingValues, Content.EstimatedTrainingValues);
     88        matrix[0, 1] = SimpleMSEEvaluator.Calculate(originalTestValues, Content.EstimatedTestValues);
     89        matrix[1, 0] = SimpleRSquaredEvaluator.Calculate(originalTrainingValues, Content.EstimatedTrainingValues);
     90        matrix[1, 1] = SimpleRSquaredEvaluator.Calculate(originalTestValues, Content.EstimatedTestValues);
     91        matrix[2, 0] = SimpleMeanAbsolutePercentageErrorEvaluator.Calculate(originalTrainingValues, Content.EstimatedTrainingValues);
     92        matrix[2, 1] = SimpleMeanAbsolutePercentageErrorEvaluator.Calculate(originalTestValues, Content.EstimatedTestValues);
     93
     94        matrixView.Content = matrix;
     95      } else
     96        matrixView.Content = null;
     97    }
    4598  }
    4699}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/DataAnalysisSolution.cs

    r3933 r3979  
    3636  [Item("DataAnalysisSolution", "Represents a solution for a data analysis problem which can be visualized in the GUI.")]
    3737  [StorableClass]
    38   public abstract class DataAnalysisSolution : NamedItem, IStringConvertibleMatrix {
     38  public abstract class DataAnalysisSolution : NamedItem {
    3939    protected DataAnalysisSolution()
    4040      : base() { }
     
    162162      return clone;
    163163    }
    164 
    165     #region IStringConvertibleMatrix implementation
    166     private List<string> rowNames = new List<string>() { "MeanSquaredError", "CoefficientOfDetermination", "MeanAbsolutePercentageError" };
    167     private List<string> columnNames = new List<string>() { "Training", "Test" };
    168     private double[,] resultValues = new double[3, 2];
    169     int IStringConvertibleMatrix.Rows { get { return rowNames.Count; } set { } }
    170     int IStringConvertibleMatrix.Columns { get { return columnNames.Count; } set { } }
    171     IEnumerable<string> IStringConvertibleMatrix.ColumnNames { get { return columnNames; } set { } }
    172     IEnumerable<string> IStringConvertibleMatrix.RowNames { get { return rowNames; } set { } }
    173     bool IStringConvertibleMatrix.SortableView { get { return false; } set { } }
    174     bool IStringConvertibleMatrix.ReadOnly { get { return true; } }
    175 
    176     string IStringConvertibleMatrix.GetValue(int rowIndex, int columnIndex) {
    177       return resultValues[rowIndex, columnIndex].ToString();
    178     }
    179     bool IStringConvertibleMatrix.Validate(string value, out string errorMessage) {
    180       errorMessage = "This matrix is readonly.";
    181       return false;
    182     }
    183     bool IStringConvertibleMatrix.SetValue(string value, int rowIndex, int columnIndex) { return false; }
    184 
    185     protected void RecalculateResultValues() {
    186       IEnumerable<double> originalTrainingValues = problemData.Dataset.GetVariableValues(problemData.TargetVariable.Value, problemData.TrainingSamplesStart.Value, problemData.TrainingSamplesEnd.Value);
    187       IEnumerable<double> originalTestValues = problemData.Dataset.GetVariableValues(problemData.TargetVariable.Value, problemData.TestSamplesStart.Value, problemData.TestSamplesEnd.Value);
    188       resultValues[0, 0] = SimpleMSEEvaluator.Calculate(originalTrainingValues, EstimatedTrainingValues);
    189       resultValues[0, 1] = SimpleMSEEvaluator.Calculate(originalTestValues, EstimatedTestValues);
    190       resultValues[1, 0] = SimpleRSquaredEvaluator.Calculate(originalTrainingValues, EstimatedTrainingValues);
    191       resultValues[1, 1] = SimpleRSquaredEvaluator.Calculate(originalTestValues, EstimatedTestValues);
    192       resultValues[2, 0] = SimpleMeanAbsolutePercentageErrorEvaluator.Calculate(originalTrainingValues, EstimatedTrainingValues);
    193       resultValues[2, 1] = SimpleMeanAbsolutePercentageErrorEvaluator.Calculate(originalTestValues, EstimatedTestValues);
    194 
    195       this.OnReset();
    196     }
    197 
    198     public event EventHandler ColumnNamesChanged;
    199     public event EventHandler RowNamesChanged;
    200     public event EventHandler SortableViewChanged;
    201     public event EventHandler<EventArgs<int, int>> ItemChanged;
    202     public event EventHandler Reset;
    203     protected virtual void OnReset() {
    204       EventHandler handler = Reset;
    205       if (handler != null)
    206         handler(this, EventArgs.Empty);
    207     }
    208     #endregion
    209164  }
    210165}
Note: See TracChangeset for help on using the changeset viewer.