Last change
on this file since 2893 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 | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using HeuristicLab.Core;
|
---|
6 | using HeuristicLab.Data;
|
---|
7 | using HeuristicLab.DataAnalysis;
|
---|
8 |
|
---|
9 | namespace 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.