Changeset 13824 for branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Algorithms.DataAnalysis
- Timestamp:
- 05/03/16 12:25:30 (9 years ago)
- Location:
- branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Algorithms.DataAnalysis/3.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessRegressionSolution.cs
r13823 r13824 20 20 #endregion 21 21 22 using System.Collections.Generic;23 using System.Linq;24 22 using HeuristicLab.Common; 25 23 using HeuristicLab.Core; … … 33 31 [Item("GaussianProcessRegressionSolution", "Represents a Gaussian process solution for a regression problem which can be visualized in the GUI.")] 34 32 [StorableClass] 35 public sealed class GaussianProcessRegressionSolution : RegressionSolution, IGaussianProcessSolution, IConfidenceBoundRegressionSolution { 36 private new readonly Dictionary<int, double> evaluationCache; 33 public sealed class GaussianProcessRegressionSolution : ConfidenceBoundRegressionSolution, IGaussianProcessSolution { 37 34 38 35 public new IGaussianProcessModel Model { … … 44 41 private GaussianProcessRegressionSolution(bool deserializing) 45 42 : base(deserializing) { 46 evaluationCache = new Dictionary<int, double>();47 48 43 } 49 44 private GaussianProcessRegressionSolution(GaussianProcessRegressionSolution original, Cloner cloner) 50 : base(original, cloner) { 51 evaluationCache = new Dictionary<int, double>(original.evaluationCache); 52 } 45 : base(original, cloner) { } 53 46 public GaussianProcessRegressionSolution(IGaussianProcessModel model, IRegressionProblemData problemData) 54 : base(model, problemData) { 55 56 evaluationCache = new Dictionary<int, double>(problemData.Dataset.Rows); 57 } 47 : base(model, problemData) { } 58 48 59 49 public override IDeepCloneable Clone(Cloner cloner) { 60 50 return new GaussianProcessRegressionSolution(this, cloner); 61 51 } 62 63 public IEnumerable<double> EstimatedVariances {64 get { return GetEstimatedVariances(Enumerable.Range(0, ProblemData.Dataset.Rows)); }65 }66 public IEnumerable<double> EstimatedTrainingVariances {67 get { return GetEstimatedVariances(ProblemData.TrainingIndices); }68 }69 public IEnumerable<double> EstimatedTestVariances {70 get { return GetEstimatedVariances(ProblemData.TestIndices); }71 }72 73 public IEnumerable<double> GetEstimatedVariances(IEnumerable<int> rows) {74 var rowsToEvaluate = rows.Except(evaluationCache.Keys);75 var rowsEnumerator = rowsToEvaluate.GetEnumerator();76 var valuesEnumerator = Model.GetEstimatedVariances(ProblemData.Dataset, rowsToEvaluate).GetEnumerator();77 78 while (rowsEnumerator.MoveNext() & valuesEnumerator.MoveNext()) {79 evaluationCache.Add(rowsEnumerator.Current, valuesEnumerator.Current);80 }81 82 return rows.Select(row => evaluationCache[row]);83 }84 85 protected override void OnModelChanged() {86 evaluationCache.Clear();87 base.OnModelChanged();88 }89 protected override void OnProblemDataChanged() {90 evaluationCache.Clear();91 base.OnProblemDataChanged();92 }93 52 } 94 53 } -
branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Algorithms.DataAnalysis/3.4/Interfaces/IGaussianProcessSolution.cs
r12012 r13824 26 26 /// Interface to represent a Gaussian process solution (either regression or classification) 27 27 /// </summary> 28 public interface IGaussianProcessSolution : I DataAnalysisSolution {28 public interface IGaussianProcessSolution : IConfidenceBoundRegressionSolution { 29 29 new IGaussianProcessModel Model { get; } 30 30 }
Note: See TracChangeset
for help on using the changeset viewer.