Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/20/09 12:52:52 (15 years ago)
Author:
gkronber
Message:

Moved simple evaluators from plugin SVM to plugin Modeling. #635

Location:
trunk/sources/HeuristicLab.Modeling/3.2
Files:
1 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Modeling/3.2/HeuristicLab.Modeling-3.2.csproj

    r1857 r1869  
    9696    </Compile>
    9797    <Compile Include="Properties\AssemblyInfo.cs" />
     98    <Compile Include="SimpleMSEEvaluator.cs" />
     99    <Compile Include="SimpleR2Evaluator.cs" />
    98100    <Compile Include="TimeSeriesProblemInjector.cs" />
    99101  </ItemGroup>
  • trunk/sources/HeuristicLab.Modeling/3.2/SimpleMSEEvaluator.cs

    r1854 r1869  
    77using HeuristicLab.DataAnalysis;
    88
    9 namespace HeuristicLab.SupportVectorMachines {
    10   public class SimpleMSEEvaluator : OperatorBase{
     9namespace HeuristicLab.Modeling {
     10  public class SimpleMSEEvaluator : OperatorBase {
    1111
    1212    public SimpleMSEEvaluator()
    1313      : base() {
    14       AddVariableInfo(new VariableInfo("Values", "Target vs predicted values", typeof(ItemList), VariableKind.In));
     14      AddVariableInfo(new VariableInfo("Values", "Target vs predicted values", typeof(DoubleMatrixData), VariableKind.In));
    1515      AddVariableInfo(new VariableInfo("MSE", "Mean squarred error", typeof(DoubleData), VariableKind.New | VariableKind.Out));
    1616    }
    1717
    1818    public override IOperation Apply(IScope scope) {
    19       ItemList values = GetVariableValue<ItemList>("Values", scope, true);
     19      DoubleMatrixData values = GetVariableValue<DoubleMatrixData>("Values", scope, true);
    2020      double sse = 0;
    21       double cnt = 0;     
    22       foreach (ItemList row in values) {
    23         double estimated = ((DoubleData)row[0]).Data;
    24         double target = ((DoubleData)row[1]).Data;
     21      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];
    2525        if (!double.IsNaN(estimated) && !double.IsInfinity(estimated) &&
    2626            !double.IsNaN(target) && !double.IsInfinity(target)) {
     
    3232
    3333      double mse = sse / cnt;
    34       scope.AddVariable(new Variable(scope.TranslateName("MSE"),new DoubleData(mse)));
     34      scope.AddVariable(new Variable(scope.TranslateName("MSE"), new DoubleData(mse)));
    3535      return null;
    3636    }
  • trunk/sources/HeuristicLab.Modeling/3.2/SimpleR2Evaluator.cs

    r1854 r1869  
    77using HeuristicLab.DataAnalysis;
    88
    9 namespace HeuristicLab.SupportVectorMachines {
    10   public class SimpleR2Evaluator : OperatorBase{
     9namespace HeuristicLab.Modeling {
     10  public class SimpleR2Evaluator : OperatorBase {
    1111
    1212    public SimpleR2Evaluator()
    1313      : base() {
    14       AddVariableInfo(new VariableInfo("Values", "Target vs predicted values", typeof(ItemList), VariableKind.In));
     14      AddVariableInfo(new VariableInfo("Values", "Target vs predicted values", typeof(DoubleMatrixData), VariableKind.In));
    1515      AddVariableInfo(new VariableInfo("R2", "Coefficient of determination", typeof(DoubleData), VariableKind.New | VariableKind.Out));
    1616    }
    1717
    1818    public override IOperation Apply(IScope scope) {
    19       ItemList values = GetVariableValue<ItemList>("Values", scope, true);
     19      DoubleMatrixData values = GetVariableValue<DoubleMatrixData>("Values", scope, true);
    2020
    2121      double targetMean = 0;
    2222      double sse = 0;
    2323      double cnt = 0;
    24       foreach (ItemList row in values) {                               
    25         double estimated = ((DoubleData)row[0]).Data;
    26         double target = ((DoubleData)row[1]).Data;
     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];
    2727        if (!double.IsNaN(estimated) && !double.IsInfinity(estimated) &&
    2828            !double.IsNaN(target) && !double.IsInfinity(target)) {
     
    3636
    3737      double targetDeviationTotalSumOfSquares = 0;
    38       foreach (ItemList row in values) {
    39         double target = ((DoubleData)row[1]).Data;
     38      for (int i = 0; i < values.Data.GetLength(0); i++) {
     39        double target = values.Data[i, 1];
    4040        if (!double.IsNaN(target) && !double.IsInfinity(target)) {
    4141          target = target - targetMean;
Note: See TracChangeset for help on using the changeset viewer.