Changeset 8460


Ignore:
Timestamp:
08/09/12 15:01:35 (9 years ago)
Author:
mkommend
Message:

#1081: Added horizon parameters to timeseries problem data.

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  
    2222using System;
    2323using System.Collections.Generic;
    24 using System.Linq;
    2524using HeuristicLab.Common;
    2625using HeuristicLab.Core;
     
    3231  [StorableClass]
    3332  [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 {
    3734    #region default data
    3835    private static double[,] mackey_glass_17 = new double[,] {
     
    15501547    #endregion
    15511548
    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]; }
    15541554    }
    1555     public string TargetVariable {
    1556       get { return TargetVariableParameter.Value.Value; }
     1555    public IFixedValueParameter<IntValue> TestHorizonParameter {
     1556      get { return (IFixedValueParameter<IntValue>)Parameters[TestHorizonParameterName]; }
    15571557    }
     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
    15581570
    15591571    [StorableConstructor]
    15601572    protected TimeSeriesPrognosisProblemData(bool deserializing) : base(deserializing) { }
    1561     [StorableHook(HookType.AfterDeserialization)]
    1562     private void AfterDeserialization() {
    1563       RegisterParameterEvents();
    1564     }
    15651573
    1566     protected TimeSeriesPrognosisProblemData(TimeSeriesPrognosisProblemData original, Cloner cloner)
    1567       : base(original, cloner) {
    1568       RegisterParameterEvents();
    1569     }
     1574    protected TimeSeriesPrognosisProblemData(TimeSeriesPrognosisProblemData original, Cloner cloner) : base(original, cloner) { }
    15701575    public override IDeepCloneable Clone(Cloner cloner) {
    15711576      return new TimeSeriesPrognosisProblemData(this, cloner);
    15721577    }
    15731578
    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();
    15761589    }
    15771590
    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();
    15831594    }
    15841595
    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);
    15871599    }
    1588     private void TargetVariableParameter_ValueChanged(object sender, EventArgs e) {
     1600
     1601    private void Parameter_ValueChanged(object sender, EventArgs e) {
    15891602      OnChanged();
    15901603    }
     1604
    15911605  }
    15921606}
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/TimeSeriesPrognosis/ITimeSeriesPrognosisProblemData.cs

    r8458 r8460  
    2222namespace HeuristicLab.Problems.DataAnalysis {
    2323  public interface ITimeSeriesPrognosisProblemData : IRegressionProblemData {
     24    int TrainingHorizon { get; set; }
     25    int TestHorizon { get; set; }
    2426  }
    2527}
Note: See TracChangeset for help on using the changeset viewer.