Free cookie consent management tool by TermsFeed Policy Generator

Changeset 14022


Ignore:
Timestamp:
07/08/16 12:25:13 (8 years ago)
Author:
mkommend
Message:

#2595: Merged r13766, r13942, r13985, r13986, r13987 into stable.

Location:
stable
Files:
11 edited
1 copied

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Problems.DataAnalysis

  • stable/HeuristicLab.Problems.DataAnalysis.Views

  • stable/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/RegressionSolutionView.Designer.cs

    r12009 r14022  
    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, "Calculate impacts");
     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}
  • stable/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/RegressionSolutionView.cs

    r12009 r14022  
    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 override void SetEnabledStateOfControls() {
     46      base.SetEnabledStateOfControls();
     47      btnImpactCalculation.Enabled = Content != null && !Locked;
     48    }
     49
     50    protected virtual void btnImpactCalculation_Click(object sender, EventArgs e) {
     51      var mainForm = (MainForm.WindowsForms.MainForm)MainFormManager.MainForm;
     52      var view = new StringConvertibleArrayView();
     53      view.Caption = Content.Name + " Variable Impacts";
     54      view.Show();
     55
     56      Task.Factory.StartNew(() => {
     57        try {
     58          mainForm.AddOperationProgressToView(view, "Calculating variable impacts for " + Content.Name);
     59
     60          var impacts = RegressionSolutionVariableImpactsCalculator.CalculateImpacts(Content);
     61          var impactArray = new DoubleArray(impacts.Select(i => i.Item2).ToArray());
     62          impactArray.ElementNames = impacts.Select(i => i.Item1);
     63          view.Content = (DoubleArray)impactArray.AsReadOnly();
     64        }
     65        finally {
     66          mainForm.RemoveOperationProgressFromView(view);
     67        }
     68      });
    3769    }
    3870
  • stable/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj

    r13156 r14022  
    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" />
     
    313314      <Private>False</Private>
    314315    </ProjectReference>
     316    <ProjectReference Include="..\..\HeuristicLab.Random\3.3\HeuristicLab.Random-3.3.csproj">
     317      <Project>{F4539FB6-4708-40C9-BE64-0A1390AEA197}</Project>
     318      <Name>HeuristicLab.Random-3.3</Name>
     319    </ProjectReference>
    315320  </ItemGroup>
    316321  <ItemGroup />
  • stable/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblemData.cs

    r12702 r14022  
    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 {
  • stable/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionProblemData.cs

    r12702 r14022  
    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) { }
  • stable/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolutionVariableImpactsCalculator.cs

    r13766 r14022  
    3030using HeuristicLab.Parameters;
    3131using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     32using HeuristicLab.Random;
    3233
    3334namespace HeuristicLab.Problems.DataAnalysis {
    3435  [StorableClass]
    35   [Item("RegressionSolution Impacts Calculator", "Calculation of the impacts of input variables for a concrete ")]
     36  [Item("RegressionSolution Impacts Calculator", "Calculation of the impacts of input variables for any regression solution")]
    3637  public sealed class RegressionSolutionVariableImpactsCalculator : ParameterizedNamedItem {
    3738    public enum ReplacementMethodEnum {
    3839      Median,
    39       Average
     40      Average,
     41      Shuffle,
     42      Noise
    4043    }
    4144
     
    7780      : base() {
    7881      Parameters.Add(new FixedValueParameter<EnumValue<ReplacementMethodEnum>>(ReplacementParameterName, "The replacement method for variables during impact calculation.", new EnumValue<ReplacementMethodEnum>(ReplacementMethodEnum.Median)));
    79       Parameters.Add(new FixedValueParameter<EnumValue<DataPartitionEnum>>(ReplacementParameterName, "The data partition on which the impacts are calculated.", new EnumValue<DataPartitionEnum>(DataPartitionEnum.Training)));
     82      Parameters.Add(new FixedValueParameter<EnumValue<DataPartitionEnum>>(DataPartitionParameterName, "The data partition on which the impacts are calculated.", new EnumValue<DataPartitionEnum>(DataPartitionEnum.Training)));
    8083    }
    8184
     
    138141      var originalValues = dataset.GetReadOnlyDoubleValues(variable).ToList();
    139142      double replacementValue;
     143      List<double> replacementValues;
     144      IRandom rand;
    140145
    141146      switch (replacement) {
    142147        case ReplacementMethodEnum.Median:
    143148          replacementValue = rows.Select(r => originalValues[r]).Median();
     149          replacementValues = Enumerable.Repeat(replacementValue, dataset.Rows).ToList();
    144150          break;
    145151        case ReplacementMethodEnum.Average:
    146152          replacementValue = rows.Select(r => originalValues[r]).Average();
     153          replacementValues = Enumerable.Repeat(replacementValue, dataset.Rows).ToList();
    147154          break;
     155        case ReplacementMethodEnum.Shuffle:
     156          // new var has same empirical distribution but the relation to y is broken
     157          rand = new FastRandom(31415);
     158          replacementValues = rows.Select(r => originalValues[r]).Shuffle(rand).ToList();
     159          break;
     160        case ReplacementMethodEnum.Noise:
     161          var avg = rows.Select(r => originalValues[r]).Average();
     162          var stdDev = rows.Select(r => originalValues[r]).StandardDeviation();
     163          rand = new FastRandom(31415);
     164          replacementValues = rows.Select(_ => NormalDistributedRandom.NextDouble(rand, avg, stdDev)).ToList();
     165          break;
     166
    148167        default:
    149168          throw new ArgumentException(string.Format("ReplacementMethod {0} cannot be handled.", replacement));
    150169      }
    151170
    152       dataset.ReplaceVariable(variable, Enumerable.Repeat(replacementValue, dataset.Rows).ToList());
     171      dataset.ReplaceVariable(variable, replacementValues);
    153172      //mkommend: ToList is used on purpose to avoid lazy evaluation that could result in wrong estimates due to variable replacements
    154173      var estimates = model.GetEstimatedValues(dataset, rows).ToList();
  • stable/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/IDataAnalysisProblemData.cs

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

    r12009 r14022  
    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}
  • stable/HeuristicLab.Problems.DataAnalysis/3.4/Plugin.cs.frame

    r13316 r14022  
    3838  [PluginDependency("HeuristicLab.Persistence", "3.3")]
    3939  [PluginDependency("HeuristicLab.Problems.Instances", "3.3")] 
     40  [PluginDependency("HeuristicLab.Random", "3.3")]
    4041  public class HeuristicLabProblemsDataAnalysisPlugin : PluginBase {
    4142  }
Note: See TracChangeset for help on using the changeset viewer.