Changeset 1888
- Timestamp:
- 05/25/09 15:09:44 (16 years ago)
- Location:
- trunk/sources/HeuristicLab.Modeling/3.2
- Files:
-
- 4 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Modeling/3.2/HeuristicLab.Modeling-3.2.csproj
r1869 r1888 83 83 <ItemGroup> 84 84 <Compile Include="ClassificationProblemInjector.cs" /> 85 <Compile Include="SimpleEvaluatorBase.cs" /> 85 86 <Compile Include="ITimeSeriesAlgorithm.cs" /> 86 87 <Compile Include="IClassificationAlgorithm.cs" /> … … 88 89 <Compile Include="HeuristicLabModelingPlugin.cs" /> 89 90 <Compile Include="IAlgorithm.cs" /> 91 <Compile Include="SimpleMeanAbsolutePercentageErrorEvaluator.cs" /> 92 <Compile Include="SimpleMeanAbsolutePercentageOfRangeErrorEvaluator.cs" /> 90 93 <Compile Include="ProblemInjector.cs" /> 91 94 <Compile Include="ProblemInjectorView.cs"> … … 99 102 <Compile Include="SimpleR2Evaluator.cs" /> 100 103 <Compile Include="TimeSeriesProblemInjector.cs" /> 104 <Compile Include="SimpleVarianceAccountedForEvaluator.cs" /> 101 105 </ItemGroup> 102 106 <ItemGroup> -
trunk/sources/HeuristicLab.Modeling/3.2/SimpleMSEEvaluator.cs
r1869 r1888 8 8 9 9 namespace HeuristicLab.Modeling { 10 public class SimpleMSEEvaluator : OperatorBase {10 public class SimpleMSEEvaluator : SimpleEvaluatorBase { 11 11 12 public SimpleMSEEvaluator() 13 : base() { 14 AddVariableInfo(new VariableInfo("Values", "Target vs predicted values", typeof(DoubleMatrixData), VariableKind.In)); 15 AddVariableInfo(new VariableInfo("MSE", "Mean squarred error", typeof(DoubleData), VariableKind.New | VariableKind.Out)); 12 public override string OutputVariableName { 13 get { 14 return "MSE"; 15 } 16 } 17 public override double Evaluate(double[,] values) { 18 return Calculate(values); 16 19 } 17 20 18 public override IOperation Apply(IScope scope) { 19 DoubleMatrixData values = GetVariableValue<DoubleMatrixData>("Values", scope, true); 21 public static double Calculate(double[,] values) { 20 22 double sse = 0; 21 23 double cnt = 0; 22 for (int i = 0; i < values. Data.GetLength(0); i++) {23 double estimated = values .Data[i, 0];24 double target = values .Data[i, 1];24 for (int i = 0; i < values.GetLength(0); i++) { 25 double estimated = values[i, 0]; 26 double target = values[i, 1]; 25 27 if (!double.IsNaN(estimated) && !double.IsInfinity(estimated) && 26 28 !double.IsNaN(target) && !double.IsInfinity(target)) { … … 32 34 33 35 double mse = sse / cnt; 34 scope.AddVariable(new Variable(scope.TranslateName("MSE"), new DoubleData(mse))); 35 return null; 36 return mse; 36 37 } 37 38 } -
trunk/sources/HeuristicLab.Modeling/3.2/SimpleR2Evaluator.cs
r1869 r1888 8 8 9 9 namespace HeuristicLab.Modeling { 10 public class SimpleR2Evaluator : OperatorBase {10 public class SimpleR2Evaluator : SimpleEvaluatorBase { 11 11 12 public SimpleR2Evaluator()13 : base(){14 AddVariableInfo(new VariableInfo("Values", "Target vs predicted values", typeof(DoubleMatrixData), VariableKind.In));15 AddVariableInfo(new VariableInfo("R2", "Coefficient of determination", typeof(DoubleData), VariableKind.New | VariableKind.Out));12 public override string OutputVariableName { 13 get { 14 return "R2"; 15 } 16 16 } 17 17 18 public override IOperation Apply(IScope scope) { 19 DoubleMatrixData values = GetVariableValue<DoubleMatrixData>("Values", scope, true); 18 public override double Evaluate(double[,] values) { 19 return Calculate(values); 20 } 20 21 22 public static double Calculate(double[,] values) { 21 23 double targetMean = 0; 22 24 double sse = 0; 23 25 double cnt = 0; 24 for (int i = 0; i < values. Data.GetLength(0); i++) {25 double estimated = values .Data[i, 0];26 double target = values .Data[i, 1];26 for (int i = 0; i < values.GetLength(0); i++) { 27 double estimated = values[i, 0]; 28 double target = values[i, 1]; 27 29 if (!double.IsNaN(estimated) && !double.IsInfinity(estimated) && 28 30 !double.IsNaN(target) && !double.IsInfinity(target)) { … … 36 38 37 39 double targetDeviationTotalSumOfSquares = 0; 38 for (int i = 0; i < values. Data.GetLength(0); i++) {39 double target = values .Data[i, 1];40 for (int i = 0; i < values.GetLength(0); i++) { 41 double target = values[i, 1]; 40 42 if (!double.IsNaN(target) && !double.IsInfinity(target)) { 41 43 target = target - targetMean; … … 48 50 throw new InvalidProgramException(); 49 51 50 scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("R2"), new DoubleData(quality))); 51 return null; 52 return quality; 52 53 } 53 54 }
Note: See TracChangeset
for help on using the changeset viewer.