Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/14/09 10:08:40 (15 years ago)
Author:
gkronber
Message:

Worked on SVR algorithm for time-series. #705

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.SupportVectorMachines/3.2/Predictor.cs

    r2328 r2347  
    4040    private Dictionary<string, int> variableNames = new Dictionary<string, int>();
    4141    private string targetVariable;
     42    private int minTimeOffset;
     43    private int maxTimeOffset;
    4244
    4345    public Predictor() : base() { } // for persistence
    4446
    45     public Predictor(SVMModel model, string targetVariable, Dictionary<string, int> variableNames)
     47    public Predictor(SVMModel model, string targetVariable, Dictionary<string, int> variableNames) :
     48      this(model, targetVariable, variableNames, 0, 0) {
     49    }
     50
     51    public Predictor(SVMModel model, string targetVariable, Dictionary<string, int> variableNames, int minTimeOffset, int maxTimeOffset)
    4652      : base() {
    4753      this.svmModel = model;
    4854      this.targetVariable = targetVariable;
    4955      this.variableNames = variableNames;
     56      this.minTimeOffset = minTimeOffset;
     57      this.maxTimeOffset = maxTimeOffset;
    5058    }
    5159
     
    6169      }
    6270
    63       Problem p = SVMHelper.CreateSVMProblem(input, input.GetVariableIndex(targetVariable), newIndex, start, end);
     71      Problem p = SVMHelper.CreateSVMProblem(input, input.GetVariableIndex(targetVariable), newIndex,
     72        start, end, minTimeOffset, maxTimeOffset);
    6473      Problem scaledProblem = SVM.Scaling.Scale(p, transform);
    6574
     
    8291      clone.targetVariable = targetVariable;
    8392      clone.variableNames = new Dictionary<string, int>(variableNames);
     93      clone.minTimeOffset = minTimeOffset;
     94      clone.maxTimeOffset = maxTimeOffset;
    8495      return clone;
    8596    }
     
    90101      targetVarAttr.Value = targetVariable;
    91102      node.Attributes.Append(targetVarAttr);
     103      XmlAttribute minTimeOffsetAttr = document.CreateAttribute("MinTimeOffset");
     104      XmlAttribute maxTimeOffsetAttr = document.CreateAttribute("MaxTimeOffset");
     105      minTimeOffsetAttr.Value = XmlConvert.ToString(minTimeOffset);
     106      maxTimeOffsetAttr.Value = XmlConvert.ToString(maxTimeOffset);
     107      node.Attributes.Append(minTimeOffsetAttr);
     108      node.Attributes.Append(maxTimeOffsetAttr);
    92109      node.AppendChild(PersistenceManager.Persist(svmModel, document, persistedObjects));
    93110      XmlNode variablesNode = document.CreateElement("Variables");
     
    111128      svmModel = (SVMModel)PersistenceManager.Restore(node.ChildNodes[0], restoredObjects);
    112129
     130      if (node.Attributes["MinTimeOffset"] != null) minTimeOffset = XmlConvert.ToInt32(node.Attributes["MinTimeOffset"].Value);
     131      if (node.Attributes["MaxTimeOffset"] != null) maxTimeOffset = XmlConvert.ToInt32(node.Attributes["MaxTimeOffset"].Value);
    113132      variableNames = new Dictionary<string, int>();
    114133      XmlNode variablesNode = node.ChildNodes[1];
Note: See TracChangeset for help on using the changeset viewer.