Changeset 16160
- Timestamp:
- 09/20/18 14:43:40 (6 years ago)
- Location:
- stable
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
-
stable/HeuristicLab.Algorithms.DataAnalysis
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Algorithms.DataAnalysis merged: 15854
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Algorithms.DataAnalysis/3.4
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Algorithms.DataAnalysis/3.4 merged: 15854
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorMachineModel.cs
r15584 r16160 155 155 private IEnumerable<double> GetEstimatedValuesHelper(IDataset dataset, IEnumerable<int> rows) { 156 156 // calculate predictions for the currently requested rows 157 svm_problem problem = SupportVectorMachineUtil.CreateSvmProblem(dataset, TargetVariable,allowedInputVariables, rows);157 svm_problem problem = SupportVectorMachineUtil.CreateSvmProblem(dataset, allowedInputVariables, rows); 158 158 svm_problem scaledProblem = rangeTransform.Scale(problem); 159 159 -
stable/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorMachineUtil.cs
r15584 r16160 35 35 public class SupportVectorMachineUtil { 36 36 /// <summary> 37 /// Transforms <paramref name="problemData"/> into a data structure as needed by libSVM. 38 /// </summary> 39 /// <param name="problemData">The problem data to transform</param> 37 /// Transforms <paramref name="dataset"/> into a data structure as needed by libSVM. 38 /// </summary> 39 /// <param name="dataset">The source dataset</param> 40 /// <param name="targetVariable">The target variable</param> 41 /// <param name="inputVariables">The selected input variables to include in the svm_problem.</param> 40 42 /// <param name="rowIndices">The rows of the dataset that should be contained in the resulting SVM-problem</param> 41 43 /// <returns>A problem data type that can be used to train a support vector machine.</returns> 42 44 public static svm_problem CreateSvmProblem(IDataset dataset, string targetVariable, IEnumerable<string> inputVariables, IEnumerable<int> rowIndices) { 43 double[] targetVector = dataset.GetDoubleValues(targetVariable, rowIndices).ToArray(); 44 svm_node[][] nodes = new svm_node[targetVector.Length][]; 45 double[] targetVector ; 46 var nRows = rowIndices.Count(); 47 if (string.IsNullOrEmpty(targetVariable)) { 48 // if the target variable is not set (e.g. for prediction of a trained model) we just use a zero vector 49 targetVector = new double[nRows]; 50 } else { 51 targetVector = dataset.GetDoubleValues(targetVariable, rowIndices).ToArray(); 52 } 53 svm_node[][] nodes = new svm_node[nRows][]; 45 54 int maxNodeIndex = 0; 46 55 int svmProblemRowIndex = 0; … … 66 75 67 76 /// <summary> 77 /// Transforms <paramref name="dataset"/> into a data structure as needed by libSVM for prediction. 78 /// </summary> 79 /// <param name="dataset">The problem data to transform</param> 80 /// <param name="inputVariables">The selected input variables to include in the svm_problem.</param> 81 /// <param name="rowIndices">The rows of the dataset that should be contained in the resulting SVM-problem</param> 82 /// <returns>A problem data type that can be used for prediction with a trained support vector machine.</returns> 83 public static svm_problem CreateSvmProblem(IDataset dataset, IEnumerable<string> inputVariables, IEnumerable<int> rowIndices) { 84 // for prediction we don't need a target variable 85 return CreateSvmProblem(dataset, string.Empty, inputVariables, rowIndices); 86 } 87 88 /// <summary> 68 89 /// Instantiate and return a svm_parameter object with default values. 69 90 /// </summary>
Note: See TracChangeset
for help on using the changeset viewer.