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/Symbolic
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionModel.cs

    r3541 r3884  
    3939  [StorableClass]
    4040  [Item("SymbolicRegressionModel", "A symbolic regression model represents an entity that provides estimated values based on input values.")]
    41   public class SymbolicRegressionModel : Item {
     41  public class SymbolicRegressionModel : NamedItem, IDataAnalysisModel {
     42    private SymbolicRegressionModel() : base() { } // for cloning
     43    [StorableConstructor]
     44    protected SymbolicRegressionModel(bool deserializing)
     45      : base(deserializing) {
     46    }
     47    public SymbolicRegressionModel(ISymbolicExpressionTreeInterpreter interpreter, SymbolicExpressionTree tree, IEnumerable<string> inputVariables)
     48      : base() {
     49      this.tree = tree;
     50      this.interpreter = interpreter;
     51      this.inputVariables = inputVariables.ToList();
     52    }
     53
    4254    [Storable]
    4355    private SymbolicExpressionTree tree;
     
    5062      get { return interpreter; }
    5163    }
     64    [Storable]
    5265    private List<string> inputVariables;
    53     [Storable]
    5466    public IEnumerable<string> InputVariables {
    5567      get { return inputVariables.AsEnumerable(); }
     
    5971      }
    6072    }
    61     public SymbolicRegressionModel() : base() { } // for cloning
    6273
    63     public SymbolicRegressionModel(ISymbolicExpressionTreeInterpreter interpreter, SymbolicExpressionTree tree, IEnumerable<string> inputVariables)
    64       : base() {
    65       this.tree = tree;
    66       this.interpreter = interpreter;
    67       this.inputVariables = inputVariables.ToList();
    68     }
    69 
    70     public IEnumerable<double> GetEstimatedValues(Dataset dataset, int start, int end) {
    71       return interpreter.GetSymbolicExpressionTreeValues(tree, dataset, Enumerable.Range(start, end - start));
     74    public IEnumerable<double> GetEstimatedValues(DataAnalysisProblemData problemData, int start, int end) {
     75      return interpreter.GetSymbolicExpressionTreeValues(tree, problemData.Dataset, Enumerable.Range(start, end - start));
    7276    }
    7377
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionSolution.cs

    r3710 r3884  
    3737  [StorableClass]
    3838  public sealed class SymbolicRegressionSolution : DataAnalysisSolution {
     39    public SymbolicRegressionSolution() : base() { }
     40    public SymbolicRegressionSolution(DataAnalysisProblemData problemData, SymbolicRegressionModel model, double lowerEstimationLimit, double upperEstimationLimit)
     41      : base(problemData, lowerEstimationLimit, upperEstimationLimit) {
     42      this.Model = model;
     43    }
     44
    3945    public override Image ItemImage {
    4046      get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Function; }
    4147    }
    42     [Storable]
    43     private SymbolicRegressionModel model;
    44     public SymbolicRegressionModel Model {
    45       get { return model; }
    46       set {
    47         if (model != value) {
    48           if (value == null) throw new ArgumentNullException();
    49           model = value;
    50           OnModelChanged(EventArgs.Empty);
    51         }
    52       }
     48
     49    public new SymbolicRegressionModel Model {
     50      get { return (SymbolicRegressionModel)base.Model; }
     51      set { base.Model = value; }
    5352    }
    5453
    55     public SymbolicRegressionSolution() : base() { }
    56     public SymbolicRegressionSolution(DataAnalysisProblemData problemData, SymbolicRegressionModel model, double lowerEstimationLimit, double upperEstimationLimit)
    57       : base(problemData, lowerEstimationLimit, upperEstimationLimit) {
    58       this.model = model;
    59     }
    60 
    61     public event EventHandler ModelChanged;
    62     private void OnModelChanged(EventArgs e) {
    63       RecalculateEstimatedValues();
    64       var listeners = ModelChanged;
    65       if (listeners != null)
    66         listeners(this, e);
    67     }
    68 
    69     protected override void OnProblemDataChanged(EventArgs e) {
    70       RecalculateEstimatedValues();
    71     }
    72 
    73     private void RecalculateEstimatedValues() {
    74       estimatedValues = (from x in model.GetEstimatedValues(ProblemData.Dataset, 0, ProblemData.Dataset.Rows)
     54    protected override void RecalculateEstimatedValues() {
     55      estimatedValues = (from x in Model.GetEstimatedValues(ProblemData, 0, ProblemData.Dataset.Rows)
    7556                         let boundedX = Math.Min(UpperEstimationLimit, Math.Max(LowerEstimationLimit, x))
    7657                         select double.IsNaN(boundedX) ? UpperEstimationLimit : boundedX).ToList();
    77       OnEstimatedValuesChanged(EventArgs.Empty);
     58      OnEstimatedValuesChanged();
    7859    }
    7960
     
    10384      }
    10485    }
    105 
    106     public override IDeepCloneable Clone(Cloner cloner) {
    107       SymbolicRegressionSolution clone = (SymbolicRegressionSolution)base.Clone(cloner);
    108       clone.model = (SymbolicRegressionModel)cloner.Clone(model);
    109       return clone;
    110     }
    11186  }
    11287}
Note: See TracChangeset for help on using the changeset viewer.