Changeset 2148
- Timestamp:
- 07/07/09 13:06:31 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.SupportVectorMachines/3.2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.SupportVectorMachines/3.2/SVMHelper.cs
r1808 r2148 12 12 int rowCount = end - start; 13 13 double[] samples = dataset.Samples; 14 15 SVM.Node[][] nodes = new SVM.Node[rowCount][]; 14 15 List<int> skippedFeatures = new List<int>(); 16 for (int i = 0; i < allowedFeatures.Count; i++) { 17 if (dataset.GetRange(allowedFeatures[i].Data, start, end) == 0) 18 skippedFeatures.Add(i); 19 } 20 21 double[] targetVector = new double[rowCount]; 22 for (int i = 0; i < rowCount; i++) { 23 double value = samples[(start + i) * dataset.Columns + targetVariable]; 24 targetVector[i] = value; 25 } 26 targetVector = targetVector.Where(x=> !double.IsNaN(x)).ToArray(); 27 28 SVM.Node[][] nodes = new SVM.Node[targetVector.Length][]; 16 29 List<SVM.Node> tempRow; 17 double value;30 int addedRows = 0; 18 31 for (int row = 0; row < rowCount; row++) { 19 32 tempRow = new List<SVM.Node>(); 20 33 for (int col = 0; col < allowedFeatures.Count; col++) { 21 value = samples[(start + row) * dataset.Columns + allowedFeatures[col].Data]; 22 if(!double.IsNaN(value)) 23 tempRow.Add(new SVM.Node(allowedFeatures[col].Data, value)); 34 if (!skippedFeatures.Contains(col)) { 35 double value = samples[(start + row) * dataset.Columns + allowedFeatures[col].Data]; 36 if (!double.IsNaN(value)) 37 tempRow.Add(new SVM.Node(allowedFeatures[col].Data, value)); 38 } 24 39 } 25 nodes[row] = tempRow.ToArray(); 40 if (!double.IsNaN(samples[(start + row) * dataset.Columns + targetVariable])) { 41 nodes[addedRows] = tempRow.ToArray(); 42 addedRows++; 43 } 26 44 } 27 45 28 double[] targetVector = new double[rowCount]; 29 for (int i = 0; i < rowCount; i++) 30 targetVector[i] = samples[(start + i) * dataset.Columns + targetVariable]; 31 32 return new SVM.Problem(rowCount, targetVector, nodes, allowedFeatures.Max(x => x.Data)); 46 return new SVM.Problem(targetVector.Length, targetVector, nodes, allowedFeatures.Max(x => x.Data)); 33 47 } 34 48 } -
trunk/sources/HeuristicLab.SupportVectorMachines/3.2/SupportVectorEvaluator.cs
r2043 r2148 56 56 SVM.Problem scaledProblem = SVM.Scaling.Scale(problem, modelData.RangeTransform); 57 57 58 double[,] values = new double[ end-start, 2];59 for (int i = 0; i < end - start; i++) {58 double[,] values = new double[scaledProblem.Count, 2]; 59 for (int i = 0; i < scaledProblem.Count; i++) { 60 60 values[i,0] = SVM.Prediction.Predict(modelData.Model, scaledProblem.X[i]); 61 61 values[i,1] = dataset.GetValue(start + i,targetVariable);
Note: See TracChangeset
for help on using the changeset viewer.