Changeset 4068 for trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.LibSVM/1.6.3/LibSVM-1.6.3/Scaling.cs
- Timestamp:
- 07/22/10 00:44:01 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.LibSVM/1.6.3/LibSVM-1.6.3/Scaling.cs
r2645 r4068 18 18 19 19 20 using System;21 20 22 namespace SVM 23 { 21 namespace SVM { 22 /// <summary> 23 /// Deals with the scaling of Problems so they have uniform ranges across all dimensions in order to 24 /// result in better SVM performance. 25 /// </summary> 26 public static class Scaling { 24 27 /// <summary> 25 /// Deals with the scaling of Problems so they have uniform ranges across all dimensions in order to 26 /// result in better SVM performance. 28 /// Scales a problem using the provided range. This will not affect the parameter. 27 29 /// </summary> 28 public static class Scaling 29 { 30 /// <summary> 31 /// Scales a problem using the provided range. This will not affect the parameter. 32 /// </summary> 33 /// <param name="prob">The problem to scale</param> 34 /// <param name="range">The Range transform to use in scaling</param> 35 /// <returns>The Scaled problem</returns> 36 public static Problem Scale(this IRangeTransform range, Problem prob) 37 { 38 Problem scaledProblem = new Problem(prob.Count, new double[prob.Count], new Node[prob.Count][], prob.MaxIndex); 39 for (int i = 0; i < scaledProblem.Count; i++) 40 { 41 scaledProblem.X[i] = new Node[prob.X[i].Length]; 42 for (int j = 0; j < scaledProblem.X[i].Length; j++) 43 scaledProblem.X[i][j] = new Node(prob.X[i][j].Index, range.Transform(prob.X[i][j].Value, prob.X[i][j].Index)); 44 scaledProblem.Y[i] = prob.Y[i]; 45 } 46 return scaledProblem; 47 } 30 /// <param name="prob">The problem to scale</param> 31 /// <param name="range">The Range transform to use in scaling</param> 32 /// <returns>The Scaled problem</returns> 33 public static Problem Scale(this IRangeTransform range, Problem prob) { 34 Problem scaledProblem = new Problem(prob.Count, new double[prob.Count], new Node[prob.Count][], prob.MaxIndex); 35 for (int i = 0; i < scaledProblem.Count; i++) { 36 scaledProblem.X[i] = new Node[prob.X[i].Length]; 37 for (int j = 0; j < scaledProblem.X[i].Length; j++) 38 scaledProblem.X[i][j] = new Node(prob.X[i][j].Index, range.Transform(prob.X[i][j].Value, prob.X[i][j].Index)); 39 scaledProblem.Y[i] = prob.Y[i]; 40 } 41 return scaledProblem; 48 42 } 43 } 49 44 }
Note: See TracChangeset
for help on using the changeset viewer.