Changeset 6588
- Timestamp:
- 07/25/11 15:42:14 (13 years ago)
- Location:
- trunk/sources
- Files:
-
- 1 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NearestNeighbour/NearestNeighbourRegressionSolution.cs
r6583 r6588 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Drawing;25 using System.Linq;26 22 using HeuristicLab.Common; 27 23 using HeuristicLab.Core; … … 49 45 public NearestNeighbourRegressionSolution(IRegressionProblemData problemData, INearestNeighbourModel nnModel) 50 46 : base(nnModel, problemData) { 47 RecalculateResults(); 51 48 } 52 49 … … 54 51 return new NearestNeighbourRegressionSolution(this, cloner); 55 52 } 53 54 protected override void RecalculateResults() { 55 CalculateResults(); 56 } 56 57 } 57 58 } -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkEnsembleRegressionSolution.cs
r6580 r6588 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Drawing;25 using System.Linq;26 22 using HeuristicLab.Common; 27 23 using HeuristicLab.Core; … … 49 45 public NeuralNetworkEnsembleRegressionSolution(IRegressionProblemData problemData, INeuralNetworkEnsembleModel nnModel) 50 46 : base(nnModel, problemData) { 47 RecalculateResults(); 51 48 } 52 49 … … 54 51 return new NeuralNetworkEnsembleRegressionSolution(this, cloner); 55 52 } 53 54 protected override void RecalculateResults() { 55 CalculateResults(); 56 } 56 57 } 57 58 } -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NeuralNetwork/NeuralNetworkRegressionSolution.cs
r6577 r6588 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Drawing;25 using System.Linq;26 22 using HeuristicLab.Common; 27 23 using HeuristicLab.Core; … … 49 45 public NeuralNetworkRegressionSolution(IRegressionProblemData problemData, INeuralNetworkModel nnModel) 50 46 : base(nnModel, problemData) { 47 RecalculateResults(); 51 48 } 52 49 … … 54 51 return new NeuralNetworkRegressionSolution(this, cloner); 55 52 } 53 54 protected override void RecalculateResults() { 55 CalculateResults(); 56 } 56 57 } 57 58 } -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/RandomForest/RandomForestRegressionSolution.cs
r6241 r6588 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Drawing;25 using System.Linq;26 22 using HeuristicLab.Common; 27 23 using HeuristicLab.Core; … … 49 45 public RandomForestRegressionSolution(IRegressionProblemData problemData, IRandomForestModel randomForestModel) 50 46 : base(randomForestModel, problemData) { 47 RecalculateResults(); 51 48 } 52 49 … … 54 51 return new RandomForestRegressionSolution(this, cloner); 55 52 } 53 54 protected override void RecalculateResults() { 55 CalculateResults(); 56 } 56 57 } 57 58 } -
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorRegressionSolution.cs
r5809 r6588 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Drawing;25 using System.Linq;26 22 using HeuristicLab.Common; 27 23 using HeuristicLab.Core; … … 49 45 public SupportVectorRegressionSolution(SupportVectorMachineModel model, IRegressionProblemData problemData) 50 46 : base(model, problemData) { 47 RecalculateResults(); 51 48 } 52 49 … … 54 51 return new SupportVectorRegressionSolution(this, cloner); 55 52 } 53 54 protected override void RecalculateResults() { 55 base.CalculateResults(); 56 } 56 57 } 57 58 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionSolution.cs
r6411 r6588 62 62 Add(new Result(ModelLengthResultName, "Length of the symbolic regression model.", new IntValue())); 63 63 Add(new Result(ModelDepthResultName, "Depth of the symbolic regression model.", new IntValue())); 64 CalculateResults();64 RecalculateResults(); 65 65 } 66 66 … … 70 70 71 71 protected override void RecalculateResults() { 72 base.RecalculateResults();73 CalculateResults();74 }75 76 private void CalculateResults() {77 72 ModelLength = Model.SymbolicExpressionTree.Length; 78 73 ModelDepth = Model.SymbolicExpressionTree.Depth; 74 CalculateResults(); 79 75 } 80 76 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj
r6239 r6588 136 136 </Compile> 137 137 <Compile Include="Interfaces\Regression\IRegressionEnsembleSolution.cs" /> 138 <Compile Include="Implementation\Regression\RegressionSolutionBase.cs" /> 138 139 <Compile Include="OnlineCalculators\OnlineLinearScalingParameterCalculator.cs" /> 139 140 <Compile Include="Implementation\Classification\DiscriminantFunctionClassificationModel.cs" /> -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisSolution.cs
r6411 r6588 80 80 name = ItemName; 81 81 description = ItemDescription; 82 Add(new Result(ModelResultName, "The symbolicdata analysis model.", model));83 Add(new Result(ProblemDataResultName, "The symbolicdata analysis problem data.", problemData));82 Add(new Result(ModelResultName, "The data analysis model.", model)); 83 Add(new Result(ProblemDataResultName, "The data analysis problem data.", problemData)); 84 84 85 85 problemData.Changed += new EventHandler(ProblemData_Changed); -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionEnsembleSolution.cs
r6574 r6588 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Linq; 24 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; 27 using HeuristicLab.Data; 26 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 using System;28 using HeuristicLab.Data;29 29 30 30 namespace HeuristicLab.Problems.DataAnalysis { … … 80 80 public override IDeepCloneable Clone(Cloner cloner) { 81 81 return new RegressionEnsembleSolution(this, cloner); 82 } 83 84 protected override void RecalculateResults() { 85 CalculateResults(); 82 86 } 83 87 -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolution.cs
r6411 r6588 23 23 using System.Linq; 24 24 using HeuristicLab.Common; 25 using HeuristicLab.Data;26 using HeuristicLab.Optimization;27 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 26 … … 32 30 /// </summary> 33 31 [StorableClass] 34 public class RegressionSolution : DataAnalysisSolution, IRegressionSolution { 35 private const string TrainingMeanSquaredErrorResultName = "Mean squared error (training)"; 36 private const string TestMeanSquaredErrorResultName = "Mean squared error (test)"; 37 private const string TrainingSquaredCorrelationResultName = "Pearson's R² (training)"; 38 private const string TestSquaredCorrelationResultName = "Pearson's R² (test)"; 39 private const string TrainingRelativeErrorResultName = "Average relative error (training)"; 40 private const string TestRelativeErrorResultName = "Average relative error (test)"; 41 private const string TrainingNormalizedMeanSquaredErrorResultName = "Normalized mean squared error (training)"; 42 private const string TestNormalizedMeanSquaredErrorResultName = "Normalized mean squared error (test)"; 43 44 public new IRegressionModel Model { 45 get { return (IRegressionModel)base.Model; } 46 protected set { base.Model = value; } 47 } 48 49 public new IRegressionProblemData ProblemData { 50 get { return (IRegressionProblemData)base.ProblemData; } 51 protected set { base.ProblemData = value; } 52 } 53 54 public double TrainingMeanSquaredError { 55 get { return ((DoubleValue)this[TrainingMeanSquaredErrorResultName].Value).Value; } 56 private set { ((DoubleValue)this[TrainingMeanSquaredErrorResultName].Value).Value = value; } 57 } 58 59 public double TestMeanSquaredError { 60 get { return ((DoubleValue)this[TestMeanSquaredErrorResultName].Value).Value; } 61 private set { ((DoubleValue)this[TestMeanSquaredErrorResultName].Value).Value = value; } 62 } 63 64 public double TrainingRSquared { 65 get { return ((DoubleValue)this[TrainingSquaredCorrelationResultName].Value).Value; } 66 private set { ((DoubleValue)this[TrainingSquaredCorrelationResultName].Value).Value = value; } 67 } 68 69 public double TestRSquared { 70 get { return ((DoubleValue)this[TestSquaredCorrelationResultName].Value).Value; } 71 private set { ((DoubleValue)this[TestSquaredCorrelationResultName].Value).Value = value; } 72 } 73 74 public double TrainingRelativeError { 75 get { return ((DoubleValue)this[TrainingRelativeErrorResultName].Value).Value; } 76 private set { ((DoubleValue)this[TrainingRelativeErrorResultName].Value).Value = value; } 77 } 78 79 public double TestRelativeError { 80 get { return ((DoubleValue)this[TestRelativeErrorResultName].Value).Value; } 81 private set { ((DoubleValue)this[TestRelativeErrorResultName].Value).Value = value; } 82 } 83 84 public double TrainingNormalizedMeanSquaredError { 85 get { return ((DoubleValue)this[TrainingNormalizedMeanSquaredErrorResultName].Value).Value; } 86 private set { ((DoubleValue)this[TrainingNormalizedMeanSquaredErrorResultName].Value).Value = value; } 87 } 88 89 public double TestNormalizedMeanSquaredError { 90 get { return ((DoubleValue)this[TestNormalizedMeanSquaredErrorResultName].Value).Value; } 91 private set { ((DoubleValue)this[TestNormalizedMeanSquaredErrorResultName].Value).Value = value; } 92 } 93 94 32 public abstract class RegressionSolution : RegressionSolutionBase { 95 33 [StorableConstructor] 96 34 protected RegressionSolution(bool deserializing) : base(deserializing) { } … … 98 36 : base(original, cloner) { 99 37 } 100 p ublicRegressionSolution(IRegressionModel model, IRegressionProblemData problemData)38 protected RegressionSolution(IRegressionModel model, IRegressionProblemData problemData) 101 39 : base(model, problemData) { 102 Add(new Result(TrainingMeanSquaredErrorResultName, "Mean of squared errors of the model on the training partition", new DoubleValue()));103 Add(new Result(TestMeanSquaredErrorResultName, "Mean of squared errors of the model on the test partition", new DoubleValue()));104 Add(new Result(TrainingSquaredCorrelationResultName, "Squared Pearson's correlation coefficient of the model output and the actual values on the training partition", new DoubleValue()));105 Add(new Result(TestSquaredCorrelationResultName, "Squared Pearson's correlation coefficient of the model output and the actual values on the test partition", new DoubleValue()));106 Add(new Result(TrainingRelativeErrorResultName, "Average of the relative errors of the model output and the actual values on the training partition", new PercentValue()));107 Add(new Result(TestRelativeErrorResultName, "Average of the relative errors of the model output and the actual values on the test partition", new PercentValue()));108 Add(new Result(TrainingNormalizedMeanSquaredErrorResultName, "Normalized mean of squared errors of the model on the training partition", new DoubleValue()));109 Add(new Result(TestNormalizedMeanSquaredErrorResultName, "Normalized mean of squared errors of the model on the test partition", new DoubleValue()));110 111 CalculateResults();112 40 } 113 41 114 public override IDeepCloneable Clone(Cloner cloner) { 115 return new RegressionSolution(this, cloner); 42 public override IEnumerable<double> EstimatedValues { 43 get { return GetEstimatedValues(Enumerable.Range(0, ProblemData.Dataset.Rows)); } 44 } 45 public override IEnumerable<double> EstimatedTrainingValues { 46 get { return GetEstimatedValues(ProblemData.TrainingIndizes); } 47 } 48 public override IEnumerable<double> EstimatedTestValues { 49 get { return GetEstimatedValues(ProblemData.TestIndizes); } 116 50 } 117 51 118 protected override void RecalculateResults() { 119 CalculateResults(); 120 } 121 122 private void CalculateResults() { 123 double[] estimatedTrainingValues = EstimatedTrainingValues.ToArray(); // cache values 124 IEnumerable<double> originalTrainingValues = ProblemData.Dataset.GetEnumeratedVariableValues(ProblemData.TargetVariable, ProblemData.TrainingIndizes); 125 double[] estimatedTestValues = EstimatedTestValues.ToArray(); // cache values 126 IEnumerable<double> originalTestValues = ProblemData.Dataset.GetEnumeratedVariableValues(ProblemData.TargetVariable, ProblemData.TestIndizes); 127 128 OnlineCalculatorError errorState; 129 double trainingMSE = OnlineMeanSquaredErrorCalculator.Calculate(estimatedTrainingValues, originalTrainingValues, out errorState); 130 TrainingMeanSquaredError = errorState == OnlineCalculatorError.None ? trainingMSE : double.NaN; 131 double testMSE = OnlineMeanSquaredErrorCalculator.Calculate(estimatedTestValues, originalTestValues, out errorState); 132 TestMeanSquaredError = errorState == OnlineCalculatorError.None ? testMSE : double.NaN; 133 134 double trainingR2 = OnlinePearsonsRSquaredCalculator.Calculate(estimatedTrainingValues, originalTrainingValues, out errorState); 135 TrainingRSquared = errorState == OnlineCalculatorError.None ? trainingR2 : double.NaN; 136 double testR2 = OnlinePearsonsRSquaredCalculator.Calculate(estimatedTestValues, originalTestValues, out errorState); 137 TestRSquared = errorState == OnlineCalculatorError.None ? testR2 : double.NaN; 138 139 double trainingRelError = OnlineMeanAbsolutePercentageErrorCalculator.Calculate(estimatedTrainingValues, originalTrainingValues, out errorState); 140 TrainingRelativeError = errorState == OnlineCalculatorError.None ? trainingRelError : double.NaN; 141 double testRelError = OnlineMeanAbsolutePercentageErrorCalculator.Calculate(estimatedTestValues, originalTestValues, out errorState); 142 TestRelativeError = errorState == OnlineCalculatorError.None ? testRelError : double.NaN; 143 144 double trainingNMSE = OnlineNormalizedMeanSquaredErrorCalculator.Calculate(estimatedTrainingValues, originalTrainingValues, out errorState); 145 TrainingNormalizedMeanSquaredError = errorState == OnlineCalculatorError.None ? trainingNMSE : double.NaN; 146 double testNMSE = OnlineNormalizedMeanSquaredErrorCalculator.Calculate(estimatedTestValues, originalTestValues, out errorState); 147 TestNormalizedMeanSquaredError = errorState == OnlineCalculatorError.None ? testNMSE : double.NaN; 148 } 149 150 public virtual IEnumerable<double> EstimatedValues { 151 get { 152 return GetEstimatedValues(Enumerable.Range(0, ProblemData.Dataset.Rows)); 153 } 154 } 155 156 public virtual IEnumerable<double> EstimatedTrainingValues { 157 get { 158 return GetEstimatedValues(ProblemData.TrainingIndizes); 159 } 160 } 161 162 public virtual IEnumerable<double> EstimatedTestValues { 163 get { 164 return GetEstimatedValues(ProblemData.TestIndizes); 165 } 166 } 167 168 public virtual IEnumerable<double> GetEstimatedValues(IEnumerable<int> rows) { 52 public override IEnumerable<double> GetEstimatedValues(IEnumerable<int> rows) { 169 53 return Model.GetEstimatedValues(ProblemData.Dataset, rows); 170 54 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Regression/IRegressionSolution.cs
r5829 r6588 37 37 double TrainingRelativeError { get; } 38 38 double TestRelativeError { get; } 39 double TrainingNormalizedMeanSquaredError { get; } 40 double TestNormalizedMeanSquaredError { get; } 39 41 } 40 42 }
Note: See TracChangeset
for help on using the changeset viewer.