Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Modeling/3.2/SimpleEvaluatorBase.cs @ 2421

Last change on this file since 2421 was 2357, checked in by gkronber, 15 years ago

Fixed #740 (SimpleEvaluators in HL.GP.StructId and HL.SVM are not compatible with evaluators in HL.Modeling).

File size: 1.3 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.Core;
6using HeuristicLab.Data;
7using HeuristicLab.DataAnalysis;
8
9namespace HeuristicLab.Modeling {
10  public abstract class SimpleEvaluatorBase : OperatorBase {
11    protected const int ORIGINAL_INDEX = 0;
12    protected const int ESTIMATION_INDEX = 1;
13
14    public virtual string OutputVariableName {
15      get { return "Quality"; }
16    }
17    public SimpleEvaluatorBase()
18      : base() {
19      AddVariableInfo(new VariableInfo("Values", "Target vs predicted values", typeof(DoubleMatrixData), VariableKind.In));
20      AddVariableInfo(new VariableInfo(OutputVariableName, OutputVariableName, typeof(DoubleData), VariableKind.New | VariableKind.Out));
21    }
22
23    public override IOperation Apply(IScope scope) {
24      DoubleMatrixData values = GetVariableValue<DoubleMatrixData>("Values", scope, true);
25      DoubleData quality = GetVariableValue<DoubleData>(OutputVariableName, scope, false, false);
26      if (quality == null) {
27        quality = new DoubleData();
28        scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName(OutputVariableName), quality));
29      }
30
31      quality.Data = Evaluate(values.Data);
32      return null;
33    }
34
35    public abstract double Evaluate(double[,] values);
36  }
37}
Note: See TracBrowser for help on using the repository browser.