- Timestamp:
- 05/25/09 15:09:44 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.