- Timestamp:
- 09/03/09 15:00:23 (15 years ago)
- 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 23 23 using HeuristicLab.Core; 24 24 using HeuristicLab.Data; 25 using HeuristicLab.Common; 25 26 26 27 namespace HeuristicLab.GP.StructureIdentification.Classification { … … 49 50 // on the lower end and upper end only add linear error if the absolute error is larger than 1 50 51 // 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)) { 53 54 errorsSquaredSum += Math.Abs(error); // only add linear error below the smallest class or above the largest class 54 55 } else { … … 71 72 mse.Data = errorsSquaredSum; 72 73 } 73 74 private bool IsEqual(double x, double y) {75 return Math.Abs(x - y) < EPSILON;76 }77 74 } 78 75 } -
trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/HeuristicLab.GP.StructureIdentification.Classification-3.3.csproj
r2222 r2328 94 94 </ItemGroup> 95 95 <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> 96 100 <ProjectReference Include="..\..\HeuristicLab.Core\3.2\HeuristicLab.Core-3.2.csproj"> 97 101 <Project>{F43B59AB-2B8C-4570-BC1E-15592086517C}</Project> -
trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/HeuristicLabGPClassificationPlugin.cs
r2222 r2328 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.Common-3.2")] 30 31 [Dependency(Dependency = "HeuristicLab.Core-3.2")] 31 32 [Dependency(Dependency = "HeuristicLab.Data-3.2")] -
trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/MulticlassModeller.cs
r2222 r2328 22 22 using System; 23 23 using System.Collections.Generic; 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; 25 26 using HeuristicLab.Data; … … 83 84 double[] row = new double[dataset.Columns]; 84 85 double targetValue = origDataset.GetValue(k, targetVariable); 85 if ( IsEqual(targetValue,classAValue)) {86 if (targetValue.IsAlmost(classAValue)) { 86 87 for (int l = 0; l < row.Length; l++) { 87 88 row[l] = origDataset.GetValue(k, l); … … 89 90 row[targetVariable] = 0; 90 91 rows.Add(row); 91 } else if ( IsEqual(targetValue,classBValue)) {92 } else if (targetValue.IsAlmost(classBValue)) { 92 93 for (int l = 0; l < row.Length; l++) { 93 94 row[l] = origDataset.GetValue(k, l); … … 102 103 double[] row = new double[dataset.Columns]; 103 104 double targetValue = origDataset.GetValue(k, targetVariable); 104 if ( IsEqual(targetValue,classAValue)) {105 if (targetValue.IsAlmost(classAValue)) { 105 106 for (int l = 0; l < row.Length; l++) { 106 107 row[l] = origDataset.GetValue(k, l); … … 108 109 row[targetVariable] = 0; 109 110 rows.Add(row); 110 } else if ( IsEqual(targetValue,classBValue)) {111 } else if (targetValue.IsAlmost(classBValue)) { 111 112 for (int l = 0; l < row.Length; l++) { 112 113 row[l] = origDataset.GetValue(k, l); … … 141 142 return null; 142 143 } 143 144 private bool IsEqual(double x, double y) {145 return Math.Abs(x - y) < EPSILON;146 }147 144 } 148 145 } -
trunk/sources/HeuristicLab.GP.StructureIdentification.Classification/3.3/MulticlassOneVsOneAnalyzer.cs
r2285 r2328 25 25 using HeuristicLab.DataAnalysis; 26 26 using HeuristicLab.GP.Interfaces; 27 using HeuristicLab.Common; 27 28 28 29 namespace HeuristicLab.GP.StructureIdentification.Classification { … … 44 45 private const string TREEEVALUATOR = "TreeEvaluator"; 45 46 46 private const double EPSILON = 1E-6;47 47 public override string Description { 48 48 get { return @"TASK"; } … … 56 56 AddVariableInfo(new VariableInfo(CLASSAVALUE, "The original class value of the class A in the subscope", typeof(DoubleData), VariableKind.In)); 57 57 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));60 58 AddVariableInfo(new VariableInfo(SAMPLESSTART, "The start of samples in the original dataset", typeof(IntData), VariableKind.In)); 61 59 AddVariableInfo(new VariableInfo(SAMPLESEND, "The end of samples in the original dataset", typeof(IntData), VariableKind.In)); … … 84 82 85 83 ITreeEvaluator evaluator = GetVariableValue<ITreeEvaluator>(TREEEVALUATOR, bestScope, true); 86 evaluator.PrepareForEvaluation(dataset, targetVariable, trainingSamplesStart, trainingSamplesEnd,gpModel.FunctionTree);84 evaluator.PrepareForEvaluation(dataset, gpModel.FunctionTree); 87 85 for(int i = 0; i < (samplesEnd - samplesStart); i++) { 88 86 double est = evaluator.Evaluate(i + samplesStart); … … 110 108 } 111 109 } 112 if( IsEqual(originalClassValue,estimatedClassValue) && sameVotes == 0) correctlyClassified++;110 if(originalClassValue.IsAlmost(estimatedClassValue) && sameVotes == 0) correctlyClassified++; 113 111 } 114 112 … … 122 120 private void CastVote(int[,] votes, int sample, double votedClass, ItemList<DoubleData> classValues) { 123 121 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]++; 125 123 } 126 }127 128 private bool IsEqual(double x, double y) {129 return Math.Abs(x - y) < EPSILON;130 124 } 131 125 }
Note: See TracChangeset
for help on using the changeset viewer.