Changeset 4194 for branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.Regression/3.3/Symbolic/Evaluators
- Timestamp:
- 08/11/10 13:00:53 (14 years ago)
- Location:
- branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.Regression
- Files:
-
- 4 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.Regression/3.3/Symbolic/Evaluators/SymbolicVectorRegressionEvaluator.cs
r4068 r4194 105 105 #endregion 106 106 107 public SymbolicVectorRegressionEvaluator(bool deserializing) : base(deserializing) { } 107 108 public SymbolicVectorRegressionEvaluator() 108 109 : base() { … … 118 119 } 119 120 120 public override IOperation Apply() { 121 var interpreter = SymbolicExpressionTreeInterpreter; 122 var tree = SymbolicExpressionTree; 123 var problemData = MultiVariateDataAnalysisProblemData; 124 125 IEnumerable<string> selectedTargetVariables = 126 problemData.TargetVariables.CheckedItems 127 .Select(x => x.Value.Value); 128 129 // check if there is a vector component for each target variable 130 if (selectedTargetVariables.Count() != tree.Root.SubTrees[0].SubTrees.Count) 131 throw new ArgumentException("The dimension of the output-vector of the tree doesn't match the number of selected target variables."); 132 int start = SamplesStart.Value; 133 int end = SamplesEnd.Value; 134 135 IEnumerable<int> rows = GenerateRowsToEvaluate((uint)Random.Next(), RelativeNumberOfEvaluatedSamples.Value, start, end); 136 137 Evaluate(tree, interpreter, problemData, selectedTargetVariables, rows, LowerEstimationLimit, UpperEstimationLimit); 138 139 return base.Apply(); 140 } 141 142 public abstract void Evaluate(SymbolicExpressionTree tree, ISymbolicExpressionTreeInterpreter interpreter, MultiVariateDataAnalysisProblemData problemData, IEnumerable<string> targetVariables, IEnumerable<int> rows, DoubleArray lowerEstimationBound, DoubleArray upperEstimationBound); 143 144 private static IEnumerable<int> GenerateRowsToEvaluate(uint seed, double relativeAmount, int start, int end) { 121 public static IEnumerable<int> GenerateRowsToEvaluate(uint seed, double relativeAmount, int start, int end) { 145 122 if (end < start) throw new ArgumentException("Start value is larger than end value."); 146 123 int count = (int)((end - start) * relativeAmount); -
branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.Regression/3.3/Symbolic/Evaluators/SymbolicVectorRegressionNormalizedMseEvaluator.cs
r4112 r4194 34 34 [Item("SymbolicVectorRegressionNormalizedMseEvaluator", "Represents an operator that calculates the sum of the normalized mean squared error over all components.")] 35 35 [StorableClass] 36 public class SymbolicVectorRegressionNormalizedMseEvaluator : SymbolicVectorRegressionEvaluator, ISingleObjectiveSymbolicVectorRegressionEvaluator { 37 private const string QualityParameterName = "ScaledNormalizedMeanSquaredError"; 36 public class SymbolicVectorRegressionNormalizedMseEvaluator : SingleObjectiveSymbolicVectorRegressionEvaluator { 38 37 39 #region parameter properties 40 public ILookupParameter<DoubleValue> QualityParameter { 41 get { return (ILookupParameter<DoubleValue>)Parameters[QualityParameterName]; } 38 39 public SymbolicVectorRegressionNormalizedMseEvaluator(bool deserializing) : base(deserializing) { } 40 public SymbolicVectorRegressionNormalizedMseEvaluator() 41 : base() { 42 42 } 43 43 44 #endregion 45 46 public SymbolicVectorRegressionNormalizedMseEvaluator() 47 : base() { 48 Parameters.Add(new LookupParameter<DoubleValue>(QualityParameterName, "The sum of the normalized mean squared error over all components of the symbolic vector regression solution encoded as a symbolic expression tree.")); 49 } 50 51 public override void Evaluate(SymbolicExpressionTree tree, ISymbolicExpressionTreeInterpreter interpreter, MultiVariateDataAnalysisProblemData problemData, IEnumerable<string> targetVariables, IEnumerable<int> rows, DoubleArray lowerEstimationBound, DoubleArray upperEstimationBound) { 52 double nmse = Calculate(tree, interpreter, problemData, targetVariables, rows, lowerEstimationBound, upperEstimationBound); 53 QualityParameter.ActualValue = new DoubleValue(nmse); 44 public override double Evaluate(SymbolicExpressionTree tree, ISymbolicExpressionTreeInterpreter interpreter, MultiVariateDataAnalysisProblemData problemData, IEnumerable<string> targetVariables, IEnumerable<int> rows, DoubleArray lowerEstimationBound, DoubleArray upperEstimationBound) { 45 return Calculate(tree, interpreter, problemData, targetVariables, rows, lowerEstimationBound, upperEstimationBound); 54 46 } 55 47 -
branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.Regression/3.3/Symbolic/Evaluators/SymbolicVectorRegressionScaledMseEvaluator.cs
r4112 r4194 34 34 [Item("SymbolicVectorRegressionScaledMseEvaluator", "Represents an operator that calculates the scaled mean squared error for all components independently.")] 35 35 [StorableClass] 36 public class SymbolicVectorRegressionScaledMseEvaluator : SymbolicVectorRegressionEvaluator, IMultiObjectiveSymbolicVectorRegressionEvaluator { 37 private const string QualitiesParameterName = "ScaledMeanSquaredErrors"; 36 public class SymbolicVectorRegressionScaledMseEvaluator : MultiObjectiveSymbolicVectorRegressionEvaluator { 38 37 private const string AlphaParameterName = "Alpha"; 39 38 private const string BetaParameterName = "Beta"; 40 39 41 40 #region parameter properties 42 public ILookupParameter<DoubleArray> QualitiesParameter {43 get { return (ILookupParameter<DoubleArray>)Parameters[QualitiesParameterName]; }44 }45 41 public ILookupParameter<DoubleArray> AlphaParameter { 46 42 get { return (ILookupParameter<DoubleArray>)Parameters[AlphaParameterName]; } … … 54 50 public SymbolicVectorRegressionScaledMseEvaluator() 55 51 : base() { 56 Parameters.Add(new LookupParameter<DoubleArray>(QualitiesParameterName, "The mean squared errors for each component of the symbolic vector regression solution encoded as a symbolic expression tree."));57 52 Parameters.Add(new LookupParameter<DoubleArray>(AlphaParameterName, "The alpha parameter for linear scaling.")); 58 53 Parameters.Add(new LookupParameter<DoubleArray>(BetaParameterName, "The beta parameter for linear scaling.")); 59 54 } 60 55 61 public override voidEvaluate(SymbolicExpressionTree tree, ISymbolicExpressionTreeInterpreter interpreter, MultiVariateDataAnalysisProblemData problemData, IEnumerable<string> targetVariables, IEnumerable<int> rows, DoubleArray lowerEstimationBound, DoubleArray upperEstimationBound) {56 public override double[] Evaluate(SymbolicExpressionTree tree, ISymbolicExpressionTreeInterpreter interpreter, MultiVariateDataAnalysisProblemData problemData, IEnumerable<string> targetVariables, IEnumerable<int> rows, DoubleArray lowerEstimationBound, DoubleArray upperEstimationBound) { 62 57 List<string> targetVariablesList = targetVariables.ToList(); 63 DoubleArray qualities = new DoubleArray(targetVariables.Count());58 double[] qualities = new double[targetVariables.Count()]; 64 59 DoubleArray alpha = new DoubleArray(qualities.Length); 65 60 DoubleArray beta = new DoubleArray(qualities.Length); … … 87 82 } 88 83 89 QualitiesParameter.ActualValue = qualities;90 84 AlphaParameter.ActualValue = alpha; 91 85 BetaParameter.ActualValue = beta; 86 return qualities; 92 87 } 93 88 } -
branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.MultiVariate.Regression/3.3/Symbolic/Evaluators/SymbolicVectorRegressionScaledNormalizedMseEvaluator.cs
r4112 r4194 34 34 [Item("SymbolicVectorRegressionScaledNormalizedMseEvaluator", "Represents an operator that calculates the sum of the normalized mean squared error over all components.")] 35 35 [StorableClass] 36 public class SymbolicVectorRegressionScaledNormalizedMseEvaluator : SymbolicVectorRegressionEvaluator, ISingleObjectiveSymbolicVectorRegressionEvaluator { 37 private const string QualityParameterName = "ScaledNormalizedMeanSquaredError"; 36 public class SymbolicVectorRegressionScaledNormalizedMseEvaluator : SingleObjectiveSymbolicVectorRegressionEvaluator { 38 37 private const string AlphaParameterName = "Alpha"; 39 38 private const string BetaParameterName = "Beta"; 40 39 41 40 #region parameter properties 42 public ILookupParameter<DoubleValue> QualityParameter {43 get { return (ILookupParameter<DoubleValue>)Parameters[QualityParameterName]; }44 }45 41 public ILookupParameter<DoubleArray> AlphaParameter { 46 42 get { return (ILookupParameter<DoubleArray>)Parameters[AlphaParameterName]; } … … 54 50 public SymbolicVectorRegressionScaledNormalizedMseEvaluator() 55 51 : base() { 56 Parameters.Add(new LookupParameter<DoubleValue>(QualityParameterName, "The sum of the normalized mean squared error over all components of the symbolic vector regression solution encoded as a symbolic expression tree."));57 52 Parameters.Add(new LookupParameter<DoubleArray>(AlphaParameterName, "The alpha parameter for linear scaling.")); 58 53 Parameters.Add(new LookupParameter<DoubleArray>(BetaParameterName, "The beta parameter for linear scaling.")); 59 54 } 60 55 61 public override voidEvaluate(SymbolicExpressionTree tree, ISymbolicExpressionTreeInterpreter interpreter, MultiVariateDataAnalysisProblemData problemData, IEnumerable<string> targetVariables, IEnumerable<int> rows, DoubleArray lowerEstimationBound, DoubleArray upperEstimationBound) {56 public override double Evaluate(SymbolicExpressionTree tree, ISymbolicExpressionTreeInterpreter interpreter, MultiVariateDataAnalysisProblemData problemData, IEnumerable<string> targetVariables, IEnumerable<int> rows, DoubleArray lowerEstimationBound, DoubleArray upperEstimationBound) { 62 57 List<string> targetVariablesList = targetVariables.ToList(); 63 58 double nmseSum = 0.0; … … 87 82 AlphaParameter.ActualValue = alpha; 88 83 BetaParameter.ActualValue = beta; 89 QualityParameter.ActualValue = new DoubleValue(nmseSum);84 return nmseSum; 90 85 } 91 86 }
Note: See TracChangeset
for help on using the changeset viewer.