Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/03/09 15:00:23 (15 years ago)
Author:
gkronber
Message:

this is the remaining part of changeset r2327.
Applied changes in modeling plugins that are necessary for the new model analyzer (#722)

  • predictor has properties for the lower and upper limit of the predicted value
  • added views for predictors that show the limits (also added a new view for GeneticProgrammingModel that shows the size and height of the model)
  • Reintroduced TreeEvaluatorInjectors that read a PunishmentFactor and calculate the lower and upper limits for estimated values (limits are set in the tree evaluators)
  • Added operators to create Predictors. Changed modeling algorithms to use the predictors for the calculation of final model qualities and variable impacts (to be compatible with the new model analyzer the predictors use a very large PunishmentFactor)
  • replaced all private implementations of double.IsAlmost and use HL.Commons instead (see #733 r2324)
  • Implemented operator SolutionExtractor and moved BestSolutionStorer from HL.Logging to HL.Modeling (fixes #734)
Location:
trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/ClassificationMeanSquaredErrorEvaluator.cs

    r2222 r2328  
    2323using HeuristicLab.Core;
    2424using HeuristicLab.Data;
     25using HeuristicLab.Common;
    2526
    2627namespace HeuristicLab.GP.StructureIdentification.Classification {
     
    4950          // on the lower end and upper end only add linear error if the absolute error is larger than 1
    5051          // the error>1.0 constraint is needed for balance because in the interval ]-1, 1[ the squared error is smaller than the absolute error
    51           if ((IsEqual(original, classes[0]) && error < -1.0) ||
    52             (IsEqual(original, classes[classes.Length - 1]) && error > 1.0)) {
     52          if ((original.IsAlmost(classes[0]) && error < -1.0) ||
     53            (original.IsAlmost(classes[classes.Length - 1]) && error > 1.0)) {
    5354            errorsSquaredSum += Math.Abs(error); // only add linear error below the smallest class or above the largest class
    5455          } else {
     
    7172      mse.Data = errorsSquaredSum;
    7273    }
    73 
    74     private bool IsEqual(double x, double y) {
    75       return Math.Abs(x - y) < EPSILON;
    76     }
    7774  }
    7875}
  • trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/HeuristicLab.GP.StructureIdentification.Classification-3.3.csproj

    r2222 r2328  
    9494  </ItemGroup>
    9595  <ItemGroup>
     96    <ProjectReference Include="..\..\HeuristicLab.Common\3.2\HeuristicLab.Common-3.2.csproj">
     97      <Project>{1FC004FC-59AF-4249-B1B6-FF25873A20E4}</Project>
     98      <Name>HeuristicLab.Common-3.2</Name>
     99    </ProjectReference>
    96100    <ProjectReference Include="..\..\HeuristicLab.Core\3.2\HeuristicLab.Core-3.2.csproj">
    97101      <Project>{F43B59AB-2B8C-4570-BC1E-15592086517C}</Project>
  • trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/HeuristicLabGPClassificationPlugin.cs

    r2222 r2328  
    2828  [ClassInfo(Name = "HeuristicLab.GP.StructureIdentification.Classification-3.3")]
    2929  [PluginFile(Filename = "HeuristicLab.GP.StructureIdentification.Classification-3.3.dll", Filetype = PluginFileType.Assembly)]
     30  [Dependency(Dependency = "HeuristicLab.Common-3.2")]
    3031  [Dependency(Dependency = "HeuristicLab.Core-3.2")]
    3132  [Dependency(Dependency = "HeuristicLab.Data-3.2")]
  • trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/MulticlassModeller.cs

    r2222 r2328  
    2222using System;
    2323using System.Collections.Generic;
     24using HeuristicLab.Common;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.Data;
     
    8384            double[] row = new double[dataset.Columns];
    8485            double targetValue = origDataset.GetValue(k, targetVariable);
    85             if (IsEqual(targetValue, classAValue)) {
     86            if (targetValue.IsAlmost(classAValue)) {
    8687              for (int l = 0; l < row.Length; l++) {
    8788                row[l] = origDataset.GetValue(k, l);
     
    8990              row[targetVariable] = 0;
    9091              rows.Add(row);
    91             } else if (IsEqual(targetValue, classBValue)) {
     92            } else if (targetValue.IsAlmost(classBValue)) {
    9293              for (int l = 0; l < row.Length; l++) {
    9394                row[l] = origDataset.GetValue(k, l);
     
    102103            double[] row = new double[dataset.Columns];
    103104            double targetValue = origDataset.GetValue(k, targetVariable);
    104             if (IsEqual(targetValue, classAValue)) {
     105            if (targetValue.IsAlmost(classAValue)) {
    105106              for (int l = 0; l < row.Length; l++) {
    106107                row[l] = origDataset.GetValue(k, l);
     
    108109              row[targetVariable] = 0;
    109110              rows.Add(row);
    110             } else if (IsEqual(targetValue, classBValue)) {
     111            } else if (targetValue.IsAlmost(classBValue)) {
    111112              for (int l = 0; l < row.Length; l++) {
    112113                row[l] = origDataset.GetValue(k, l);
     
    141142      return null;
    142143    }
    143 
    144     private bool IsEqual(double x, double y) {
    145       return Math.Abs(x - y) < EPSILON;
    146     }
    147144  }
    148145}
  • trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/MulticlassOneVsOneAnalyzer.cs

    r2285 r2328  
    2525using HeuristicLab.DataAnalysis;
    2626using HeuristicLab.GP.Interfaces;
     27using HeuristicLab.Common;
    2728
    2829namespace HeuristicLab.GP.StructureIdentification.Classification {
     
    4445    private const string TREEEVALUATOR = "TreeEvaluator";
    4546
    46     private const double EPSILON = 1E-6;
    4747    public override string Description {
    4848      get { return @"TASK"; }
     
    5656      AddVariableInfo(new VariableInfo(CLASSAVALUE, "The original class value of the class A in the subscope", typeof(DoubleData), VariableKind.In));
    5757      AddVariableInfo(new VariableInfo(CLASSBVALUE, "The original class value of the class B in the subscope", typeof(DoubleData), VariableKind.In));
    58       AddVariableInfo(new VariableInfo(TRAININGSAMPLESSTART, "The start of training samples in the original dataset", typeof(IntData), VariableKind.In));
    59       AddVariableInfo(new VariableInfo(TRAININGSAMPLESEND, "The end of training samples in the original dataset", typeof(IntData), VariableKind.In));
    6058      AddVariableInfo(new VariableInfo(SAMPLESSTART, "The start of samples in the original dataset", typeof(IntData), VariableKind.In));
    6159      AddVariableInfo(new VariableInfo(SAMPLESEND, "The end of samples in the original dataset", typeof(IntData), VariableKind.In));
     
    8482
    8583        ITreeEvaluator evaluator = GetVariableValue<ITreeEvaluator>(TREEEVALUATOR, bestScope, true);
    86         evaluator.PrepareForEvaluation(dataset, targetVariable, trainingSamplesStart, trainingSamplesEnd, gpModel.FunctionTree);
     84        evaluator.PrepareForEvaluation(dataset, gpModel.FunctionTree);
    8785        for(int i = 0; i < (samplesEnd - samplesStart); i++) {
    8886          double est = evaluator.Evaluate(i + samplesStart);
     
    110108          }
    111109        }
    112         if(IsEqual(originalClassValue, estimatedClassValue) && sameVotes == 0) correctlyClassified++;
     110        if(originalClassValue.IsAlmost(estimatedClassValue) && sameVotes == 0) correctlyClassified++;
    113111      }
    114112
     
    122120    private void CastVote(int[,] votes, int sample, double votedClass, ItemList<DoubleData> classValues) {
    123121      for(int i = 0; i < classValues.Count; i++) {
    124         if(IsEqual(classValues[i].Data, votedClass)) votes[sample, i]++;
     122        if(classValues[i].Data.IsAlmost(votedClass)) votes[sample, i]++;
    125123      }
    126     }
    127 
    128     private bool IsEqual(double x, double y) {
    129       return Math.Abs(x - y) < EPSILON;
    130124    }
    131125  }
Note: See TracChangeset for help on using the changeset viewer.