- Timestamp:
- 08/09/12 15:01:35 (12 years ago)
- Location:
- branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis/3.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/TimeSeriesPrognosis/TimeSeriesPrognosisProblemData.cs
r8459 r8460 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Linq;25 24 using HeuristicLab.Common; 26 25 using HeuristicLab.Core; … … 32 31 [StorableClass] 33 32 [Item("TimeSeriesPrognosisProblemData", "Represents an item containing all data defining a time series prognosis problem.")] 34 public class TimeSeriesPrognosisProblemData : DataAnalysisProblemData, ITimeSeriesPrognosisProblemData { 35 protected const string TargetVariableParameterName = "TargetVariable"; 36 33 public class TimeSeriesPrognosisProblemData : RegressionProblemData, ITimeSeriesPrognosisProblemData { 37 34 #region default data 38 35 private static double[,] mackey_glass_17 = new double[,] { … … 1550 1547 #endregion 1551 1548 1552 public ConstrainedValueParameter<StringValue> TargetVariableParameter { 1553 get { return (ConstrainedValueParameter<StringValue>)Parameters[TargetVariableParameterName]; } 1549 private const string TrainingHorizonParameterName = "Training Horizon"; 1550 private const string TestHorizonParameterName = "Test Horizon"; 1551 1552 public IFixedValueParameter<IntValue> TrainingHorizonParameter { 1553 get { return (IFixedValueParameter<IntValue>)Parameters[TrainingHorizonParameterName]; } 1554 1554 } 1555 public string TargetVariable{1556 get { return TargetVariableParameter.Value.Value; }1555 public IFixedValueParameter<IntValue> TestHorizonParameter { 1556 get { return (IFixedValueParameter<IntValue>)Parameters[TestHorizonParameterName]; } 1557 1557 } 1558 1559 #region Properties 1560 public int TrainingHorizon { 1561 get { return TrainingHorizonParameter.Value.Value; } 1562 set { TrainingHorizonParameter.Value.Value = value; } 1563 } 1564 1565 public int TestHorizon { 1566 get { return TestHorizonParameter.Value.Value; } 1567 set { TestHorizonParameter.Value.Value = value; } 1568 } 1569 #endregion 1558 1570 1559 1571 [StorableConstructor] 1560 1572 protected TimeSeriesPrognosisProblemData(bool deserializing) : base(deserializing) { } 1561 [StorableHook(HookType.AfterDeserialization)]1562 private void AfterDeserialization() {1563 RegisterParameterEvents();1564 }1565 1573 1566 protected TimeSeriesPrognosisProblemData(TimeSeriesPrognosisProblemData original, Cloner cloner) 1567 : base(original, cloner) { 1568 RegisterParameterEvents(); 1569 } 1574 protected TimeSeriesPrognosisProblemData(TimeSeriesPrognosisProblemData original, Cloner cloner) : base(original, cloner) { } 1570 1575 public override IDeepCloneable Clone(Cloner cloner) { 1571 1576 return new TimeSeriesPrognosisProblemData(this, cloner); 1572 1577 } 1573 1578 1574 public TimeSeriesPrognosisProblemData() 1575 : this(defaultDataset, defaultAllowedInputVariables, defaultTargetVariable) { 1579 public TimeSeriesPrognosisProblemData() : this(defaultDataset, defaultAllowedInputVariables, defaultTargetVariable) { } 1580 public TimeSeriesPrognosisProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable) 1581 : base(dataset, allowedInputVariables, targetVariable) { 1582 Parameters.Add(new FixedValueParameter<IntValue>(TrainingHorizonParameterName, "Specifies the horizon (how far the prognosis reaches in the future) for each training sample.", new IntValue(1))); 1583 Parameters.Add(new FixedValueParameter<IntValue>(TestHorizonParameterName, "Specifies the horizon (how far the prognosis reaches in the future) for each test sample.", new IntValue(1))); 1584 1585 TrainingHorizonParameter.Hidden = true; 1586 TestHorizonParameter.Hidden = true; 1587 1588 RegisterParameterEventHandlers(); 1576 1589 } 1577 1590 1578 public TimeSeriesPrognosisProblemData(Dataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable) 1579 : base(dataset, allowedInputVariables) { 1580 var variables = InputVariables.Select(x => x.AsReadOnly()).ToList(); 1581 Parameters.Add(new ConstrainedValueParameter<StringValue>(TargetVariableParameterName, new ItemSet<StringValue>(variables), variables.First(x => x.Value == targetVariable))); 1582 RegisterParameterEvents(); 1591 [StorableHook(HookType.AfterDeserialization)] 1592 private void AfterDeserialization() { 1593 RegisterParameterEventHandlers(); 1583 1594 } 1584 1595 1585 private void RegisterParameterEvents() { 1586 TargetVariableParameter.ValueChanged += new EventHandler(TargetVariableParameter_ValueChanged); 1596 private void RegisterParameterEventHandlers() { 1597 TrainingHorizonParameter.Value.ValueChanged += new System.EventHandler(Parameter_ValueChanged); 1598 TestHorizonParameter.Value.ValueChanged += new System.EventHandler(Parameter_ValueChanged); 1587 1599 } 1588 private void TargetVariableParameter_ValueChanged(object sender, EventArgs e) { 1600 1601 private void Parameter_ValueChanged(object sender, EventArgs e) { 1589 1602 OnChanged(); 1590 1603 } 1604 1591 1605 } 1592 1606 } -
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/TimeSeriesPrognosis/ITimeSeriesPrognosisProblemData.cs
r8458 r8460 22 22 namespace HeuristicLab.Problems.DataAnalysis { 23 23 public interface ITimeSeriesPrognosisProblemData : IRegressionProblemData { 24 int TrainingHorizon { get; set; } 25 int TestHorizon { get; set; } 24 26 } 25 27 }
Note: See TracChangeset
for help on using the changeset viewer.