- Timestamp:
- 07/23/17 00:52:14 (7 years ago)
- Location:
- branches/Async
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Async
- Property svn:mergeinfo changed
-
branches/Async/HeuristicLab.Algorithms.DataAnalysis
- Property svn:mergeinfo changed
-
branches/Async/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorMachineModel.cs
r12509 r15280 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
Note: See TracChangeset
for help on using the changeset viewer.