Changeset 2418 for trunk/sources/HeuristicLab.SupportVectorMachines
- Timestamp:
- 10/07/09 16:19:21 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.SupportVectorMachines/3.2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.SupportVectorMachines/3.2/Predictor.cs
r2416 r2418 159 159 StreamWriter writer = new StreamWriter(s); 160 160 writer.Write("Targetvariable: "); writer.WriteLine(p.targetVariable); 161 writer.Write("LowerPredictionLimit: "); writer.WriteLine(p.LowerPredictionLimit.ToString("r" ));162 writer.Write("UpperPredictionLimit: "); writer.WriteLine(p.UpperPredictionLimit.ToString("r" ));161 writer.Write("LowerPredictionLimit: "); writer.WriteLine(p.LowerPredictionLimit.ToString("r", CultureInfo.InvariantCulture.NumberFormat)); 162 writer.Write("UpperPredictionLimit: "); writer.WriteLine(p.UpperPredictionLimit.ToString("r", CultureInfo.InvariantCulture.NumberFormat)); 163 163 writer.Write("MaxTimeOffset: "); writer.WriteLine(p.MaxTimeOffset.ToString()); 164 164 writer.Write("MinTimeOffset: "); writer.WriteLine(p.MinTimeOffset.ToString()); … … 176 176 } 177 177 178 public static Predictor Import( Stream s) {178 public static Predictor Import(TextReader reader) { 179 179 Predictor p = new Predictor(); 180 StreamReader reader = new StreamReader(s);181 180 string[] targetVariableLine = reader.ReadLine().Split(':'); 182 181 string[] lowerPredictionLimitLine = reader.ReadLine().Split(':'); … … 187 186 188 187 p.targetVariable = targetVariableLine[1].Trim(); 189 p.LowerPredictionLimit = double.Parse(lowerPredictionLimitLine[1] );190 p.UpperPredictionLimit = double.Parse(upperPredictionLimitLine[1] );188 p.LowerPredictionLimit = double.Parse(lowerPredictionLimitLine[1], CultureInfo.InvariantCulture.NumberFormat); 189 p.UpperPredictionLimit = double.Parse(upperPredictionLimitLine[1], CultureInfo.InvariantCulture.NumberFormat); 191 190 p.maxTimeOffset = int.Parse(maxTimeOffsetLine[1]); 192 191 p.minTimeOffset = int.Parse(minTimeOffsetLine[1]); … … 195 194 p.variableNames[inputVariable.Trim()] = i++; 196 195 } 197 p.svmModel = SVMModel.Import( s);196 p.svmModel = SVMModel.Import(reader); 198 197 return p; 199 198 } -
trunk/sources/HeuristicLab.SupportVectorMachines/3.2/SVMModel.cs
r2415 r2418 120 120 StreamWriter writer = new StreamWriter(s); 121 121 writer.WriteLine("RangeTransform:"); 122 writer.Flush(); 122 123 using (MemoryStream memStream = new MemoryStream()) { 123 124 SVM.RangeTransform.Write(memStream, model.RangeTransform); … … 126 127 } 127 128 writer.WriteLine("Model:"); 128 129 writer.Flush(); 129 130 using (MemoryStream memStream = new MemoryStream()) { 130 131 SVM.Model.Write(memStream, model.Model); … … 135 136 } 136 137 137 public static SVMModel Import( Stream s) {138 public static SVMModel Import(TextReader reader) { 138 139 SVMModel model = new SVMModel(); 139 StreamReader reader = new StreamReader(s);140 140 while (reader.ReadLine().Trim() != "RangeTransform:") ; // read until line "RangeTransform"; 141 model.RangeTransform = SVM.RangeTransform.Read(s); 142 141 model.RangeTransform = SVM.RangeTransform.Read(reader); 143 142 // read until "Model:" 144 143 while (reader.ReadLine().Trim() != "Model:") ; 145 model.Model = SVM.Model.Read( s);144 model.Model = SVM.Model.Read(reader); 146 145 return model; 147 146 }
Note: See TracChangeset
for help on using the changeset viewer.