Changeset 8459 for branches/HeuristicLab.TimeSeries
- Timestamp:
- 08/09/12 14:36:46 (12 years ago)
- 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 49 49 public SymbolicTimeSeriesPrognosisModel(ISymbolicExpressionTree tree, ISymbolicTimeSeriesPrognosisExpressionTreeInterpreter interpreter, double lowerLimit = double.MinValue, double upperLimit = double.MaxValue) : base(tree, interpreter, lowerLimit, upperLimit) { } 50 50 51 52 53 51 public IEnumerable<IEnumerable<double>> GetPrognosedValues(Dataset dataset, IEnumerable<int> rows, IEnumerable<int> horizons) { 54 52 var estimatedValues = Interpreter.GetSymbolicExpressionTreeValues(SymbolicExpressionTree, dataset, rows, horizons); … … 62 60 return CreateTimeSeriesPrognosisSolution(problemData); 63 61 } 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 tree80 // 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 nodes92 // 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 //}135 62 } 136 63 } -
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisProblemData.cs
r7989 r8459 1542 1542 private static readonly string defaultTargetVariable; 1543 1543 1544 private static readonly TimeSeriesPrognosisProblemData emptyProblemData;1545 public static TimeSeriesPrognosisProblemData EmptyProblemData {1546 get { return emptyProblemData; }1547 }1548 1549 1544 static TimeSeriesPrognosisProblemData() { 1550 1545 defaultDataset = new Dataset(new string[] { "x" }, mackey_glass_17); … … 1552 1547 defaultAllowedInputVariables = new List<string>() { "x" }; 1553 1548 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;1567 1549 } 1568 1550 #endregion … … 1587 1569 } 1588 1570 public override IDeepCloneable Clone(Cloner cloner) { 1589 if (this == emptyProblemData) return emptyProblemData;1590 1571 return new TimeSeriesPrognosisProblemData(this, cloner); 1591 1572 }
Note: See TracChangeset
for help on using the changeset viewer.