Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17741


Ignore:
Timestamp:
09/10/20 09:57:02 (4 years ago)
Author:
pfleck
Message:

#3040 Added new benchmark and some minor bugfixes.

Location:
branches/3040_VectorBasedGP
Files:
7 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/3040_VectorBasedGP/HeuristicLab.Common/3.3/Statistics/EnumerableStatisticExtensions.cs

    r17721 r17741  
    230230      if (min > max) throw new ArgumentException(string.Format("Minimum {0} is larger than maximum {1}.", min, max));
    231231      foreach (var x in values) {
    232         /*if (double.IsNaN(x)) yield return (max + min) / 2.0;
    233         else */
    234         if (x < min) yield return min;
     232        if (double.IsNaN(x)) yield return (max + min) / 2.0;
     233        else if (x < min) yield return min;
    235234        else if (x > max) yield return max;
    236235        else yield return x;
  • branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/SymbolicRegressionSingleObjectiveProblem.cs

    r17180 r17741  
    118118
    119119    private void UpdateEstimationLimits() {
    120       if (ProblemData.TrainingIndices.Any()) {
     120      if (ProblemData.TrainingIndices.Any() && ProblemData.Dataset.VariableHasType<double>(ProblemData.TargetVariable)) {
    121121        var targetValues = ProblemData.Dataset.GetDoubleValues(ProblemData.TargetVariable, ProblemData.TrainingIndices).ToList();
    122122        var mean = targetValues.Average();
  • branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis/3.4/ModifiableDataset.cs

    r17180 r17741  
    141141      if (values.Count != variableValues[variableName].Count)
    142142        throw new ArgumentException("The number of values must coincide with the number of dataset rows.");
    143       if (GetVariableType(variableName) != values[0].GetType())
     143      //if (GetVariableType(variableName) != values[0].GetType())
     144      if (!GetVariableType(variableName).IsInstanceOfType(values[0]))
    144145        throw new ArgumentException("The type of the provided value does not match the variable type.");
    145146      variableValues[variableName] = values;
  • branches/3040_VectorBasedGP/HeuristicLab.Problems.Instances.DataAnalysis/3.3/HeuristicLab.Problems.Instances.DataAnalysis-3.3.csproj

    r17588 r17741  
    262262    <Compile Include="Regression\VectorData\RandomExtensions.cs" />
    263263    <Compile Include="Regression\VectorData\VectorDataInstanceProvider.cs" />
     264    <Compile Include="Regression\VectorData\VectorDataTestFour.cs" />
    264265    <Compile Include="Regression\VectorData\VectorDataTestThree.cs" />
    265266    <Compile Include="Regression\VectorData\VectorDataTestTwo.cs" />
  • branches/3040_VectorBasedGP/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/VectorData/AzzaliBenchmark3.cs

    r17721 r17741  
    2828using HeuristicLab.Problems.DataAnalysis;
    2929using HeuristicLab.Random;
    30 
     30using MathNet.Numerics.Statistics;
    3131using DoubleVector = MathNet.Numerics.LinearAlgebra.Vector<double>;
    3232
     
    3838    protected override string TargetVariable { get { return "B3"; } }
    3939    protected override string[] VariableNames { get { return AllowedInputVariables.Concat(new[] { TargetVariable }).ToArray(); } }
    40     protected override string[] AllowedInputVariables { get { return new string[] { "X1", "X2", "X3", "X4" }; } }
     40    protected override string[] AllowedInputVariables { get { return new string[] { "X1", "X2", "X3", "X4", "X5" }; } }
    4141    protected override int TrainingPartitionStart { get { return 0; } }
    4242    protected override int TrainingPartitionEnd { get { return 70; } }
     
    8585        x3Column.Add(x3);
    8686        x4Column.Add(x4);
     87        x5Column.Add(x5);
    8788        b3Column.Add(b3);
    8889      }
  • branches/3040_VectorBasedGP/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/VectorData/AzzaliKorns5.cs

    r17448 r17741  
    2828using HeuristicLab.Problems.DataAnalysis;
    2929using HeuristicLab.Random;
    30 
     30using MathNet.Numerics.Statistics;
    3131using DoubleVector = MathNet.Numerics.LinearAlgebra.Vector<double>;
    3232
  • branches/3040_VectorBasedGP/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/VectorData/VectorDataInstanceProvider.cs

    r17588 r17741  
    6262        new VectorDataTestThreeC(rand.Next()),
    6363        new VectorDataTestThreeD(rand.Next()),
     64        new VectorDataTestFourA(rand.Next()),
     65        new VectorDataTestFourB(rand.Next()),
     66        new VectorDataTestFourC(rand.Next()),
     67        new VectorDataTestFourD(rand.Next()),
    6468        new AzzaliBenchmark1(rand.Next()),
    6569        new AzzaliBenchmark2(rand.Next()),
  • branches/3040_VectorBasedGP/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/VectorData/VectorDataTestFour.cs

    r17725 r17741  
    3030
    3131namespace HeuristicLab.Problems.Instances.DataAnalysis {
    32   public abstract class VectorDataTestOne : ArtificialRegressionDataDescriptor {
     32  public abstract class VectorDataTestFour : ArtificialRegressionDataDescriptor {
    3333
    34     protected const int Rows = 1000;
     34    protected const int Rows = 10000;
    3535
    3636    public override string Description { get { return ""; } }
    3737
    3838    protected override string TargetVariable { get { return "Y"; } }
    39     protected override string[] VariableNames { get { return new string[] { "X1", "X2", "X3", "V1", "V2", "Y" }; } }
    40     protected override string[] AllowedInputVariables { get { return new string[] { "X1", "X2", "X3", "V1", "V2" }; } }
     39    protected override string[] VariableNames { get { return new string[] { "X1", "X2", "X3", "X4", "X5", "V1", "V2", "V3", "V4", "V5", "Y" }; } }
     40    protected override string[] AllowedInputVariables { get { return new string[] { "X1", "X2", "X3", "X4", "X5", "V1", "V2", "V3", "V4", "V5" }; } }
    4141    protected override int TrainingPartitionStart { get { return 0; } }
    4242    protected override int TrainingPartitionEnd { get { return Rows * 3 / 4; } }
     
    4646    public int Seed { get; private set; }
    4747
    48     protected VectorDataTestOne()
     48    protected VectorDataTestFour()
    4949      : this((int)DateTime.Now.Ticks) { }
    50     protected VectorDataTestOne(int seed)
     50    protected VectorDataTestFour(int seed)
    5151      : base() {
    5252      Seed = seed;
     
    5858      var rand = new MersenneTwister((uint)Seed);
    5959
    60       double x1, x2, x3;
    61       DoubleVector v1, v2;
     60      double x1, x2, x3, x4, x5;
     61      DoubleVector v1, v2, v3, v4, v5;
    6262      double y;
    6363
     
    6565      var x2Column = new List<double>(Rows);
    6666      var x3Column = new List<double>(Rows);
     67      var x4Column = new List<double>(Rows);
     68      var x5Column = new List<double>(Rows);
    6769      var v1Column = new List<DoubleVector>(Rows);
    6870      var v2Column = new List<DoubleVector>(Rows);
     71      var v3Column = new List<DoubleVector>(Rows);
     72      var v4Column = new List<DoubleVector>(Rows);
     73      var v5Column = new List<DoubleVector>(Rows);
    6974      var yColumn = new List<double>(Rows);
    7075
     
    7479        x2 = rand.NextDouble(2, 6);
    7580        x3 = rand.NextDouble(0, 1);
    76         int v1Length = vectorLengths[0][i];
    77         int v2Length = vectorLengths[1][i];
    78         v1 = rand.NextDoubleVector(2, 6, v1Length);
    79         v2 = rand.NextDoubleVector(3, 5, v2Length);
     81        x4 = rand.NextDouble(30, 100);
     82        x5 = rand.NextDouble(150, 200);
     83        v1 = rand.NextDoubleVector(2, 6, vectorLengths[0][i]);
     84        v2 = rand.NextDoubleVector(3, 5, vectorLengths[1][i]);
     85        v3 = rand.NextDoubleVector(-10, 50, vectorLengths[2][i]);
     86        v4 = rand.NextDoubleVector(0, 200, vectorLengths[3][i]);
     87        v5 = rand.NextDoubleVector(200, 220, vectorLengths[4][i]);
    8088
    81         y = x1 * v1.Sum() + x2 * v2.Mean();
     89        var t1 = ((v1 + Math.Log(10 * x5)) * (v4 - 50 * v2.PointwiseSin()).Mean() * x1).Mean() / 10;  // mean 50
     90        var t2 = (v5.StandardDeviation() + v2.PointwisePower(2.0)).Mean();  // mean 18 + 6 = 24
     91        var t3 = Math.Exp(3 * x3) + v2.PointwiseMultiply(v3).Mean() / 10;     // mean 7 + 8 = 15
     92        y = t1 - 0.1 * t2 * t3;
    8293
    8394        x1Column.Add(x1);
    8495        x2Column.Add(x2);
    8596        x3Column.Add(x3);
     97        x4Column.Add(x4);
     98        x5Column.Add(x5);
    8699        v1Column.Add(v1);
    87100        v2Column.Add(v2);
     101        v3Column.Add(v3);
     102        v4Column.Add(v4);
     103        v5Column.Add(v5);
    88104        yColumn.Add(y);
    89105      }
    90106
    91       return new List<IList> { x1Column, x2Column, x3Column, v1Column, v2Column, yColumn };
     107      return new List<IList> {
     108        x1Column, x2Column, x3Column, x4Column, x5Column,
     109        v1Column, v2Column, v3Column, v4Column, v5Column,
     110        yColumn
     111      };
    92112    }
    93113
     
    95115  }
    96116
    97   public class VectorDataTestOneA : VectorDataTestOne {
     117  public class VectorDataTestFourA : VectorDataTestFour {
    98118    public override string Name {
    99       get { return "Vector Data Test - I [fully-constrained]: Y = X1 * sum(V1) + X2 * mean(V2)"; }
     119      get { return "Vector Data Test - IV [fully-constrained]: Y = X1 * sum(V1) + X2 * mean(V2)"; }
    100120    }
    101121
    102     public VectorDataTestOneA() : base() { }
    103     public VectorDataTestOneA(int seed) : base(seed) { }
     122    public VectorDataTestFourA() : base() { }
     123    public VectorDataTestFourA(int seed) : base(seed) { }
    104124
    105125    protected override List<int>[] GetVectorLengths(IRandom rand) {
    106126      // always same length
    107       const int length = 5;
    108       return new List<int>[2] {
     127      const int length = 40;
     128      return new List<int>[5] {
     129        Enumerable.Repeat(length, Rows).ToList(),
     130        Enumerable.Repeat(length, Rows).ToList(),
     131        Enumerable.Repeat(length, Rows).ToList(),
    109132        Enumerable.Repeat(length, Rows).ToList(),
    110133        Enumerable.Repeat(length, Rows).ToList()
     
    113136  }
    114137
    115   public class VectorDataTestOneB : VectorDataTestOne {
    116     public override string Name { get { return "Vector Data Test - I [row-constrained]: Y = X1 * sum(V1) + X2 * mean(V2)"; } }
     138  public class VectorDataTestFourB : VectorDataTestFour {
     139    public override string Name { get { return "Vector Data Test - IV [row-constrained]: Y = X1 * sum(V1) + X2 * mean(V2)"; } }
    117140
    118     public VectorDataTestOneB() : base() { }
    119     public VectorDataTestOneB(int seed) : base(seed) { }
     141    public VectorDataTestFourB() : base() { }
     142    public VectorDataTestFourB(int seed) : base(seed) { }
    120143
    121144    protected override List<int>[] GetVectorLengths(IRandom rand) {
    122       // length between length 4 and 8, same row always the same length
    123       var lengths = Enumerable.Range(0, Rows).Select(i => rand.Next(4, 8)).ToList();
    124       return new List<int>[2] {
     145      // length between length 40 and 80, same row always the same length
     146      var lengths = Enumerable.Range(0, Rows).Select(i => rand.Next(40, 80)).ToList();
     147      return new List<int>[5] {
     148        Enumerable.Range(0, Rows).Select(i => lengths[i]).ToList(),
     149        Enumerable.Range(0, Rows).Select(i => lengths[i]).ToList(),
     150        Enumerable.Range(0, Rows).Select(i => lengths[i]).ToList(),
    125151        Enumerable.Range(0, Rows).Select(i => lengths[i]).ToList(),
    126152        Enumerable.Range(0, Rows).Select(i => lengths[i]).ToList()
     
    129155  }
    130156
    131   public class VectorDataTestOneC : VectorDataTestOne {
    132     public override string Name { get { return "Vector Data Test - I [column-constrained]: Y = X1 * sum(V1) + X2 * mean(V2)"; } }
     157  public class VectorDataTestFourC : VectorDataTestFour {
     158    public override string Name { get { return "Vector Data Test - IV [column-constrained]: Y = X1 * sum(V1) + X2 * mean(V2)"; } }
    133159
    134     public VectorDataTestOneC() : base() { }
    135     public VectorDataTestOneC(int seed) : base(seed) { }
     160    public VectorDataTestFourC() : base() { }
     161    public VectorDataTestFourC(int seed) : base(seed) { }
    136162
    137163    protected override List<int>[] GetVectorLengths(IRandom rand) {
    138       // length between length 4 and 8; each feature is same length
    139       // force two different lengths
    140       int v1Length = rand.Next(4, 8);
     164      // length between length 40 and 80; each feature is same length
     165      int v1Length = rand.Next(40, 80);
    141166      int v2Length;
    142       do {
    143         v2Length = rand.Next(4, 8);
    144       } while (v1Length != v2Length);
    145       return new List<int>[2] {
     167      do { v2Length = rand.Next(40, 80); } while (v1Length != v2Length);
     168      int v3Length = rand.Next(40, 80);
     169      int v4Length;
     170      do { v4Length = rand.Next(40, 80); } while (v3Length != v4Length);
     171      int v5Length = rand.Next(40, 80);
     172      return new List<int>[5] {
    146173        Enumerable.Repeat(v1Length, Rows).ToList(),
    147         Enumerable.Repeat(v2Length, Rows).ToList()
     174        Enumerable.Repeat(v2Length, Rows).ToList(),
     175        Enumerable.Repeat(v3Length, Rows).ToList(),
     176        Enumerable.Repeat(v4Length, Rows).ToList(),
     177        Enumerable.Repeat(v5Length, Rows).ToList()
    148178      };
    149179    }
    150180  }
    151181
    152   public class VectorDataTestOneD : VectorDataTestOne {
    153     public override string Name { get { return "Vector Data Test - I [unconstrained]: Y = X1 * sum(V1) + X2 * mean(V2)"; } }
     182  public class VectorDataTestFourD : VectorDataTestFour {
     183    public override string Name { get { return "Vector Data Test - IV [unconstrained]: Y = X1 * sum(V1) + X2 * mean(V2)"; } }
    154184
    155     public VectorDataTestOneD() : base() { }
    156     public VectorDataTestOneD(int seed) : base(seed) { }
     185    public VectorDataTestFourD() : base() { }
     186    public VectorDataTestFourD(int seed) : base(seed) { }
    157187
    158188    protected override List<int>[] GetVectorLengths(IRandom rand) {
    159       // always random between 4 and 8
    160       return new List<int>[2] {
    161           Enumerable.Range(0, Rows).Select(i => rand.Next(4, 8)).ToList(),
    162           Enumerable.Range(0, Rows).Select(i => rand.Next(4, 8)).ToList()
    163         };
     189      // always random between 40 and 80
     190      return new List<int>[5] {
     191        Enumerable.Range(0, Rows).Select(i => rand.Next(40, 80)).ToList(),
     192        Enumerable.Range(0, Rows).Select(i => rand.Next(40, 80)).ToList(),
     193        Enumerable.Range(0, Rows).Select(i => rand.Next(40, 80)).ToList(),
     194        Enumerable.Range(0, Rows).Select(i => rand.Next(40, 80)).ToList(),
     195        Enumerable.Range(0, Rows).Select(i => rand.Next(40, 80)).ToList()
     196      };
    164197    }
    165198  }
Note: See TracChangeset for help on using the changeset viewer.