Changeset 14029 for branches/crossvalidation-2434/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine
- Timestamp:
- 07/08/16 14:40:02 (8 years ago)
- Location:
- branches/crossvalidation-2434
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/crossvalidation-2434
- Property svn:mergeinfo changed
-
branches/crossvalidation-2434/HeuristicLab.Algorithms.DataAnalysis
- Property svn:mergeinfo changed
-
branches/crossvalidation-2434/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorClassification.cs
r12935 r14029 36 36 /// Support vector machine classification data analysis algorithm. 37 37 /// </summary> 38 [Item("Support Vector Classification ", "Support vector machine classification data analysis algorithm (wrapper for libSVM).")]38 [Item("Support Vector Classification (SVM)", "Support vector machine classification data analysis algorithm (wrapper for libSVM).")] 39 39 [Creatable(CreatableAttribute.Categories.DataAnalysisClassification, Priority = 110)] 40 40 [StorableClass] … … 212 212 IEnumerable<int> rows = problemData.TrainingIndices; 213 213 214 //extract SVM parameters from scope and set them215 214 svm_parameter parameter = new svm_parameter { 216 215 svm_type = svmType, -
branches/crossvalidation-2434/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorMachineModel.cs
r12509 r14029 37 37 [StorableClass] 38 38 [Item("SupportVectorMachineModel", "Represents a support vector machine model.")] 39 public sealed class SupportVectorMachineModel : NamedItem, ISupportVectorMachineModel { 39 public sealed class SupportVectorMachineModel : ClassificationModel, ISupportVectorMachineModel { 40 public override IEnumerable<string> VariablesUsedForPrediction { 41 get { return allowedInputVariables; } 42 } 43 40 44 41 45 private svm_model model; … … 83 87 84 88 [Storable] 85 private string targetVariable;86 [Storable]87 89 private string[] allowedInputVariables; 88 90 [Storable] … … 96 98 this.model = original.model; 97 99 this.rangeTransform = original.rangeTransform; 98 this.targetVariable = original.targetVariable;99 100 this.allowedInputVariables = (string[])original.allowedInputVariables.Clone(); 100 101 if (original.classValues != null) … … 106 107 } 107 108 public SupportVectorMachineModel(svm_model model, RangeTransform rangeTransform, string targetVariable, IEnumerable<string> allowedInputVariables) 108 : base( ) {109 : base(targetVariable) { 109 110 this.name = ItemName; 110 111 this.description = ItemDescription; 111 112 this.model = model; 112 113 this.rangeTransform = rangeTransform; 113 this.targetVariable = targetVariable;114 114 this.allowedInputVariables = allowedInputVariables.ToArray(); 115 115 } … … 123 123 return GetEstimatedValuesHelper(dataset, rows); 124 124 } 125 public SupportVectorRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) {125 public IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) { 126 126 return new SupportVectorRegressionSolution(this, new RegressionProblemData(problemData)); 127 127 } 128 IRegressionSolution IRegressionModel.CreateRegressionSolution(IRegressionProblemData problemData) {129 return CreateRegressionSolution(problemData);130 }131 128 #endregion 132 129 133 130 #region IClassificationModel Members 134 public IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) {131 public override IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) { 135 132 if (classValues == null) throw new NotSupportedException(); 136 133 // return the original class value instead of the predicted value of the model … … 152 149 } 153 150 154 public SupportVectorClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) {151 public override IClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) { 155 152 return new SupportVectorClassificationSolution(this, new ClassificationProblemData(problemData)); 156 }157 IClassificationSolution IClassificationModel.CreateClassificationSolution(IClassificationProblemData problemData) {158 return CreateClassificationSolution(problemData);159 153 } 160 154 #endregion 161 155 private IEnumerable<double> GetEstimatedValuesHelper(IDataset dataset, IEnumerable<int> rows) { 162 156 // calculate predictions for the currently requested rows 163 svm_problem problem = SupportVectorMachineUtil.CreateSvmProblem(dataset, targetVariable, allowedInputVariables, rows);157 svm_problem problem = SupportVectorMachineUtil.CreateSvmProblem(dataset, TargetVariable, allowedInputVariables, rows); 164 158 svm_problem scaledProblem = rangeTransform.Scale(problem); 165 159 -
branches/crossvalidation-2434/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorRegression.cs
r12935 r14029 36 36 /// Support vector machine regression data analysis algorithm. 37 37 /// </summary> 38 [Item("Support Vector Regression ", "Support vector machine regression data analysis algorithm (wrapper for libSVM).")]38 [Item("Support Vector Regression (SVM)", "Support vector machine regression data analysis algorithm (wrapper for libSVM).")] 39 39 [Creatable(CreatableAttribute.Categories.DataAnalysisRegression, Priority = 110)] 40 40 [StorableClass] … … 229 229 IEnumerable<int> rows = problemData.TrainingIndices; 230 230 231 //extract SVM parameters from scope and set them232 231 svm_parameter parameter = new svm_parameter { 233 232 svm_type = GetSvmType(svmType),
Note: See TracChangeset
for help on using the changeset viewer.