Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/03/09 12:26:42 (15 years ago)
Author:
gkronber
Message:

Merged changes from GP-refactoring branch back into the trunk #713.

Location:
trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3
Files:
12 edited

Legend:

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

    r1891 r2222  
    2121
    2222using System;
    23 using System.Collections.Generic;
    24 using System.Linq;
    25 using System.Text;
    2623using HeuristicLab.Core;
    2724using HeuristicLab.Data;
    28 using HeuristicLab.GP.StructureIdentification;
    2925using HeuristicLab.DataAnalysis;
    3026
  • trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/ClassificationMeanSquaredErrorEvaluator.cs

    r1891 r2222  
    2121
    2222using System;
    23 using System.Collections.Generic;
    24 using System.Linq;
    25 using System.Text;
    2623using HeuristicLab.Core;
    2724using HeuristicLab.Data;
    28 using HeuristicLab.GP.StructureIdentification;
    2925
    3026namespace HeuristicLab.GP.StructureIdentification.Classification {
  • trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/ConfusionMatrixEvaluator.cs

    r1891 r2222  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Linq;
    25 using System.Text;
    2622using HeuristicLab.Core;
    2723using HeuristicLab.Data;
    28 using HeuristicLab.GP.StructureIdentification;
    2924
    3025namespace HeuristicLab.GP.StructureIdentification.Classification {
  • trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/CrossValidation.cs

    r1529 r2222  
    2121
    2222using System;
    23 using System.Collections.Generic;
    24 using System.Text;
    25 using System.Xml;
    2623using HeuristicLab.Core;
    2724using HeuristicLab.Data;
    2825using HeuristicLab.DataAnalysis;
    2926
    30 namespace HeuristicLab.GP.StructureIdentification.Classification
    31 {
    32     public class CrossValidation : OperatorBase
    33     {
     27namespace HeuristicLab.GP.StructureIdentification.Classification {
     28  public class CrossValidation : OperatorBase {
    3429
    35         private const string DATASET = "Dataset";
    36         private const string NFOLD = "n-Fold";
    37         private const string TRAININGSAMPLESSTART = "TrainingSamplesStart";
    38         private const string TRAININGSAMPLESEND = "TrainingSamplesEnd";
    39         private const string VALIDATIONSAMPLESSTART = "ValidationSamplesStart";
    40         private const string VALIDATIONSAMPLESEND = "ValidationSamplesEnd";
    41         private const string TESTSAMPLESSTART = "TestSamplesStart";
    42         private const string TESTSAMPLESEND = "TestSamplesEnd";
     30    private const string DATASET = "Dataset";
     31    private const string NFOLD = "n-Fold";
     32    private const string TRAININGSAMPLESSTART = "TrainingSamplesStart";
     33    private const string TRAININGSAMPLESEND = "TrainingSamplesEnd";
     34    private const string VALIDATIONSAMPLESSTART = "ValidationSamplesStart";
     35    private const string VALIDATIONSAMPLESEND = "ValidationSamplesEnd";
     36    private const string TESTSAMPLESSTART = "TestSamplesStart";
     37    private const string TESTSAMPLESEND = "TestSamplesEnd";
    4338
    44         public override string Description
    45         {
    46             get { return @"TASK"; }
    47         }
     39    public override string Description {
     40      get { return @"TASK"; }
     41    }
    4842
    49         public CrossValidation()
    50             : base()
    51         {
    52             AddVariableInfo(new VariableInfo(DATASET, "The original dataset and the new datasets in the newly created subscopes", typeof(Dataset), VariableKind.In));
    53             AddVariableInfo(new VariableInfo(NFOLD, "Number of folds for the cross-validation", typeof(IntData), VariableKind.In));
    54             AddVariableInfo(new VariableInfo(TRAININGSAMPLESSTART, "The start of training samples in the original dataset and starts of training samples in the new datasets", typeof(IntData), VariableKind.In | VariableKind.New));
    55             AddVariableInfo(new VariableInfo(TRAININGSAMPLESEND, "The end of training samples in the original dataset and ends of training samples in the new datasets", typeof(IntData), VariableKind.In | VariableKind.New));
    56             AddVariableInfo(new VariableInfo(VALIDATIONSAMPLESSTART, "The start of validation samples in the original dataset and starts of validation samples in the new datasets", typeof(IntData), VariableKind.In | VariableKind.New));
    57             AddVariableInfo(new VariableInfo(VALIDATIONSAMPLESEND, "The end of validation samples in the original dataset and ends of validation samples in the new datasets", typeof(IntData), VariableKind.In | VariableKind.New));
    58             AddVariableInfo(new VariableInfo(TESTSAMPLESSTART, "The start of the test samples in the new datasets", typeof(IntData), VariableKind.New));
    59             AddVariableInfo(new VariableInfo(TESTSAMPLESEND, "The end of the test samples in the new datasets", typeof(IntData), VariableKind.New));
    60         }
     43    public CrossValidation()
     44      : base() {
     45      AddVariableInfo(new VariableInfo(DATASET, "The original dataset and the new datasets in the newly created subscopes", typeof(Dataset), VariableKind.In));
     46      AddVariableInfo(new VariableInfo(NFOLD, "Number of folds for the cross-validation", typeof(IntData), VariableKind.In));
     47      AddVariableInfo(new VariableInfo(TRAININGSAMPLESSTART, "The start of training samples in the original dataset and starts of training samples in the new datasets", typeof(IntData), VariableKind.In | VariableKind.New));
     48      AddVariableInfo(new VariableInfo(TRAININGSAMPLESEND, "The end of training samples in the original dataset and ends of training samples in the new datasets", typeof(IntData), VariableKind.In | VariableKind.New));
     49      AddVariableInfo(new VariableInfo(VALIDATIONSAMPLESSTART, "The start of validation samples in the original dataset and starts of validation samples in the new datasets", typeof(IntData), VariableKind.In | VariableKind.New));
     50      AddVariableInfo(new VariableInfo(VALIDATIONSAMPLESEND, "The end of validation samples in the original dataset and ends of validation samples in the new datasets", typeof(IntData), VariableKind.In | VariableKind.New));
     51      AddVariableInfo(new VariableInfo(TESTSAMPLESSTART, "The start of the test samples in the new datasets", typeof(IntData), VariableKind.New));
     52      AddVariableInfo(new VariableInfo(TESTSAMPLESEND, "The end of the test samples in the new datasets", typeof(IntData), VariableKind.New));
     53    }
    6154
    62         public override IOperation Apply(IScope scope) {
     55    public override IOperation Apply(IScope scope) {
    6356      Dataset origDataset = GetVariableValue<Dataset>(DATASET, scope, true);
    6457      int nFolds = GetVariableValue<IntData>(NFOLD, scope, true).Data;
    65       if (nFolds < 2) throw new ArgumentException("The number of folds (nFolds) has to be >=2 for cross validation"); 
     58      if (nFolds < 2) throw new ArgumentException("The number of folds (nFolds) has to be >=2 for cross validation");
    6659      int origTrainingSamplesStart = GetVariableValue<IntData>(TRAININGSAMPLESSTART, scope, true).Data;
    6760      int origTrainingSamplesEnd = GetVariableValue<IntData>(TRAININGSAMPLESEND, scope, true).Data;
    6861      int origValidationSamplesStart = GetVariableValue<IntData>(VALIDATIONSAMPLESSTART, scope, true).Data;
    6962      int origValidationSamplesEnd = GetVariableValue<IntData>(VALIDATIONSAMPLESEND, scope, true).Data;
    70       int n=origDataset.Rows;
    71       int origTrainingSamples = (origTrainingSamplesEnd-origTrainingSamplesStart);
    72       int origValidationSamples = (origValidationSamplesEnd-origValidationSamplesStart);
     63      int n = origDataset.Rows;
     64      int origTrainingSamples = (origTrainingSamplesEnd - origTrainingSamplesStart);
     65      int origValidationSamples = (origValidationSamplesEnd - origValidationSamplesStart);
    7366
    7467      double percentTrainingSamples = origTrainingSamples / (double)(origValidationSamples + origTrainingSamples);
     
    8275      int newTestSamplesEnd = n;
    8376
    84       for(int i = 0; i < nFolds; i++) {
     77      for (int i = 0; i < nFolds; i++) {
    8578        Scope childScope = new Scope(i.ToString());
    8679        Dataset rotatedSet = new Dataset();
     
    10699    }
    107100
    108         private void RotateArray(double[] samples, int p)
    109         {
    110             Array.Reverse(samples, 0, p);
    111             Array.Reverse(samples, p, samples.Length - p);
    112             Array.Reverse(samples);
    113         }
     101    private void RotateArray(double[] samples, int p) {
     102      Array.Reverse(samples, 0, p);
     103      Array.Reverse(samples, p, samples.Length - p);
     104      Array.Reverse(samples);
    114105    }
     106  }
    115107}
  • trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/GPClassificationEvaluatorBase.cs

    r1891 r2222  
    2121
    2222using System;
    23 using System.Collections.Generic;
    24 using System.Linq;
    25 using System.Text;
    2623using HeuristicLab.Core;
    2724using HeuristicLab.Data;
    28 using HeuristicLab.GP.StructureIdentification;
    2925using HeuristicLab.DataAnalysis;
    3026
  • trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/HeuristicLab.GP.StructureIdentification.Classification-3.3.csproj

    r1856 r2222  
    9494  </ItemGroup>
    9595  <ItemGroup>
    96     <ProjectReference Include="..\..\HeuristicLab.Constraints\3.2\HeuristicLab.Constraints-3.2.csproj">
    97       <Project>{FCD62C6F-4793-4593-AE9A-0BDCA256EE99}</Project>
    98       <Name>HeuristicLab.Constraints-3.2</Name>
    99     </ProjectReference>
    10096    <ProjectReference Include="..\..\HeuristicLab.Core\3.2\HeuristicLab.Core-3.2.csproj">
    10197      <Project>{F43B59AB-2B8C-4570-BC1E-15592086517C}</Project>
     
    109105      <Project>{F473D9AF-3F09-4296-9F28-3C65118DAFFA}</Project>
    110106      <Name>HeuristicLab.Data-3.2</Name>
     107    </ProjectReference>
     108    <ProjectReference Include="..\..\HeuristicLab.GP.Interfaces\3.3\HeuristicLab.GP.Interfaces-3.3.csproj">
     109      <Project>{924B6BEA-9A99-40FE-9334-5C01E8D540EC}</Project>
     110      <Name>HeuristicLab.GP.Interfaces-3.3</Name>
    111111    </ProjectReference>
    112112    <ProjectReference Include="..\..\HeuristicLab.GP.StructureIdentification\3.3\HeuristicLab.GP.StructureIdentification-3.3.csproj">
  • trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/HeuristicLabGPClassificationPlugin.cs

    r1873 r2222  
    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.Constraints-3.2")]
    3130  [Dependency(Dependency = "HeuristicLab.Core-3.2")]
    3231  [Dependency(Dependency = "HeuristicLab.Data-3.2")]
    3332  [Dependency(Dependency = "HeuristicLab.DataAnalysis-3.2")]
    3433  [Dependency(Dependency = "HeuristicLab.GP-3.3")]
     34  [Dependency(Dependency = "HeuristicLab.GP.Interfaces-3.3")]
    3535  [Dependency(Dependency = "HeuristicLab.GP.StructureIdentification-3.3")]
    3636  [Dependency(Dependency = "HeuristicLab.Modeling-3.2")]
  • trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/MulticlassModeller.cs

    r1529 r2222  
    2222using System;
    2323using System.Collections.Generic;
    24 using System.Text;
    25 using System.Xml;
    2624using HeuristicLab.Core;
    2725using HeuristicLab.Data;
  • trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/MulticlassOneVsOneAnalyzer.cs

    r2034 r2222  
    2121
    2222using System;
    23 using System.Collections.Generic;
    24 using System.Text;
    25 using System.Xml;
    2623using HeuristicLab.Core;
    2724using HeuristicLab.Data;
    2825using HeuristicLab.DataAnalysis;
    29 using HeuristicLab.GP.StructureIdentification;
     26using HeuristicLab.GP.Interfaces;
    3027
    3128namespace HeuristicLab.GP.StructureIdentification.Classification {
     
    4542    private const string VOTES = "Votes";
    4643    private const string ACCURACY = "Accuracy";
     44    private const string TREEEVALUATOR = "TreeEvaluator";
    4745
    4846    private const double EPSILON = 1E-6;
     
    6361      AddVariableInfo(new VariableInfo(SAMPLESEND, "The end of samples in the original dataset", typeof(IntData), VariableKind.In));
    6462      AddVariableInfo(new VariableInfo(BESTMODELLSCOPE, "The variable containing the scope of the model (incl. meta data)", typeof(IScope), VariableKind.In));
    65       AddVariableInfo(new VariableInfo(BESTMODELL, "The variable in the scope of the model that contains the actual model", typeof(BakedFunctionTree), VariableKind.In));
     63      AddVariableInfo(new VariableInfo(BESTMODELL, "The variable in the scope of the model that contains the actual model", typeof(IGeneticProgrammingModel), VariableKind.In));
     64      AddVariableInfo(new VariableInfo(TREEEVALUATOR, "The evaluator to apply to the function tree", typeof(ITreeEvaluator), VariableKind.In));
    6665      AddVariableInfo(new VariableInfo(VOTES, "Array with the votes for each instance", typeof(IntMatrixData), VariableKind.New));
    6766      AddVariableInfo(new VariableInfo(ACCURACY, "Accuracy of the one-vs-one multi-cass classifier", typeof(DoubleData), VariableKind.New));
     
    8281        double classBValue = GetVariableValue<DoubleData>(CLASSBVALUE, childScope, true).Data;
    8382        IScope bestScope = GetVariableValue<IScope>(BESTMODELLSCOPE, childScope, true);
    84         BakedFunctionTree functionTree = GetVariableValue<BakedFunctionTree>(BESTMODELL, bestScope, true);
     83        IGeneticProgrammingModel gpModel = GetVariableValue<IGeneticProgrammingModel>(BESTMODELL, bestScope, true);
    8584
    86         BakedTreeEvaluator evaluator = new BakedTreeEvaluator();
    87         evaluator.PrepareForEvaluation(dataset, targetVariable, trainingSamplesStart, trainingSamplesEnd, 1.0, functionTree);
     85        ITreeEvaluator evaluator = GetVariableValue<ITreeEvaluator>(TREEEVALUATOR, bestScope, true);
     86        evaluator.PrepareForEvaluation(dataset, targetVariable, trainingSamplesStart, trainingSamplesEnd, 1.0, gpModel.FunctionTree);
    8887        for(int i = 0; i < (samplesEnd - samplesStart); i++) {
    8988          double est = evaluator.Evaluate(i + samplesStart);
  • trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/OffspringSelectionGP.cs

    r2161 r2222  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Linq;
    25 using System.Text;
    2622using HeuristicLab.Core;
    27 using System.Xml;
    28 using System.Diagnostics;
    29 using HeuristicLab.DataAnalysis;
    30 using HeuristicLab.Random;
    31 using HeuristicLab.Data;
    3223using HeuristicLab.Modeling;
    3324
  • trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/ROCAnalyzer.cs

    r1529 r2222  
    2020#endregion
    2121
    22 using System;
    2322using System.Collections.Generic;
    2423using System.Linq;
    25 using System.Text;
    2624using HeuristicLab.Core;
    2725using HeuristicLab.Data;
    28 using HeuristicLab.DataAnalysis;
    2926
    3027
     
    8986      foreach (double key in classes.Keys)
    9087        classes[key].Sort();
    91  
     88
    9289      //calculate ROC Curve
    9390      foreach (double key in classes.Keys) {
     
    133130          }
    134131        }
    135           myAucValues.Add(new DoubleData(bestAUC));
    136           myRocValues.Add(Convert(bestROC));
    137        
     132        myAucValues.Add(new DoubleData(bestAUC));
     133        myRocValues.Add(Convert(bestROC));
     134
    138135      } else { //last class
    139136        actNegatives = negatives.Where<double>(value => value > classes[positiveClassKey].Min<double>()).ToList<double>();
     
    158155
    159156      actTP = positives.Count<double>(value => minThreshold <= value && value <= negatives.Max<double>());
    160       actFP = negatives.Count<double>(value => minThreshold <= value );
     157      actFP = negatives.Count<double>(value => minThreshold <= value);
    161158      //add point (1,TPR) for AUC 'correct' calculation
    162159      roc.Add(new KeyValuePair<double, double>(1, actTP / positives.Count));
     
    222219
    223220        //stop calculation if truePositiveRate == 0 => straight line with y=0 & save runtime
    224         if (actTP == 0 || actFP==0)
     221        if (actTP == 0 || actFP == 0)
    225222          break;
    226223      }
  • trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/StandardGP.cs

    r2161 r2222  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Linq;
    25 using System.Text;
    2622using HeuristicLab.Core;
    27 using System.Xml;
    28 using System.Diagnostics;
    29 using HeuristicLab.DataAnalysis;
    30 using HeuristicLab.Random;
    31 using HeuristicLab.Data;
     23using HeuristicLab.Modeling;
    3224using HeuristicLab.Operators;
    33 using HeuristicLab.Modeling;
    3425
    3526namespace HeuristicLab.GP.StructureIdentification.Classification {
Note: See TracChangeset for help on using the changeset viewer.