Changeset 2436


Ignore:
Timestamp:
10/15/09 14:47:01 (13 years ago)
Author:
gkronber
Message:

Fixed a bug in import of SVM predictors. #772 (Text export of SVM models)

File:
1 edited

Legend:

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

    r2421 r2436  
    5050    }
    5151
    52     public Predictor() : base() { } // for persistence
     52    // for persistence
     53    public Predictor() : base() { }
    5354
    5455    public Predictor(SVMModel model, string targetVariable, IEnumerable<string> variableNames) :
     
    5758
    5859    public Predictor(SVMModel model, string targetVariable, IEnumerable<string> variableNames, int minTimeOffset, int maxTimeOffset)
    59       : base() {
     60      : this() {
    6061      this.svmModel = model;
    6162      this.targetVariable = targetVariable;
    62       this.variableNames = new List<string>(variableNames);
    6363      this.minTimeOffset = minTimeOffset;
    6464      this.maxTimeOffset = maxTimeOffset;
     65      this.variableNames = new List<string>(variableNames);
    6566    }
    6667
     
    169170
    170171    public static Predictor Import(TextReader reader) {
    171       Predictor p = new Predictor();
    172172      string[] targetVariableLine = reader.ReadLine().Split(':');
    173173      string[] lowerPredictionLimitLine = reader.ReadLine().Split(':');
     
    177177      string[] inputVariableLine = reader.ReadLine().Split(':', ';');
    178178
    179       p.targetVariable = targetVariableLine[1].Trim();
    180       p.LowerPredictionLimit = double.Parse(lowerPredictionLimitLine[1], CultureInfo.InvariantCulture.NumberFormat);
    181       p.UpperPredictionLimit = double.Parse(upperPredictionLimitLine[1], CultureInfo.InvariantCulture.NumberFormat);
    182       p.maxTimeOffset = int.Parse(maxTimeOffsetLine[1]);
    183       p.minTimeOffset = int.Parse(minTimeOffsetLine[1]);
     179      string targetVariable = targetVariableLine[1].Trim();
     180      double lowerPredictionLimit = double.Parse(lowerPredictionLimitLine[1], CultureInfo.InvariantCulture.NumberFormat);
     181      double upperPredictionLimit = double.Parse(upperPredictionLimitLine[1], CultureInfo.InvariantCulture.NumberFormat);
     182      int maxTimeOffset = int.Parse(maxTimeOffsetLine[1]);
     183      int minTimeOffset = int.Parse(minTimeOffsetLine[1]);
     184      List<string> variableNames = new List<string>();
    184185      foreach (string inputVariable in inputVariableLine.Skip(1)) {
    185         p.variableNames.Add(inputVariable.Trim());
     186        variableNames.Add(inputVariable.Trim());
    186187      }
    187       p.svmModel = SVMModel.Import(reader);
     188      SVMModel model = SVMModel.Import(reader);
     189      Predictor p = new Predictor(model, targetVariable, variableNames, minTimeOffset, maxTimeOffset);
     190      p.UpperPredictionLimit = upperPredictionLimit;
     191      p.LowerPredictionLimit = lowerPredictionLimit;
    188192      return p;
    189193    }
Note: See TracChangeset for help on using the changeset viewer.