Changeset 5690 for branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Regression/3.3/SupportVectorRegression/SupportVectorRegressionSolution.cs
- Timestamp:
- 03/15/11 15:35:32 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis.Regression/3.3/SupportVectorRegression/SupportVectorRegressionSolution.cs
r5445 r5690 46 46 } 47 47 48 public Dataset SupportVectors {49 get { return CalculateSupportVectors(); }50 }51 52 48 private List<double> estimatedValues; 53 49 public override IEnumerable<double> EstimatedValues { … … 70 66 } 71 67 68 public Dataset SupportVectors { 69 get { 70 int nCol = inputVariables.Count; 71 double[,] data = new double[Model.Model.SupportVectorCount, nCol]; 72 int row = 0; 73 foreach (var sv in Model.SupportVectors) { 74 for (int col = 0; col < nCol; col++) { 75 data[row, col] = sv[col]; 76 } 77 row++; 78 } 79 return new Dataset(inputVariables, data); 80 } 81 } 82 83 [Storable] 84 private List<string> inputVariables; 85 72 86 [StorableConstructor] 73 87 private SupportVectorRegressionSolution(bool deserializing) : base(deserializing) { } 74 private SupportVectorRegressionSolution(SupportVectorRegressionSolution original, Cloner cloner) : base(original, cloner) { } 88 private SupportVectorRegressionSolution(SupportVectorRegressionSolution original, Cloner cloner) 89 : base(original, cloner) { 90 this.inputVariables = new List<string>(original.inputVariables); 91 } 75 92 public SupportVectorRegressionSolution() : base() { } 76 93 public SupportVectorRegressionSolution(DataAnalysisProblemData problemData, SupportVectorMachineModel model, IEnumerable<string> inputVariables, double lowerEstimationLimit, double upperEstimationLimit) 77 94 : base(problemData, lowerEstimationLimit, upperEstimationLimit) { 78 95 this.Model = model; 96 this.inputVariables = new List<string>(inputVariables); 97 } 98 99 [StorableHook(HookType.AfterDeserialization)] 100 private void AfterDeserialization() { 101 #region backwards compatibility 102 if (inputVariables == null) inputVariables = ProblemData.InputVariables.CheckedItems.Select(x => x.Value.Value).ToList(); 103 #endregion 79 104 } 80 105 81 106 public override IDeepCloneable Clone(Cloner cloner) { 82 107 return new SupportVectorRegressionSolution(this, cloner); 83 }84 85 protected override void OnProblemDataChanged() {86 Model.Model.SupportVectorIndizes = new int[0];87 base.OnProblemDataChanged();88 }89 90 private Dataset CalculateSupportVectors() {91 if (Model.Model.SupportVectorIndizes.Length == 0)92 return new Dataset(new List<string>(), new double[0, 0]);93 94 double[,] data = new double[Model.Model.SupportVectorIndizes.Length, ProblemData.Dataset.Columns];95 for (int i = 0; i < Model.Model.SupportVectorIndizes.Length; i++) {96 for (int column = 0; column < ProblemData.Dataset.Columns; column++)97 data[i, column] = ProblemData.Dataset[Model.Model.SupportVectorIndizes[i], column];98 }99 return new Dataset(ProblemData.Dataset.VariableNames, data);100 108 } 101 109
Note: See TracChangeset
for help on using the changeset viewer.