Changeset 2216 for branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.Classification
- Timestamp:
- 07/30/09 19:41:58 (15 years ago)
- Location:
- branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/AccuracyEvaluator.cs
r1891 r2216 21 21 22 22 using System; 23 using System.Collections.Generic;24 using System.Linq;25 using System.Text;26 23 using HeuristicLab.Core; 27 24 using HeuristicLab.Data; 28 using HeuristicLab.GP.StructureIdentification;29 25 using HeuristicLab.DataAnalysis; 30 26 -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/ClassificationMeanSquaredErrorEvaluator.cs
r1891 r2216 21 21 22 22 using System; 23 using System.Collections.Generic;24 using System.Linq;25 using System.Text;26 23 using HeuristicLab.Core; 27 24 using HeuristicLab.Data; 28 using HeuristicLab.GP.StructureIdentification;29 25 30 26 namespace HeuristicLab.GP.StructureIdentification.Classification { -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/ConfusionMatrixEvaluator.cs
r1891 r2216 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Linq;25 using System.Text;26 22 using HeuristicLab.Core; 27 23 using HeuristicLab.Data; 28 using HeuristicLab.GP.StructureIdentification;29 24 30 25 namespace HeuristicLab.GP.StructureIdentification.Classification { -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/CrossValidation.cs
r1529 r2216 21 21 22 22 using System; 23 using System.Collections.Generic;24 using System.Text;25 using System.Xml;26 23 using HeuristicLab.Core; 27 24 using HeuristicLab.Data; 28 25 using HeuristicLab.DataAnalysis; 29 26 30 namespace HeuristicLab.GP.StructureIdentification.Classification 31 { 32 public class CrossValidation : OperatorBase 33 { 27 namespace HeuristicLab.GP.StructureIdentification.Classification { 28 public class CrossValidation : OperatorBase { 34 29 35 36 37 38 39 40 41 42 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"; 43 38 44 public override string Description 45 { 46 get { return @"TASK"; } 47 } 39 public override string Description { 40 get { return @"TASK"; } 41 } 48 42 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 } 61 54 62 55 public override IOperation Apply(IScope scope) { 63 56 Dataset origDataset = GetVariableValue<Dataset>(DATASET, scope, true); 64 57 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"); 66 59 int origTrainingSamplesStart = GetVariableValue<IntData>(TRAININGSAMPLESSTART, scope, true).Data; 67 60 int origTrainingSamplesEnd = GetVariableValue<IntData>(TRAININGSAMPLESEND, scope, true).Data; 68 61 int origValidationSamplesStart = GetVariableValue<IntData>(VALIDATIONSAMPLESSTART, scope, true).Data; 69 62 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); 73 66 74 67 double percentTrainingSamples = origTrainingSamples / (double)(origValidationSamples + origTrainingSamples); … … 82 75 int newTestSamplesEnd = n; 83 76 84 for (int i = 0; i < nFolds; i++) {77 for (int i = 0; i < nFolds; i++) { 85 78 Scope childScope = new Scope(i.ToString()); 86 79 Dataset rotatedSet = new Dataset(); … … 106 99 } 107 100 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); 114 105 } 106 } 115 107 } -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/GPClassificationEvaluatorBase.cs
r1891 r2216 21 21 22 22 using System; 23 using System.Collections.Generic;24 using System.Linq;25 using System.Text;26 23 using HeuristicLab.Core; 27 24 using HeuristicLab.Data; 28 using HeuristicLab.GP.StructureIdentification;29 25 using HeuristicLab.DataAnalysis; 30 26 -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/HeuristicLabGPClassificationPlugin.cs
r2210 r2216 28 28 [ClassInfo(Name = "HeuristicLab.GP.StructureIdentification.Classification-3.3")] 29 29 [PluginFile(Filename = "HeuristicLab.GP.StructureIdentification.Classification-3.3.dll", Filetype = PluginFileType.Assembly)] 30 [Dependency(Dependency = "HeuristicLab.Constraints-3.2")]31 30 [Dependency(Dependency = "HeuristicLab.Core-3.2")] 32 31 [Dependency(Dependency = "HeuristicLab.Data-3.2")] -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/MulticlassModeller.cs
r1529 r2216 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Text;25 using System.Xml;26 24 using HeuristicLab.Core; 27 25 using HeuristicLab.Data; -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/MulticlassOneVsOneAnalyzer.cs
r2211 r2216 21 21 22 22 using System; 23 using System.Collections.Generic;24 using System.Text;25 using System.Xml;26 23 using HeuristicLab.Core; 27 24 using HeuristicLab.Data; 28 25 using HeuristicLab.DataAnalysis; 29 using HeuristicLab.GP.StructureIdentification;30 26 using HeuristicLab.GP.Interfaces; 31 27 -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/OffspringSelectionGP.cs
r2161 r2216 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Linq;25 using System.Text;26 22 using HeuristicLab.Core; 27 using System.Xml;28 using System.Diagnostics;29 using HeuristicLab.DataAnalysis;30 using HeuristicLab.Random;31 using HeuristicLab.Data;32 23 using HeuristicLab.Modeling; 33 24 -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/ROCAnalyzer.cs
r1529 r2216 20 20 #endregion 21 21 22 using System;23 22 using System.Collections.Generic; 24 23 using System.Linq; 25 using System.Text;26 24 using HeuristicLab.Core; 27 25 using HeuristicLab.Data; 28 using HeuristicLab.DataAnalysis;29 26 30 27 … … 89 86 foreach (double key in classes.Keys) 90 87 classes[key].Sort(); 91 88 92 89 //calculate ROC Curve 93 90 foreach (double key in classes.Keys) { … … 133 130 } 134 131 } 135 136 137 132 myAucValues.Add(new DoubleData(bestAUC)); 133 myRocValues.Add(Convert(bestROC)); 134 138 135 } else { //last class 139 136 actNegatives = negatives.Where<double>(value => value > classes[positiveClassKey].Min<double>()).ToList<double>(); … … 158 155 159 156 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); 161 158 //add point (1,TPR) for AUC 'correct' calculation 162 159 roc.Add(new KeyValuePair<double, double>(1, actTP / positives.Count)); … … 222 219 223 220 //stop calculation if truePositiveRate == 0 => straight line with y=0 & save runtime 224 if (actTP == 0 || actFP ==0)221 if (actTP == 0 || actFP == 0) 225 222 break; 226 223 } -
branches/GP-Refactoring-713/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/StandardGP.cs
r2161 r2216 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Linq;25 using System.Text;26 22 using HeuristicLab.Core; 27 using System.Xml; 28 using System.Diagnostics; 29 using HeuristicLab.DataAnalysis; 30 using HeuristicLab.Random; 31 using HeuristicLab.Data; 23 using HeuristicLab.Modeling; 32 24 using HeuristicLab.Operators; 33 using HeuristicLab.Modeling;34 25 35 26 namespace HeuristicLab.GP.StructureIdentification.Classification {
Note: See TracChangeset
for help on using the changeset viewer.