Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/01/10 17:58:03 (14 years ago)
Author:
gkronber
Message:

Worked on support vector regression operators and views. #1009

Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/SupportVectorRegression
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/SupportVectorRegression/BestSupportVectorRegressionSolutionAnalyzer.cs

    r3877 r3884  
    169169      return base.Apply();
    170170    }
    171 
    172     private IEnumerable<string> GetInputVariables(SymbolicExpressionTree tree) {
    173       return (from varNode in tree.IterateNodesPrefix().OfType<VariableTreeNode>()
    174               select varNode.VariableName).Distinct();
    175     }
    176171  }
    177172}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/SupportVectorRegression/SupportVectorRegressionSolution.cs

    r3858 r3884  
    3939  [StorableClass]
    4040  public sealed class SupportVectorRegressionSolution : DataAnalysisSolution {
     41    public SupportVectorRegressionSolution() : base() { }
     42    public SupportVectorRegressionSolution(DataAnalysisProblemData problemData, SupportVectorMachineModel model, IEnumerable<string> inputVariables, double lowerEstimationLimit, double upperEstimationLimit)
     43      : base(problemData, lowerEstimationLimit, upperEstimationLimit) {
     44      this.Model = model;
     45    }
     46
    4147    public override Image ItemImage {
    4248      get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Function; }
    4349    }
    4450
    45     [Storable]
    46     private SupportVectorMachineModel model;
    47     public SupportVectorMachineModel Model {
    48       get { return model; }
     51    public new SupportVectorMachineModel Model {
     52      get { return (SupportVectorMachineModel)base.Model; }
     53      set { base.Model = value; }
    4954    }
    5055
     
    5358    }
    5459
    55     public SupportVectorRegressionSolution() : base() { }
    56     public SupportVectorRegressionSolution(DataAnalysisProblemData problemData, SupportVectorMachineModel model, IEnumerable<string> inputVariables, double lowerEstimationLimit, double upperEstimationLimit)
    57       : base(problemData, lowerEstimationLimit, upperEstimationLimit) {
    58       this.model = model;
    59     }
    60 
    61     protected override void OnProblemDataChanged(EventArgs e) {
    62       RecalculateEstimatedValues();
    63       model.Model.SupportVectorIndizes = new int[0];
     60    protected override void OnProblemDataChanged() {
     61      Model.Model.SupportVectorIndizes = new int[0];
     62      base.OnProblemDataChanged();
    6463    }
    6564
    6665    private Dataset CalculateSupportVectors() {
    67       if (model.Model.SupportVectorIndizes.Length == 0)
     66      if (Model.Model.SupportVectorIndizes.Length == 0)
    6867        return new Dataset();
    6968
    70       Dataset dataset = new Dataset(ProblemData.Dataset.VariableNames, new double[model.Model.SupportVectorCount, ProblemData.Dataset.Columns]);
    71       for (int i = 0; i < model.Model.SupportVectorIndizes.Length; i++) {
     69      Dataset dataset = new Dataset(ProblemData.Dataset.VariableNames, new double[Model.Model.SupportVectorCount, ProblemData.Dataset.Columns]);
     70      for (int i = 0; i < Model.Model.SupportVectorIndizes.Length; i++) {
    7271        for (int column = 0; column < ProblemData.Dataset.Columns; column++)
    73           dataset[i, column] = ProblemData.Dataset[model.Model.SupportVectorIndizes[i], column];
     72          dataset[i, column] = ProblemData.Dataset[Model.Model.SupportVectorIndizes[i], column];
    7473      }
    7574      return dataset;
    7675    }
    7776
    78     private void RecalculateEstimatedValues() {
     77    protected override void RecalculateEstimatedValues() {
    7978      SVM.Problem problem = SupportVectorMachineUtil.CreateSvmProblem(ProblemData, 0, ProblemData.Dataset.Rows);
    80       SVM.Problem scaledProblem = Scaling.Scale(model.RangeTransform, problem);
     79      SVM.Problem scaledProblem = Scaling.Scale(Model.RangeTransform, problem);
    8180
    8281      estimatedValues = (from row in Enumerable.Range(0, scaledProblem.Count)
    83                          let prediction = SVM.Prediction.Predict(model.Model, scaledProblem.X[row])
     82                         let prediction = SVM.Prediction.Predict(Model.Model, scaledProblem.X[row])
    8483                         let boundedX = Math.Min(UpperEstimationLimit, Math.Max(LowerEstimationLimit, prediction))
    8584                         select double.IsNaN(boundedX) ? UpperEstimationLimit : boundedX).ToList();
    86       OnEstimatedValuesChanged(EventArgs.Empty);
     85      OnEstimatedValuesChanged();
    8786    }
    8887
     
    112111      }
    113112    }
    114 
    115     public override IDeepCloneable Clone(Cloner cloner) {
    116       SupportVectorRegressionSolution clone = (SupportVectorRegressionSolution)base.Clone(cloner);
    117       clone.model = (SupportVectorMachineModel)cloner.Clone(model);
    118       return clone;
    119     }
    120113  }
    121114}
Note: See TracChangeset for help on using the changeset viewer.