Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/09/12 14:36:46 (12 years ago)
Author:
mkommend
Message:

#1081: Code clean up in time series prognosis model and problem data.

Location:
branches/HeuristicLab.TimeSeries
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic.TimeSeriesPrognosis/3.4/SymbolicTimeSeriesPrognosisModel.cs

    r8458 r8459  
    4949    public SymbolicTimeSeriesPrognosisModel(ISymbolicExpressionTree tree, ISymbolicTimeSeriesPrognosisExpressionTreeInterpreter interpreter, double lowerLimit = double.MinValue, double upperLimit = double.MaxValue) : base(tree, interpreter, lowerLimit, upperLimit) { }
    5050
    51 
    52 
    5351    public IEnumerable<IEnumerable<double>> GetPrognosedValues(Dataset dataset, IEnumerable<int> rows, IEnumerable<int> horizons) {
    5452      var estimatedValues = Interpreter.GetSymbolicExpressionTreeValues(SymbolicExpressionTree, dataset, rows, horizons);
     
    6260      return CreateTimeSeriesPrognosisSolution(problemData);
    6361    }
    64 
    65     //public static void Scale(SymbolicTimeSeriesPrognosisModel model, ITimeSeriesPrognosisProblemData problemData, IEnumerable<int> rows) {
    66     //  var dataset = problemData.Dataset;
    67     //  var targetVariable = problemData.TargetVariable;
    68     //  var estimatedValues = model.Interpreter.GetSymbolicExpressionTreeValues(model.SymbolicExpressionTree, dataset, rows);
    69     //  var boundedEstimatedValues = estimatedValues.LimitToRange(model.lowerEstimationLimit, model.upperEstimationLimit);
    70     //  var targetValues = problemData.Dataset.GetDoubleValues(targetVariable, rows);
    71 
    72     //  double alpha, beta;
    73     //  OnlineCalculatorError error;
    74     //  OnlineLinearScalingParameterCalculator.Calculate(boundedEstimatedValues, targetValues, out alpha, out beta, out error);
    75     //  if (error != OnlineCalculatorError.None) return;
    76 
    77     //  ConstantTreeNode alphaTreeNode = null;
    78     //  ConstantTreeNode betaTreeNode = null;
    79     //  // check if model has been scaled previously by analyzing the structure of the tree
    80     //  var startNode = model.SymbolicExpressionTree.Root.GetSubtree(0);
    81     //  if (startNode.GetSubtree(0).Symbol is Addition) {
    82     //    var addNode = startNode.GetSubtree(0);
    83     //    if (addNode.SubtreeCount == 2 && addNode.GetSubtree(0).Symbol is Multiplication && addNode.GetSubtree(1).Symbol is Constant) {
    84     //      alphaTreeNode = addNode.GetSubtree(1) as ConstantTreeNode;
    85     //      var mulNode = addNode.GetSubtree(0);
    86     //      if (mulNode.SubtreeCount == 2 && mulNode.GetSubtree(1).Symbol is Constant) {
    87     //        betaTreeNode = mulNode.GetSubtree(1) as ConstantTreeNode;
    88     //      }
    89     //    }
    90     //  }
    91     //  // if tree structure matches the structure necessary for linear scaling then reuse the existing tree nodes
    92     //  if (alphaTreeNode != null && betaTreeNode != null) {
    93     //    betaTreeNode.Value *= beta;
    94     //    alphaTreeNode.Value *= beta;
    95     //    alphaTreeNode.Value += alpha;
    96     //  } else {
    97     //    var mainBranch = startNode.GetSubtree(0);
    98     //    startNode.RemoveSubtree(0);
    99     //    var scaledMainBranch = MakeSum(MakeProduct(mainBranch, beta), alpha);
    100     //    startNode.AddSubtree(scaledMainBranch);
    101     //  }
    102     //}
    103 
    104     //private static ISymbolicExpressionTreeNode MakeSum(ISymbolicExpressionTreeNode treeNode, double alpha) {
    105     //  if (alpha.IsAlmost(0.0)) {
    106     //    return treeNode;
    107     //  } else {
    108     //    var addition = new Addition();
    109     //    var node = addition.CreateTreeNode();
    110     //    var alphaConst = MakeConstant(alpha);
    111     //    node.AddSubtree(treeNode);
    112     //    node.AddSubtree(alphaConst);
    113     //    return node;
    114     //  }
    115     //}
    116 
    117     //private static ISymbolicExpressionTreeNode MakeProduct(ISymbolicExpressionTreeNode treeNode, double beta) {
    118     //  if (beta.IsAlmost(1.0)) {
    119     //    return treeNode;
    120     //  } else {
    121     //    var multipliciation = new Multiplication();
    122     //    var node = multipliciation.CreateTreeNode();
    123     //    var betaConst = MakeConstant(beta);
    124     //    node.AddSubtree(treeNode);
    125     //    node.AddSubtree(betaConst);
    126     //    return node;
    127     //  }
    128     //}
    129 
    130     //private static ISymbolicExpressionTreeNode MakeConstant(double c) {
    131     //  var node = (ConstantTreeNode)(new Constant()).CreateTreeNode();
    132     //  node.Value = c;
    133     //  return node;
    134     //}
    13562  }
    13663}
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisProblemData.cs

    r7989 r8459  
    15421542    private static readonly string defaultTargetVariable;
    15431543
    1544     private static readonly TimeSeriesPrognosisProblemData emptyProblemData;
    1545     public static TimeSeriesPrognosisProblemData EmptyProblemData {
    1546       get { return emptyProblemData; }
    1547     }
    1548 
    15491544    static TimeSeriesPrognosisProblemData() {
    15501545      defaultDataset = new Dataset(new string[] { "x" }, mackey_glass_17);
     
    15521547      defaultAllowedInputVariables = new List<string>() { "x" };
    15531548      defaultTargetVariable = "x";
    1554 
    1555       var problemData = new TimeSeriesPrognosisProblemData();
    1556       problemData.Parameters.Clear();
    1557       problemData.Name = "Empty Time-Series Prognosis ProblemData";
    1558       problemData.Description = "This ProblemData acts as place holder before the correct problem data is loaded.";
    1559       problemData.isEmpty = true;
    1560 
    1561       problemData.Parameters.Add(new FixedValueParameter<Dataset>(DatasetParameterName, "", new Dataset()));
    1562       problemData.Parameters.Add(new FixedValueParameter<ReadOnlyCheckedItemList<StringValue>>(InputVariablesParameterName, ""));
    1563       problemData.Parameters.Add(new FixedValueParameter<IntRange>(TrainingPartitionParameterName, "", (IntRange)new IntRange(0, 0).AsReadOnly()));
    1564       problemData.Parameters.Add(new FixedValueParameter<IntRange>(TestPartitionParameterName, "", (IntRange)new IntRange(0, 0).AsReadOnly()));
    1565       problemData.Parameters.Add(new ConstrainedValueParameter<StringValue>(TargetVariableParameterName, new ItemSet<StringValue>()));
    1566       emptyProblemData = problemData;
    15671549    }
    15681550    #endregion
     
    15871569    }
    15881570    public override IDeepCloneable Clone(Cloner cloner) {
    1589       if (this == emptyProblemData) return emptyProblemData;
    15901571      return new TimeSeriesPrognosisProblemData(this, cloner);
    15911572    }
Note: See TracChangeset for help on using the changeset viewer.