Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/28/16 13:33:17 (9 years ago)
Author:
mkommend
Message:

#2604:

  • Base classes for data analysis, classification, and regression models
  • Added target variable to classification and regression models
  • Switched parameter order in data analysis solutions (model, problemdata)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorMachineModel.cs

    r13921 r13941  
    3737  [StorableClass]
    3838  [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 {
    4141      get { return allowedInputVariables; }
    4242    }
    4343
    44     public string TargetVariable {
    45       get { return targetVariable; }
    46     }
    4744
    4845    private svm_model model;
     
    9087
    9188    [Storable]
    92     private string targetVariable;
    93     [Storable]
    9489    private string[] allowedInputVariables;
    9590    [Storable]
     
    10398      this.model = original.model;
    10499      this.rangeTransform = original.rangeTransform;
    105       this.targetVariable = original.targetVariable;
    106100      this.allowedInputVariables = (string[])original.allowedInputVariables.Clone();
    107101      if (original.classValues != null)
     
    113107    }
    114108    public SupportVectorMachineModel(svm_model model, RangeTransform rangeTransform, string targetVariable, IEnumerable<string> allowedInputVariables)
    115       : base() {
     109      : base(targetVariable) {
    116110      this.name = ItemName;
    117111      this.description = ItemDescription;
    118112      this.model = model;
    119113      this.rangeTransform = rangeTransform;
    120       this.targetVariable = targetVariable;
    121114      this.allowedInputVariables = allowedInputVariables.ToArray();
    122115    }
     
    130123      return GetEstimatedValuesHelper(dataset, rows);
    131124    }
    132     public SupportVectorRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) {
     125    public IRegressionSolution CreateRegressionSolution(IRegressionProblemData problemData) {
    133126      return new SupportVectorRegressionSolution(this, new RegressionProblemData(problemData));
    134127    }
    135     IRegressionSolution IRegressionModel.CreateRegressionSolution(IRegressionProblemData problemData) {
    136       return CreateRegressionSolution(problemData);
    137     }
    138128    #endregion
    139129
    140130    #region IClassificationModel Members
    141     public IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) {
     131    public override IEnumerable<double> GetEstimatedClassValues(IDataset dataset, IEnumerable<int> rows) {
    142132      if (classValues == null) throw new NotSupportedException();
    143133      // return the original class value instead of the predicted value of the model
     
    159149    }
    160150
    161     public SupportVectorClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) {
     151    public override IClassificationSolution CreateClassificationSolution(IClassificationProblemData problemData) {
    162152      return new SupportVectorClassificationSolution(this, new ClassificationProblemData(problemData));
    163     }
    164     IClassificationSolution IClassificationModel.CreateClassificationSolution(IClassificationProblemData problemData) {
    165       return CreateClassificationSolution(problemData);
    166153    }
    167154    #endregion
    168155    private IEnumerable<double> GetEstimatedValuesHelper(IDataset dataset, IEnumerable<int> rows) {
    169156      // 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);
    171158      svm_problem scaledProblem = rangeTransform.Scale(problem);
    172159
Note: See TracChangeset for help on using the changeset viewer.