Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3916


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

added ResultsView for DataAnalysisSolutions and implemented IStringConvertibleMatrix in DataAnalysisSolution (ticket #1020)

Location:
trunk/sources
Files:
2 added
5 edited

Legend:

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

    r3884 r3916  
    8484                         select double.IsNaN(boundedX) ? UpperEstimationLimit : boundedX).ToList();
    8585      OnEstimatedValuesChanged();
     86      RecalculateResultValues();
    8687    }
    8788
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionSolution.cs

    r3884 r3916  
    5757                         select double.IsNaN(boundedX) ? UpperEstimationLimit : boundedX).ToList();
    5858      OnEstimatedValuesChanged();
     59      RecalculateResultValues();
    5960    }
    6061
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.3/HeuristicLab.Problems.DataAnalysis.Views-3.3.csproj

    r3915 r3916  
    9292      <DependentUpon>DataAnalysisSolutionView.cs</DependentUpon>
    9393    </Compile>
     94    <Compile Include="ResultsView.cs">
     95      <SubType>UserControl</SubType>
     96    </Compile>
     97    <Compile Include="ResultsView.Designer.cs">
     98      <DependentUpon>ResultsView.cs</DependentUpon>
     99    </Compile>
    94100    <Compile Include="SupportVectorRegressionSolutionView.cs">
    95101      <SubType>UserControl</SubType>
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.3/LineChartView.cs

    r3764 r3916  
    4343    public new DataAnalysisSolution Content {
    4444      get { return (DataAnalysisSolution)base.Content; }
    45       set {
    46         base.Content = value;
    47       }
     45      set { base.Content = value; }
    4846    }
    4947
     
    9492      Content.ProblemDataChanged += new EventHandler(Content_ProblemDataChanged);
    9593    }
    96 
    9794    protected override void DeregisterContentEvents() {
    9895      base.DeregisterContentEvents();
     
    10198    }
    10299
    103     void Content_ProblemDataChanged(object sender, EventArgs e) {
     100    private void Content_ProblemDataChanged(object sender, EventArgs e) {
    104101      RedrawChart();
    105102    }
    106103
    107     void Content_EstimatedValuesChanged(object sender, EventArgs e) {
     104    private void Content_EstimatedValuesChanged(object sender, EventArgs e) {
    108105      UpdateEstimatedValuesLineChart();
    109106    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/DataAnalysisSolution.cs

    r3915 r3916  
    2828using System.Collections.Generic;
    2929using System.Linq;
     30using HeuristicLab.Problems.DataAnalysis.Evaluators;
    3031
    3132namespace HeuristicLab.Problems.DataAnalysis {
     
    3536  [Item("DataAnalysisSolution", "Represents a solution for a data analysis problem which can be visualized in the GUI.")]
    3637  [StorableClass]
    37   public abstract class DataAnalysisSolution : NamedItem {
     38  public abstract class DataAnalysisSolution : NamedItem, IStringConvertibleMatrix {
    3839    protected DataAnalysisSolution()
    3940      : base() { }
     
    144145    public event EventHandler EstimatedValuesChanged;
    145146    protected virtual void OnEstimatedValuesChanged() {
     147      RecalculateResultValues();
    146148      var listeners = EstimatedValuesChanged;
    147149      if (listeners != null)
     
    160162      return clone;
    161163    }
     164
     165    #region IStringConvertibleMatrix implementation
     166    private List<string> rowNames = new List<string>() { "MeanSquaredError", "CoefficientOfDetermination" };
     167    private List<string> columnNames = new List<string>() { "Training", "Test" };
     168    private double[,] resultValues = new double[2, 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      this.OnReset();
     193    }
     194
     195    public event EventHandler ColumnNamesChanged;
     196    public event EventHandler RowNamesChanged;
     197    public event EventHandler SortableViewChanged;
     198    public event EventHandler<EventArgs<int, int>> ItemChanged;
     199    public event EventHandler Reset;
     200    protected virtual void OnReset() {
     201      EventHandler handler = Reset;
     202      if (handler != null)
     203        handler(this, EventArgs.Empty);
     204    }
     205    #endregion
    162206  }
    163207}
Note: See TracChangeset for help on using the changeset viewer.