- Timestamp:
- 06/28/16 13:33:17 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorMachineModel.cs
r13921 r13941 37 37 [StorableClass] 38 38 [Item("SupportVectorMachineModel", "Represents a support vector machine model.")] 39 public sealed class SupportVectorMachineModel : NamedItem, ISupportVectorMachineModel {40 public IEnumerable<string> VariablesUsedForPrediction {39 public sealed class SupportVectorMachineModel : ClassificationModel, ISupportVectorMachineModel { 40 public override IEnumerable<string> VariablesUsedForPrediction { 41 41 get { return allowedInputVariables; } 42 42 } 43 43 44 public string TargetVariable {45 get { return targetVariable; }46 }47 44 48 45 private svm_model model; … … 90 87 91 88 [Storable] 92 private string targetVariable;93 [Storable]94 89 private string[] allowedInputVariables; 95 90 [Storable] … … 103 98 this.model = original.model; 104 99 this.rangeTransform = original.rangeTransform; 105 this.targetVariable = original.targetVariable;106 100 this.allowedInputVariables = (string[])original.allowedInputVariables.Clone(); 107 101 if (original.classValues != null) … … 113 107 } 114 108 public SupportVectorMachineModel(svm_model model, RangeTransform rangeTransform, string targetVariable, IEnumerable<string> allowedInputVariables) 115 : base( ) {109 : base(targetVariable) { 116 110 this.name = ItemName; 117 111 this.description = ItemDescription; 118 112 this.model = model; 119 113 this.rangeTransform = rangeTransform; 120 this.targetVariable = targetVariable;121 114 this.allowedInputVariables = allowedInputVariables.ToArray(); 122 115 } … … 130 123 return GetEstimatedValuesHelper(dataset, rows); 131 124 } 132 public SupportVectorRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) {125 public IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) { 133 126 return new SupportVectorRegressionSolution(this, new RegressionProblemData(problemData)); 134 127 } 135 IRegressionSolution IRegressionModel.CreateRegressionSolution(IRegressionProblemData problemData) {136 return CreateRegressionSolution(problemData);137 }138 128 #endregion 139 129 140 130 #region IClassificationModel Members 141 public IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) {131 public override IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) { 142 132 if (classValues == null) throw new NotSupportedException(); 143 133 // return the original class value instead of the predicted value of the model … … 159 149 } 160 150 161 public SupportVectorClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) {151 public override IClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) { 162 152 return new SupportVectorClassificationSolution(this, new ClassificationProblemData(problemData)); 163 }164 IClassificationSolution IClassificationModel.CreateClassificationSolution(IClassificationProblemData problemData) {165 return CreateClassificationSolution(problemData);166 153 } 167 154 #endregion 168 155 private IEnumerable<double> GetEstimatedValuesHelper(IDataset dataset, IEnumerable<int> rows) { 169 156 // calculate predictions for the currently requested rows 170 svm_problem problem = SupportVectorMachineUtil.CreateSvmProblem(dataset, targetVariable, allowedInputVariables, rows);157 svm_problem problem = SupportVectorMachineUtil.CreateSvmProblem(dataset, TargetVariable, allowedInputVariables, rows); 171 158 svm_problem scaledProblem = rangeTransform.Scale(problem); 172 159
Note: See TracChangeset
for help on using the changeset viewer.