Changeset 13766


Ignore:
Timestamp:
04/14/16 18:04:53 (3 years ago)
Author:
mkommend
Message:

#2595: First version of impact calculation for regression solution.

Location:
trunk/sources
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/RegressionSolutionView.Designer.cs

    r12012 r13766  
    1919 */
    2020#endregion
     21
    2122
    2223namespace HeuristicLab.Problems.DataAnalysis.Views {
     
    4546    /// </summary>
    4647    private void InitializeComponent() {
     48      this.btnImpactCalculation = new System.Windows.Forms.Button();
    4749      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
    4850      this.splitContainer.Panel1.SuspendLayout();
     
    5254      this.detailsGroupBox.SuspendLayout();
    5355      this.SuspendLayout();
     56      //
     57      // btnImpactCalculation
     58      //
     59      this.btnImpactCalculation.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)));
     60      this.btnImpactCalculation.Image = HeuristicLab.Common.Resources.VSImageLibrary.Zoom;
     61      this.btnImpactCalculation.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
     62      this.btnImpactCalculation.Name = "btnImpactCalculation";
     63      this.btnImpactCalculation.TabIndex = 6;
     64      this.btnImpactCalculation.Size = new System.Drawing.Size(110, 24);
     65      this.btnImpactCalculation.Text = "Variable Impacts";
     66      this.btnImpactCalculation.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
     67      this.btnImpactCalculation.UseVisualStyleBackColor = true;
     68      this.btnImpactCalculation.Click += new System.EventHandler(this.btnImpactCalculation_Click);
     69      this.toolTip.SetToolTip(this.btnImpactCalculation, "Simplify solution");
     70      //
     71      // flowLayoutPanel
     72      //
     73      this.flowLayoutPanel.Controls.Add(this.btnImpactCalculation);
    5474      //
    5575      // splitContainer
     
    84104
    85105    #endregion
     106
     107    protected System.Windows.Forms.Button btnImpactCalculation;
    86108  }
    87109}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/RegressionSolutionView.cs

    r12012 r13766  
    2020#endregion
    2121
     22using System;
     23using System.Linq;
     24using System.Threading.Tasks;
    2225using System.Windows.Forms;
    2326using HeuristicLab.Core;
     27using HeuristicLab.Data;
     28using HeuristicLab.Data.Views;
    2429using HeuristicLab.MainForm;
     30using HeuristicLab.MainForm.WindowsForms;
    2531
    2632namespace HeuristicLab.Problems.DataAnalysis.Views {
     
    3541      get { return (RegressionSolutionBase)base.Content; }
    3642      set { base.Content = value; }
     43    }
     44
     45    protected virtual void btnImpactCalculation_Click(object sender, EventArgs e) {
     46      var mainForm = (MainForm.WindowsForms.MainForm)MainFormManager.MainForm;
     47      var view = new StringConvertibleArrayView();
     48      view.Caption = Content.Name + " Variable Impacts";
     49      view.Show();
     50
     51      Task.Factory.StartNew(() => {
     52        try {
     53          mainForm.AddOperationProgressToView(view, "Calculating variable impacts for " + Content.Name);
     54
     55          var impacts = RegressionSolutionVariableImpactsCalculator.CalculateImpacts(Content);
     56          var impactArray = new DoubleArray(impacts.Select(i => i.Item2).ToArray());
     57          impactArray.ElementNames = impacts.Select(i => i.Item1);
     58          view.Content = (DoubleArray)impactArray.AsReadOnly();
     59        }
     60        finally {
     61          mainForm.RemoveOperationProgressFromView(view);
     62        }
     63      });
    3764    }
    3865
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj

    r13154 r13766  
    143143    </Compile>
    144144    <Compile Include="Implementation\Regression\RegressionEnsembleSolution.cs" />
     145    <Compile Include="Implementation\Regression\RegressionSolutionVariableImpactsCalculator.cs" />
    145146    <Compile Include="Implementation\TimeSeriesPrognosis\Models\ConstantTimeSeriesPrognosisModel.cs" />
    146147    <Compile Include="Implementation\TimeSeriesPrognosis\Models\TimeSeriesPrognosisAutoRegressiveModel.cs" />
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblemData.cs

    r12509 r13766  
    8080    }
    8181
     82    public virtual IEnumerable<int> AllIndices {
     83      get { return Enumerable.Range(0, Dataset.Rows); }
     84    }
    8285    public virtual IEnumerable<int> TrainingIndices {
    8386      get {
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionProblemData.cs

    r12509 r13766  
    110110    }
    111111
     112    public IEnumerable<double> TargetVariableValues {
     113      get { return Dataset.GetDoubleValues(TargetVariable); }
     114    }
     115    public IEnumerable<double> TargetVariableTrainingValues {
     116      get { return Dataset.GetDoubleValues(TargetVariable, TrainingIndices); }
     117    }
     118    public IEnumerable<double> TargetVariableTestValues {
     119      get { return Dataset.GetDoubleValues(TargetVariable, TestIndices); }
     120    }
     121
     122
    112123    [StorableConstructor]
    113124    protected RegressionProblemData(bool deserializing) : base(deserializing) { }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataAnalysisProblemData.cs

    r12509 r13766  
    3636    IntRange TestPartition { get; }
    3737
     38    IEnumerable<int> AllIndices { get; }
    3839    IEnumerable<int> TrainingIndices { get; }
    3940    IEnumerable<int> TestIndices { get; }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Regression/IRegressionProblemData.cs

    r12012 r13766  
    2020#endregion
    2121
     22using System.Collections.Generic;
     23
    2224namespace HeuristicLab.Problems.DataAnalysis {
    2325  public interface IRegressionProblemData : IDataAnalysisProblemData {
    2426    string TargetVariable { get; set; }
     27
     28    IEnumerable<double> TargetVariableValues { get; }
     29    IEnumerable<double> TargetVariableTrainingValues { get; }
     30    IEnumerable<double> TargetVariableTestValues { get; }
    2531  }
    2632}
Note: See TracChangeset for help on using the changeset viewer.