Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/01/21 18:33:07 (4 years ago)
Author:
pfleck
Message:

#3040 First draft additional vector aggregation symbols (distribution characteristics & time series dynamics)

File:
1 copied

Legend:

Unmodified
Added
Removed
  • branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/TypeCoherentVectorTimeSeriesExpressionGrammar.cs

    r17824 r17830  
    2929
    3030namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    31   [StorableType("7EC7B4A7-0E27-4011-B983-B0E15A6944EC")]
    32   [Item("TypeCoherentVectorExpressionGrammar", "Represents a grammar for functional expressions in which special syntactic constraints are enforced so that vector and scalar expressions are not mixed.")]
    33   public class TypeCoherentVectorExpressionGrammar : DataAnalysisGrammar, ISymbolicDataAnalysisGrammar {
     31  [StorableType("88895D71-3D3F-44A7-A531-D5D59963AABE")]
     32  [Item("TypeCoherentVectorTimeSeriesExpressionGrammar", "Represents a grammar for functional expressions in which special syntactic constraints are enforced so that vector and scalar expressions are not mixed.")]
     33  public class TypeCoherentVectorTimeSeriesExpressionGrammar : DataAnalysisGrammar, ISymbolicDataAnalysisGrammar {
    3434    private const string ArithmeticFunctionsName = "Arithmetic Functions";
    3535    private const string TrigonometricFunctionsName = "Trigonometric Functions";
     
    4040    private const string VectorStatisticsName = "Vector Statistics";
    4141    private const string VectorDistancesName = "Vector Distances";
     42    private const string VectorDistributionCharacteristicsName = "Distribution Characteristics";
     43    private const string VectorTimeSeriesDynamicsName = "Time Series Dynamics";
    4244    private const string ScalarSymbolsName = "Scalar Symbols";
    4345
     
    5456
    5557    [StorableConstructor]
    56     protected TypeCoherentVectorExpressionGrammar(StorableConstructorFlag _) : base(_) { }
    57     protected TypeCoherentVectorExpressionGrammar(TypeCoherentVectorExpressionGrammar original, Cloner cloner) : base(original, cloner) { }
    58     public TypeCoherentVectorExpressionGrammar()
    59       : base(ItemAttribute.GetName(typeof(TypeCoherentVectorExpressionGrammar)), ItemAttribute.GetDescription(typeof(TypeCoherentVectorExpressionGrammar))) {
     58    protected TypeCoherentVectorTimeSeriesExpressionGrammar(StorableConstructorFlag _) : base(_) { }
     59    protected TypeCoherentVectorTimeSeriesExpressionGrammar(TypeCoherentVectorTimeSeriesExpressionGrammar original, Cloner cloner) : base(original, cloner) { }
     60    public TypeCoherentVectorTimeSeriesExpressionGrammar()
     61      : base(ItemAttribute.GetName(typeof(TypeCoherentVectorTimeSeriesExpressionGrammar)), ItemAttribute.GetDescription(typeof(TypeCoherentVectorTimeSeriesExpressionGrammar))) {
    6062      Initialize();
    6163    }
    6264    public override IDeepCloneable Clone(Cloner cloner) {
    63       return new TypeCoherentVectorExpressionGrammar(this, cloner);
     65      return new TypeCoherentVectorTimeSeriesExpressionGrammar(this, cloner);
    6466    }
    6567
     
    8688
    8789      var constant = new Constant { MinValue = -20, MaxValue = 20 };
     90      var constantZeroToOne = new Constant { Name = "Constant [0-1]", MinValue = 0, MaxValue = 1 };
    8891      var variable = new Variable();
    8992      var binFactorVariable = new BinaryFactorVariable();
     
    9194
    9295      var mean = new Mean();
     96      var median = new Median() { Enabled = false };
    9397      var sd = new StandardDeviation();
    9498      var sum = new Sum();
     
    96100      var min = new Min() { Enabled = false };
    97101      var max = new Max() { Enabled = false };
     102      var quantile = new Quantile() { Enabled = false };
    98103      var variance = new Variance() { Enabled = false };
    99104      var skewness = new Skewness() { Enabled = false };
     
    124129
    125130      var vectorvariable = new Variable() { Name = "Vector Variable" };
     131
     132      #region TimeSeries Symbols
     133      var absoluteEnergy = new AbsoluteEnergy() { Enabled = false };
     134      var binnedEntropy = new BinnedEntropy() { Enabled = false };
     135      var hasLargeStandardDeviation = new HasLargeStandardDeviation() { Enabled = false };
     136      var hasVarianceLargerThanStd = new HasVarianceLargerThanStd() { Enabled = false };
     137      var isSymmetricLooking = new IsSymmetricLooking() { Enabled = false };
     138      var numberDataPointsAboveMean = new NumberDataPointsAboveMean() { Enabled = false };
     139      var numberDataPointsAboveMedian = new NumberDataPointsAboveMedian() { Enabled = false };
     140      var numberDataPointsBelowMean = new NumberDataPointsBelowMean() { Enabled = false };
     141      var numberDataPointsBelowMedian = new NumberDataPointsBelowMedian() { Enabled = false };
     142
     143      var arimaModelCoefficients = new ArimaModelCoefficients() { Enabled = false };
     144      var continuousWaveletTransformationCoefficients = new ContinuousWaveletTransformationCoefficients() { Enabled = false };
     145      var fastFourierTransformationCoefficient = new FastFourierTransformationCoefficient() { Enabled = false };
     146      var firstIndexMax = new FirstIndexMax() { Enabled = false };
     147      var firstIndexMin = new FirstIndexMin() { Enabled = false };
     148      var lastIndexMax = new LastIndexMax() { Enabled = false };
     149      var lastIndexMin = new LastIndexMin() { Enabled = false };
     150      var longestStrikeAboveMean = new LongestStrikeAboveMean() { Enabled = false };
     151      var longestStrikeAboveMedian = new LongestStrikeAboveMedian() { Enabled = false };
     152      var longestStrikeBelowMean = new LongestStrikeBelowMean() { Enabled = false };
     153      var longestStrikeBelowMedian = new LongestStrikeBelowMedian() { Enabled = false };
     154      var longestStrikePositive = new LongestStrikePositive() { Enabled = false };
     155      var longestStrikeNegative = new LongestStrikeNegative() { Enabled = false };
     156      var longestStrikeZero = new LongestStrikeZero() { Enabled = false };
     157      var meanAbsoluteChange = new MeanAbsoluteChange() { Enabled = false };
     158      var meanAbsoluteChangeQuantiles = new MeanAbsoluteChangeQuantiles() { Enabled = false };
     159      var meanAutocorrelation = new MeanAutocorrelation() { Enabled = false };
     160      var laggedAutocorrelation = new LaggedAutocorrelation() { Enabled = false };
     161      var meanSecondDerivateCentral = new MeanSecondDerivateCentral() { Enabled = false };
     162      var numberPeaksOfSize = new NumberPeaksOfSize() { Enabled = false };
     163      var largeNumberOfPeaks = new LargeNumberOfPeaks() { Enabled = false };
     164      var timeReversalAsymmetryStatistic = new TimeReversalAsymmetryStatistic() { Enabled = false };
     165      #endregion
    126166      #endregion
    127167
     
    135175      var exponentialAndLogarithmicSymbols = new GroupSymbol(ExponentialFunctionsName, new List<ISymbol> { exp, log });
    136176      var powerSymbols = new GroupSymbol(PowerFunctionsName, new List<ISymbol> { square, sqrt, cube, cubeRoot, power, root });
    137       var terminalSymbols = new GroupSymbol(TerminalsName, new List<ISymbol> { constant, variable, binFactorVariable, factorVariable });
    138       var statisticsSymbols = new GroupSymbol(VectorStatisticsName, new List<ISymbol> { mean, sd, sum, length, min, max, variance, skewness, kurtosis });
     177      var terminalSymbols = new GroupSymbol(TerminalsName, new List<ISymbol> { constant, constantZeroToOne, variable, binFactorVariable, factorVariable });
     178      var statisticsSymbols = new GroupSymbol(VectorStatisticsName, new List<ISymbol> { mean, median, sd, sum, length, min, max, quantile, variance, skewness, kurtosis });
    139179      var distancesSymbols = new GroupSymbol(VectorDistancesName, new List<ISymbol> { euclideanDistance, covariance });
    140       var aggregationSymbols = new GroupSymbol(VectorAggregationName, new List<ISymbol> { statisticsSymbols, distancesSymbols });
     180      var distributionCharacteristicsSymbols = new GroupSymbol(VectorDistributionCharacteristicsName, new List<ISymbol> {
     181        absoluteEnergy, binnedEntropy, hasLargeStandardDeviation, hasVarianceLargerThanStd, isSymmetricLooking,
     182        numberDataPointsAboveMean, numberDataPointsAboveMedian, numberDataPointsBelowMean, numberDataPointsBelowMedian
     183      });
     184      var timeSeriesDynamicsSymbols = new GroupSymbol(VectorTimeSeriesDynamicsName, new List<ISymbol> {
     185        arimaModelCoefficients, continuousWaveletTransformationCoefficients, fastFourierTransformationCoefficient,
     186        firstIndexMax, firstIndexMin, lastIndexMax, lastIndexMin,
     187        longestStrikeAboveMean, longestStrikeAboveMedian, longestStrikeBelowMean, longestStrikeBelowMedian, longestStrikePositive, longestStrikePositive, longestStrikeNegative, longestStrikeZero,
     188        meanAbsoluteChange, meanAbsoluteChangeQuantiles, meanAutocorrelation, laggedAutocorrelation, meanSecondDerivateCentral, meanSecondDerivateCentral,
     189        numberPeaksOfSize, largeNumberOfPeaks, timeReversalAsymmetryStatistic
     190      });
     191      var aggregationSymbols = new GroupSymbol(VectorAggregationName, new List<ISymbol> { statisticsSymbols, distancesSymbols, distributionCharacteristicsSymbols, timeSeriesDynamicsSymbols });
    141192      var scalarSymbols = new GroupSymbol(ScalarSymbolsName, new List<ISymbol>() { arithmeticSymbols, trigonometricSymbols, exponentialAndLogarithmicSymbols, powerSymbols, terminalSymbols, aggregationSymbols });
    142193
     
    170221      SetSubtreeCount(exponentialAndLogarithmicSymbols, 1, 1);
    171222      SetSubtreeCount(terminalSymbols, 0, 0);
    172       SetSubtreeCount(statisticsSymbols, 1, 1);
     223      foreach (var sy in new Symbol[] { mean, median, sd, sum, length, min, max, variance, skewness, kurtosis })
     224        SetSubtreeCount(sy, 1, 1);
     225      SetSubtreeCount(quantile, 2, 2);
    173226      SetSubtreeCount(distancesSymbols, 2, 2);
     227      #region TimeSeries symbols
     228      foreach (var sy in new Symbol[] {
     229        absoluteEnergy, hasLargeStandardDeviation, hasVarianceLargerThanStd, isSymmetricLooking,
     230         numberDataPointsAboveMean, numberDataPointsAboveMedian, numberDataPointsBelowMean, numberDataPointsBelowMedian
     231      }) SetSubtreeCount(sy, 1, 1);
     232      foreach (var sy in new Symbol[] { binnedEntropy })
     233        SetSubtreeCount(sy, 2, 2);
     234
     235      foreach (var sy in new Symbol[] {
     236        firstIndexMax, firstIndexMin, lastIndexMax, lastIndexMin,
     237        longestStrikeAboveMean, longestStrikeAboveMedian, longestStrikeBelowMean, longestStrikeBelowMedian,
     238        longestStrikePositive, longestStrikeNegative, longestStrikeZero,
     239        meanAbsoluteChange, meanAutocorrelation, meanSecondDerivateCentral
     240      }) SetSubtreeCount(sy, 1, 1);
     241      foreach (var sy in new Symbol[] {
     242        fastFourierTransformationCoefficient, laggedAutocorrelation, numberPeaksOfSize, timeReversalAsymmetryStatistic
     243      }) SetSubtreeCount(sy, 2, 2);
     244      foreach (var sy in new Symbol[] {
     245        arimaModelCoefficients, continuousWaveletTransformationCoefficients,
     246        meanAbsoluteChangeQuantiles, largeNumberOfPeaks
     247      }) SetSubtreeCount(sy, 3, 3);
     248      #endregion
    174249
    175250      SetSubtreeCount(vectorarithmeticSymbols, 2, 2);
     
    197272      AddAllowedChildSymbol(power, constant, 1);
    198273      AddAllowedChildSymbol(root, constant, 1);
    199       AddAllowedChildSymbol(aggregationSymbols, vectorSymbols);
    200       AddAllowedChildSymbol(statisticsSymbols, subvector);
     274      AddAllowedChildSymbol(aggregationSymbols, vectorSymbols, 0);
     275      AddAllowedChildSymbol(statisticsSymbols, subvector, 0);
     276      AddAllowedChildSymbol(quantile, constantZeroToOne, 1);
     277      AddAllowedChildSymbol(distancesSymbols, vectorSymbols, 1);
     278      AddAllowedChildSymbol(distributionCharacteristicsSymbols, vectorSymbols, 0);
     279      AddAllowedChildSymbol(distributionCharacteristicsSymbols, subvector, 0);
     280      AddAllowedChildSymbol(distributionCharacteristicsSymbols, constantZeroToOne, 1);
     281      AddAllowedChildSymbol(timeSeriesDynamicsSymbols, vectorSymbols, 0);
     282      AddAllowedChildSymbol(timeSeriesDynamicsSymbols, subvector, 0);
     283      AddAllowedChildSymbol(timeSeriesDynamicsSymbols, constantZeroToOne, 1);
     284      AddAllowedChildSymbol(timeSeriesDynamicsSymbols, constantZeroToOne, 2);
    201285
    202286      AddAllowedChildSymbol(vectorarithmeticSymbols, vectorSymbols);
     
    205289      AddAllowedChildSymbol(vectorexponentialAndLogarithmicSymbols, vectorSymbols);
    206290      AddAllowedChildSymbol(vectorpowerSymbols, vectorSymbols, 0);
    207       AddAllowedChildSymbol(vectorpower, constant, 1);
    208       AddAllowedChildSymbol(vectorroot, constant, 1);
     291      AddAllowedChildSymbol(vectorpower, constantZeroToOne, 1);
     292      AddAllowedChildSymbol(vectorroot, constantZeroToOne, 1);
    209293
    210294      AddAllowedChildSymbol(subvector, vectorSymbols);
Note: See TracChangeset for help on using the changeset viewer.