Changeset 16158 for branches/2883_GBTModelStorage/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine
- Timestamp:
- 09/20/18 13:12:17 (6 years ago)
- Location:
- branches/2883_GBTModelStorage/HeuristicLab.Algorithms.DataAnalysis
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2883_GBTModelStorage/HeuristicLab.Algorithms.DataAnalysis
- Property svn:mergeinfo changed
-
branches/2883_GBTModelStorage/HeuristicLab.Algorithms.DataAnalysis/3.4
- Property svn:ignore
-
old new 1 *.user 2 *.vs10x 3 HeuristicLab.Algorithms.DataAnalysis-3.4.csproj.user 4 HeuristicLabAlgorithmsDataAnalysisPlugin.cs 5 Plugin.cs 1 6 bin 2 7 obj 3 HeuristicLabAlgorithmsDataAnalysisPlugin.cs4 HeuristicLab.Algorithms.DataAnalysis-3.4.csproj.user5 *.vs10x6 Plugin.cs7 *.user
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/2883_GBTModelStorage/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorMachineModel.cs
r15583 r16158 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 -
branches/2883_GBTModelStorage/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorMachineUtil.cs
r15583 r16158 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.