- Timestamp:
- 09/16/10 17:17:51 (14 years ago)
- Location:
- branches/HeuristicLab.Classification
- Files:
-
- 15 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Classification/HeuristicLab.Classification.sln
r4391 r4417 4 4 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Classification", "HeuristicLab.Classification\HeuristicLab.Classification.csproj", "{3AB5A7E5-9F0C-4920-B18D-E06B9577618C}" 5 5 ProjectSection(ProjectDependencies) = postProject 6 {7F038E9A-B91E-4F49-8C27-D47BC86F1220} = {7F038E9A-B91E-4F49-8C27-D47BC86F1220} 6 7 {D35FD6DB-D704-4BEA-BDAE-C40ABFB5B13E} = {D35FD6DB-D704-4BEA-BDAE-C40ABFB5B13E} 7 8 EndProjectSection … … 35 36 {3AB5A7E5-9F0C-4920-B18D-E06B9577618C}.Release|Any CPU.ActiveCfg = Release|Any CPU 36 37 {3AB5A7E5-9F0C-4920-B18D-E06B9577618C}.Release|Any CPU.Build.0 = Release|Any CPU 37 {3AB5A7E5-9F0C-4920-B18D-E06B9577618C}.Release|x64.ActiveCfg = Release|Any CPU 38 {3AB5A7E5-9F0C-4920-B18D-E06B9577618C}.Release|x64.ActiveCfg = Release|x64 39 {3AB5A7E5-9F0C-4920-B18D-E06B9577618C}.Release|x64.Build.0 = Release|x64 38 40 {3AB5A7E5-9F0C-4920-B18D-E06B9577618C}.Release|x86.ActiveCfg = Release|x86 39 41 {3AB5A7E5-9F0C-4920-B18D-E06B9577618C}.Release|x86.Build.0 = Release|x86 … … 46 48 {D35FD6DB-D704-4BEA-BDAE-C40ABFB5B13E}.Release|Any CPU.ActiveCfg = Release|Any CPU 47 49 {D35FD6DB-D704-4BEA-BDAE-C40ABFB5B13E}.Release|Any CPU.Build.0 = Release|Any CPU 48 {D35FD6DB-D704-4BEA-BDAE-C40ABFB5B13E}.Release|x64.ActiveCfg = Release|Any CPU 50 {D35FD6DB-D704-4BEA-BDAE-C40ABFB5B13E}.Release|x64.ActiveCfg = Release|x64 51 {D35FD6DB-D704-4BEA-BDAE-C40ABFB5B13E}.Release|x64.Build.0 = Release|x64 49 52 {D35FD6DB-D704-4BEA-BDAE-C40ABFB5B13E}.Release|x86.ActiveCfg = Release|x86 50 53 {D35FD6DB-D704-4BEA-BDAE-C40ABFB5B13E}.Release|x86.Build.0 = Release|x86 … … 57 60 {7F038E9A-B91E-4F49-8C27-D47BC86F1220}.Release|Any CPU.ActiveCfg = Release|Any CPU 58 61 {7F038E9A-B91E-4F49-8C27-D47BC86F1220}.Release|Any CPU.Build.0 = Release|Any CPU 59 {7F038E9A-B91E-4F49-8C27-D47BC86F1220}.Release|x64.ActiveCfg = Release|Any CPU 62 {7F038E9A-B91E-4F49-8C27-D47BC86F1220}.Release|x64.ActiveCfg = Release|x64 63 {7F038E9A-B91E-4F49-8C27-D47BC86F1220}.Release|x64.Build.0 = Release|x64 60 64 {7F038E9A-B91E-4F49-8C27-D47BC86F1220}.Release|x86.ActiveCfg = Release|x86 61 65 {7F038E9A-B91E-4F49-8C27-D47BC86F1220}.Release|x86.Build.0 = Release|x86 -
branches/HeuristicLab.Classification/HeuristicLab.Problems.DataAnalysis.Classification/3.3/HeuristicLab.Problems.DataAnalysis.Classification-3.3.csproj
r4391 r4417 140 140 <Reference Include="System.Core" /> 141 141 <Reference Include="System.Drawing" /> 142 <Reference Include="System.Xml.Linq" />143 <Reference Include="System.Data.DataSetExtensions" />144 142 <Reference Include="System.Data" /> 145 <Reference Include="System.Xml" />146 143 </ItemGroup> 147 144 <ItemGroup> … … 156 153 <Compile Include="Interfaces\ISymbolicClassificationAnalyzer.cs" /> 157 154 <Compile Include="Symbolic\Analyzer\ValidationBestSymbolicClassificationSolutionAnalyzer.cs" /> 155 <Compile Include="Symbolic\Evaluators\OnlineAccuracyEvaluator.cs" /> 158 156 <Compile Include="Symbolic\Evaluators\SymbolicClassificationPearsonRSquaredEvaluator.cs" /> 159 157 <Compile Include="Symbolic\SymbolicClassificationSolution.cs" /> -
branches/HeuristicLab.Classification/HeuristicLab.Problems.DataAnalysis.Classification/3.3/Symbolic/Analyzer/ValidationBestSymbolicClassificationSolutionAnalyzer.cs
r4391 r4417 55 55 private const string BestValidationQualityParameterName = "Best validation quality"; 56 56 private const string BestValidationSolutionParameterName = "Best validation solution"; 57 private const string BestSolution GenerationParameterName = "Best solution generation";58 private const string BestSolution InputvariableCountParameterName = "Variables used by best solution";57 private const string BestSolutionAccuracyTrainingParameterName = "Best solution accuracy (training)"; 58 private const string BestSolutionAccuracyTestParameterName = "Best solution accuracy (test)"; 59 59 private const string VariableFrequenciesParameterName = "VariableFrequencies"; 60 private const string VariableImpactsParameterName = "Variable Impacts";61 60 62 61 #region parameter properties … … 111 110 get { return (ILookupParameter<SymbolicClassificationSolution>)Parameters[BestValidationSolutionParameterName]; } 112 111 } 113 public ILookupParameter<IntValue> BestSolutionGenerationParameter { 114 get { return (ILookupParameter<IntValue>)Parameters[BestSolutionGenerationParameterName]; } 115 } 116 public ILookupParameter<DoubleMatrix> VariableImpactsParameter { 117 get { return (ILookupParameter<DoubleMatrix>)Parameters[VariableImpactsParameterName]; } 118 } 119 public ILookupParameter<IntValue> BestSolutionInputvariableCountParameter { 120 get { return (ILookupParameter<IntValue>)Parameters[BestSolutionInputvariableCountParameterName]; } 112 public ILookupParameter<DoubleValue> BestSolutionAccuracyTrainingParameter { 113 get { return (ILookupParameter<DoubleValue>)Parameters[BestSolutionAccuracyTrainingParameterName]; } 114 } 115 public ILookupParameter<DoubleValue> BestSolutionAccuracyTestParameter { 116 get { return (ILookupParameter<DoubleValue>)Parameters[BestSolutionAccuracyTestParameterName]; } 121 117 } 122 118 #endregion … … 174 170 protected set { BestValidationSolutionParameter.ActualValue = value; } 175 171 } 176 public IntValue BestSolutionGeneration { 177 get { return BestSolutionGenerationParameter.ActualValue; } 178 protected set { BestSolutionGenerationParameter.ActualValue = value; } 179 } 180 public IntValue BestSolutionInputvariableCount { 181 get { return BestSolutionInputvariableCountParameter.ActualValue; } 182 protected set { BestSolutionInputvariableCountParameter.ActualValue = value; } 183 } 184 public DoubleMatrix VariableImpacts { 185 get { return VariableImpactsParameter.ActualValue; } 186 protected set { VariableImpactsParameter.ActualValue = value; } 172 public DoubleValue BestSolutionAccuracyTraining { 173 get { return BestSolutionAccuracyTrainingParameter.ActualValue; } 174 protected set { BestSolutionAccuracyTrainingParameter.ActualValue = value; } 175 } 176 public DoubleValue BestSolutionAccuracyTest { 177 get { return BestSolutionAccuracyTestParameter.ActualValue; } 178 protected set { BestSolutionAccuracyTestParameter.ActualValue = value; } 187 179 } 188 180 #endregion … … 208 200 Parameters.Add(new LookupParameter<DoubleValue>(BestValidationQualityParameterName, "The validation quality of the best solution in the current run.")); 209 201 Parameters.Add(new LookupParameter<SymbolicClassificationSolution>(BestValidationSolutionParameterName, "The best solution on the validation data found in the current run.")); 210 Parameters.Add(new LookupParameter<IntValue>(BestSolutionGenerationParameterName, "The generation in which the best solution was found.")); 211 Parameters.Add(new LookupParameter<DoubleMatrix>(VariableImpactsParameterName, "The impacts of the input variables calculated during the run.")); 212 Parameters.Add(new LookupParameter<IntValue>(BestSolutionInputvariableCountParameterName, "The number of input variables used by the best solution.")); 213 202 Parameters.Add(new LookupParameter<DoubleValue>(BestSolutionAccuracyTrainingParameterName, "The training accuracy of the best solution.")); 203 Parameters.Add(new LookupParameter<DoubleValue>(BestSolutionAccuracyTestParameterName, "The test accuracy of the best solution.")); 214 204 } 215 205 … … 272 262 BestValidationSolution.Description = "Best solution on validation partition found over the whole run."; 273 263 BestValidationQuality = new DoubleValue(bestQuality); 274 BestSolutionGeneration = (IntValue)Generations.Clone();275 BestSolutionInputvariableCount = new IntValue(BestValidationSolution.Model.InputVariables.Count());276 277 Results.Add(new Result(BestValidationSolutionParameterName, BestValidationSolution));278 Results.Add(new Result(BestValidationQualityParameterName, BestValidationQuality));279 Results.Add(new Result(BestSolutionGenerationParameterName, BestSolutionGeneration));280 281 Results.Add(new Result(BestSolutionInputvariableCountParameterName, BestSolutionInputvariableCount));282 283 if (VariableFrequencies != null) {284 VariableImpacts = CalculateVariableImpacts(VariableFrequencies);285 Results.Add(new Result(VariableImpactsParameterName, VariableImpacts));286 }287 288 264 } else { 289 265 BestValidationSolution.Model = model; 290 BestValidationQuality.Value = bestQuality;291 BestSolutionGeneration.Value = Generations.Value;292 BestSolutionInputvariableCount.Value = BestValidationSolution.Model.InputVariables.Count();293 294 if (VariableFrequencies != null) {295 VariableImpacts = CalculateVariableImpacts(VariableFrequencies);296 Results[VariableImpactsParameterName].Value = VariableImpacts;297 }298 266 } 267 268 UpdateBestSolutionResults(); 299 269 } 300 270 return base.Apply(); 301 271 } 302 272 303 private static DoubleMatrix CalculateVariableImpacts(DataTable variableFrequencies) { 304 if (variableFrequencies != null) { 305 var impacts = new DoubleMatrix(variableFrequencies.Rows.Count, 1, new string[] { "Impact" }, variableFrequencies.Rows.Select(x => x.Name)); 306 impacts.SortableView = true; 307 int rowIndex = 0; 308 foreach (var dataRow in variableFrequencies.Rows) { 309 string variableName = dataRow.Name; 310 impacts[rowIndex++, 0] = dataRow.Values.Average(); 311 } 312 return impacts; 313 } else return new DoubleMatrix(1, 1); 314 } 273 private void UpdateBestSolutionResults() { 274 BestSymbolicRegressionSolutionAnalyzer.UpdateBestSolutionResults(BestValidationSolution, ClassificationProblemData, Results, Generations, VariableFrequencies); 275 276 IEnumerable<double> trainingValues = ClassificationProblemData.Dataset.GetEnumeratedVariableValues( 277 ClassificationProblemData.TargetVariable.Value, 278 ClassificationProblemData.TrainingSamplesStart.Value, 279 ClassificationProblemData.TrainingSamplesEnd.Value); 280 IEnumerable<double> testValues = ClassificationProblemData.Dataset.GetEnumeratedVariableValues( 281 ClassificationProblemData.TargetVariable.Value, 282 ClassificationProblemData.TestSamplesStart.Value, 283 ClassificationProblemData.TestSamplesEnd.Value); 284 285 OnlineAccuracyEvaluator accuracyEvaluator = new OnlineAccuracyEvaluator(); 286 var originalEnumerator = trainingValues.GetEnumerator(); 287 var estimatedEnumerator = BestValidationSolution.EstimatedTrainingClassValues.GetEnumerator(); 288 while (originalEnumerator.MoveNext() & estimatedEnumerator.MoveNext()) { 289 accuracyEvaluator.Add(originalEnumerator.Current, estimatedEnumerator.Current); 290 } 291 double trainingAccuracy = accuracyEvaluator.Accuracy; 292 293 accuracyEvaluator.Reset(); 294 originalEnumerator = testValues.GetEnumerator(); 295 estimatedEnumerator = BestValidationSolution.EstimatedTestClassValues.GetEnumerator(); 296 while (originalEnumerator.MoveNext() & estimatedEnumerator.MoveNext()) { 297 accuracyEvaluator.Add(originalEnumerator.Current, estimatedEnumerator.Current); 298 } 299 double testAccuracy = accuracyEvaluator.Accuracy; 300 301 if (!Results.ContainsKey(BestSolutionAccuracyTrainingParameterName)) { 302 BestSolutionAccuracyTraining = new DoubleValue(trainingAccuracy); 303 BestSolutionAccuracyTest = new DoubleValue(testAccuracy); 304 305 Results.Add(new Result(BestSolutionAccuracyTrainingParameterName, BestSolutionAccuracyTraining)); 306 Results.Add(new Result(BestSolutionAccuracyTestParameterName, BestSolutionAccuracyTest)); 307 } else { 308 BestSolutionAccuracyTraining.Value = trainingAccuracy; 309 BestSolutionAccuracyTest.Value = testAccuracy; 310 } 311 } 312 315 313 } 316 314 } -
branches/HeuristicLab.Classification/HeuristicLab.Problems.DataAnalysis.Classification/3.3/Symbolic/SymbolicClassificationSolution.cs
r4391 r4417 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Drawing;25 24 using System.Linq; 26 25 using HeuristicLab.Common; … … 35 34 [Item("SymbolicClassificationSolution", "Represents a solution for a symbolic classification problem which can be visualized in the GUI.")] 36 35 [StorableClass] 37 public class SymbolicClassificationSolution : DataAnalysisSolution, IClassificationSolution {36 public class SymbolicClassificationSolution : SymbolicRegressionSolution, IClassificationSolution { 38 37 private SymbolicClassificationSolution() : base() { } 39 38 public SymbolicClassificationSolution(ClassificationProblemData problemData, SymbolicRegressionModel model, double lowerEstimationLimit, double upperEstimationLimit) 40 : base(problemData, lowerEstimationLimit, upperEstimationLimit) { 41 this.Model = model; 42 } 43 44 public override Image ItemImage { 45 get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Function; } 46 } 47 48 public new SymbolicRegressionModel Model { 49 get { return (SymbolicRegressionModel)base.Model; } 50 set { base.Model = value; } 39 : base(problemData, model, lowerEstimationLimit, upperEstimationLimit) { 51 40 } 52 41 … … 63 52 RecalculateClassIntermediates(); 64 53 OnEstimatedValuesChanged(); 65 }66 67 protected List<double> estimatedValues;68 public override IEnumerable<double> EstimatedValues {69 get {70 if (estimatedValues == null) RecalculateEstimatedValues();71 return estimatedValues.AsEnumerable();72 }73 }74 75 public override IEnumerable<double> EstimatedTrainingValues {76 get {77 if (estimatedValues == null) RecalculateEstimatedValues();78 int start = ProblemData.TrainingSamplesStart.Value;79 int n = ProblemData.TrainingSamplesEnd.Value - start;80 return estimatedValues.Skip(start).Take(n).ToList();81 }82 }83 84 public override IEnumerable<double> EstimatedTestValues {85 get {86 if (estimatedValues == null) RecalculateEstimatedValues();87 int start = ProblemData.TestSamplesStart.Value;88 int n = ProblemData.TestSamplesEnd.Value - start;89 return estimatedValues.Skip(start).Take(n).ToList();90 }91 54 } 92 55
Note: See TracChangeset
for help on using the changeset viewer.