- Timestamp:
- 08/14/09 19:56:04 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.SupportVectorMachines/3.2/SVMHelper.cs
r2285 r2290 9 9 namespace HeuristicLab.SupportVectorMachines { 10 10 public class SVMHelper { 11 11 12 public static SVM.Problem CreateSVMProblem(Dataset dataset, int targetVariable, int start, int end) { 13 return CreateSVMProblem(dataset, targetVariable, Enumerable.Range(0, dataset.Columns).ToDictionary<int, int>(x => x), start, end); 14 } 15 16 public static SVM.Problem CreateSVMProblem(Dataset dataset, int targetVariable, Dictionary<int, int> columnMapping, int start, int end) { 12 17 int rowCount = end - start; 13 18 List<int> skippedFeatures = new List<int>(); … … 24 29 for (int i = 0; i < rowCount; i++) { 25 30 double value = dataset.GetValue(start + i, targetVariable); 26 31 targetVector[i] = value; 27 32 } 28 targetVector = targetVector.Where(x => !double.IsNaN(x)).ToArray();33 targetVector = targetVector.Where(x => !double.IsNaN(x)).ToArray(); 29 34 30 35 SVM.Node[][] nodes = new SVM.Node[targetVector.Length][]; … … 34 39 tempRow = new List<SVM.Node>(); 35 40 for (int col = 0; col < dataset.Columns; col++) { 36 if (!skippedFeatures.Contains(col) && col !=targetVariable) {41 if (!skippedFeatures.Contains(col) && col != targetVariable && columnMapping.ContainsKey(col)) { 37 42 double value = dataset.GetValue(start + row, col); 38 43 if (!double.IsNaN(value)) 39 tempRow.Add(new SVM.Node(col + 1, value));44 tempRow.Add(new SVM.Node(columnMapping[col], value)); 40 45 } 41 46 }
Note: See TracChangeset
for help on using the changeset viewer.