- Timestamp:
- 07/17/11 22:51:11 (13 years ago)
- Location:
- branches/QAPAlgorithms
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/QAPAlgorithms
- Property svn:ignore
-
old new 12 12 *.psess 13 13 *.vsp 14 *.docstates
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/QAPAlgorithms/HeuristicLab.Problems.DataAnalysis
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Problems.DataAnalysis merged: 6411,6439-6440,6520,6548
- Property svn:mergeinfo changed
-
branches/QAPAlgorithms/HeuristicLab.Problems.DataAnalysis/3.3/HeuristicLabProblemsDataAnalysisPlugin.cs.frame
r6099 r6569 26 26 27 27 namespace HeuristicLab.Problems.DataAnalysis { 28 [Plugin("HeuristicLab.Problems.DataAnalysis", "3.3. 4.$WCREV$")]28 [Plugin("HeuristicLab.Problems.DataAnalysis", "3.3.5.$WCREV$")] 29 29 [PluginFile("HeuristicLab.Problems.DataAnalysis-3.3.dll", PluginFileType.Assembly)] 30 30 [PluginDependency("HeuristicLab.ALGLIB", "3.1")] -
branches/QAPAlgorithms/HeuristicLab.Problems.DataAnalysis/3.3/Properties/AssemblyInfo.frame
r6099 r6569 53 53 // by using the '*' as shown below: 54 54 [assembly: AssemblyVersion("3.3.0.0")] 55 [assembly: AssemblyFileVersion("3.3. 4.$WCREV$")]55 [assembly: AssemblyFileVersion("3.3.5.$WCREV$")] -
branches/QAPAlgorithms/HeuristicLab.Problems.DataAnalysis/3.3/Tests/Properties/AssemblyInfo.cs
r5446 r6569 52 52 // by using the '*' as shown below: 53 53 [assembly: AssemblyVersion("3.3.0.0")] 54 [assembly: AssemblyFileVersion("3.3. 3.0")]54 [assembly: AssemblyFileVersion("3.3.5.0")] -
branches/QAPAlgorithms/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLabProblemsDataAnalysisPlugin.cs.frame
r5860 r6569 26 26 27 27 namespace HeuristicLab.Problems.DataAnalysis { 28 [Plugin("HeuristicLab.Problems.DataAnalysis","Provides base classes for data analysis tasks.", "3.4. 0.$WCREV$")]28 [Plugin("HeuristicLab.Problems.DataAnalysis","Provides base classes for data analysis tasks.", "3.4.1.$WCREV$")] 29 29 [PluginFile("HeuristicLab.Problems.DataAnalysis-3.4.dll", PluginFileType.Assembly)] 30 30 [PluginDependency("HeuristicLab.Collections", "3.3")] -
branches/QAPAlgorithms/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationEnsembleModel.cs
r6239 r6569 58 58 59 59 #region IClassificationEnsembleModel Members 60 public void Add(IClassificationModel model) { 61 models.Add(model); 62 } 60 63 61 64 public IEnumerable<IEnumerable<double>> GetEstimatedClassValueVectors(Dataset dataset, IEnumerable<int> rows) { -
branches/QAPAlgorithms/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationEnsembleProblemData.cs
r6239 r6569 37 37 public override IEnumerable<int> TrainingIndizes { 38 38 get { 39 return Enumerable.Range(TrainingPartition.Start, T estPartition.End - TestPartition.Start);39 return Enumerable.Range(TrainingPartition.Start, TrainingPartition.End - TrainingPartition.Start); 40 40 } 41 41 } -
branches/QAPAlgorithms/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationEnsembleSolution.cs
r6302 r6569 79 79 this.trainingPartitions = new Dictionary<IClassificationModel, IntRange>(); 80 80 this.testPartitions = new Dictionary<IClassificationModel, IntRange>(); 81 var modelEnumerator = models.GetEnumerator(); 82 var trainingPartitionEnumerator = trainingPartitions.GetEnumerator(); 83 var testPartitionEnumerator = testPartitions.GetEnumerator(); 84 while (modelEnumerator.MoveNext() & trainingPartitionEnumerator.MoveNext() & testPartitionEnumerator.MoveNext()) { 85 this.trainingPartitions[modelEnumerator.Current] = (IntRange)trainingPartitionEnumerator.Current.Clone(); 86 this.testPartitions[modelEnumerator.Current] = (IntRange)testPartitionEnumerator.Current.Clone(); 87 } 88 if (modelEnumerator.MoveNext() | trainingPartitionEnumerator.MoveNext() | testPartitionEnumerator.MoveNext()) { 89 throw new ArgumentException(); 90 } 81 AddModelsAndParitions(models, 82 trainingPartitions, 83 testPartitions); 91 84 RecalculateResults(); 92 85 } … … 169 162 .First(); 170 163 } 164 165 public void AddModelsAndParitions(IEnumerable<IClassificationSolution> solutions) { 166 foreach (var solution in solutions) { 167 var ensembleSolution = solution as ClassificationEnsembleSolution; 168 if (ensembleSolution != null) { 169 var data = from m in ensembleSolution.Model.Models 170 let train = ensembleSolution.trainingPartitions[m] 171 let test = ensembleSolution.testPartitions[m] 172 select new { m, train, test }; 173 174 foreach (var d in data) { 175 Model.Add(d.m); 176 trainingPartitions[d.m] = (IntRange)d.train.Clone(); 177 testPartitions[d.m] = (IntRange)d.test.Clone(); 178 } 179 } else { 180 Model.Add(solution.Model); 181 trainingPartitions[solution.Model] = (IntRange)solution.ProblemData.TrainingPartition.Clone(); 182 testPartitions[solution.Model] = (IntRange)solution.ProblemData.TestPartition.Clone(); 183 } 184 } 185 186 RecalculateResults(); 187 } 188 189 private void AddModelsAndParitions(IEnumerable<IClassificationModel> models, IEnumerable<IntRange> trainingPartitions, IEnumerable<IntRange> testPartitions) { 190 var modelEnumerator = models.GetEnumerator(); 191 var trainingPartitionEnumerator = trainingPartitions.GetEnumerator(); 192 var testPartitionEnumerator = testPartitions.GetEnumerator(); 193 194 while (modelEnumerator.MoveNext() & trainingPartitionEnumerator.MoveNext() & testPartitionEnumerator.MoveNext()) { 195 this.trainingPartitions[modelEnumerator.Current] = (IntRange)trainingPartitionEnumerator.Current.Clone(); 196 this.testPartitions[modelEnumerator.Current] = (IntRange)testPartitionEnumerator.Current.Clone(); 197 } 198 if (modelEnumerator.MoveNext() | trainingPartitionEnumerator.MoveNext() | testPartitionEnumerator.MoveNext()) { 199 throw new ArgumentException(); 200 } 201 } 171 202 } 172 203 } -
branches/QAPAlgorithms/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationProblemData.cs
r6223 r6569 185 185 186 186 #region parameter properties 187 public IValueParameter<StringValue> TargetVariableParameter {188 get { return ( IValueParameter<StringValue>)Parameters[TargetVariableParameterName]; }187 public ConstrainedValueParameter<StringValue> TargetVariableParameter { 188 get { return (ConstrainedValueParameter<StringValue>)Parameters[TargetVariableParameterName]; } 189 189 } 190 190 public IFixedValueParameter<StringMatrix> ClassNamesParameter { -
branches/QAPAlgorithms/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationSolution.cs
r6184 r6569 20 20 #endregion 21 21 22 using System;23 22 using System.Collections.Generic; 24 23 using System.Linq; … … 66 65 Add(new Result(TrainingAccuracyResultName, "Accuracy of the model on the training partition (percentage of correctly classified instances).", new PercentValue())); 67 66 Add(new Result(TestAccuracyResultName, "Accuracy of the model on the test partition (percentage of correctly classified instances).", new PercentValue())); 68 RecalculateResults();67 CalculateResults(); 69 68 } 70 69 … … 73 72 } 74 73 75 protected override void OnProblemDataChanged(EventArgs e) { 76 base.OnProblemDataChanged(e); 77 RecalculateResults(); 74 protected override void RecalculateResults() { 75 CalculateResults(); 78 76 } 79 77 80 protected override void OnModelChanged(EventArgs e) { 81 base.OnModelChanged(e); 82 RecalculateResults(); 83 } 84 85 protected void RecalculateResults() { 78 private void CalculateResults() { 86 79 double[] estimatedTrainingClassValues = EstimatedTrainingClassValues.ToArray(); // cache values 87 80 IEnumerable<double> originalTrainingClassValues = ProblemData.Dataset.GetEnumeratedVariableValues(ProblemData.TargetVariable, ProblemData.TrainingIndizes); -
branches/QAPAlgorithms/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/DiscriminantFunctionClassificationSolution.cs
r5942 r6569 25 25 using HeuristicLab.Common; 26 26 using HeuristicLab.Core; 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;28 27 using HeuristicLab.Data; 29 28 using HeuristicLab.Optimization; 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 30 31 31 namespace HeuristicLab.Problems.DataAnalysis { … … 89 89 Add(new Result(TrainingRSquaredResultName, "Squared Pearson's correlation coefficient of the model output and the actual values on the training partition", new DoubleValue())); 90 90 Add(new Result(TestRSquaredResultName, "Squared Pearson's correlation coefficient of the model output and the actual values on the test partition", new DoubleValue())); 91 SetAccuracyMaximizingThresholds(); 92 93 //mkommend: important to recalculate accuracy because during the calculation before no thresholds were present 94 base.RecalculateResults(); 95 CalculateResults(); 91 96 RegisterEventHandler(); 92 SetAccuracyMaximizingThresholds();93 RecalculateResults();94 97 } 95 98 … … 99 102 } 100 103 101 protected new void RecalculateResults() { 104 protected override void OnModelChanged(EventArgs e) { 105 DeregisterEventHandler(); 106 SetAccuracyMaximizingThresholds(); 107 RegisterEventHandler(); 108 base.OnModelChanged(e); 109 } 110 111 protected override void RecalculateResults() { 112 base.RecalculateResults(); 113 CalculateResults(); 114 } 115 116 private void CalculateResults() { 102 117 double[] estimatedTrainingValues = EstimatedTrainingValues.ToArray(); // cache values 103 118 IEnumerable<double> originalTrainingValues = ProblemData.Dataset.GetEnumeratedVariableValues(ProblemData.TargetVariable, ProblemData.TrainingIndizes); … … 119 134 private void RegisterEventHandler() { 120 135 Model.ThresholdsChanged += new EventHandler(Model_ThresholdsChanged); 136 } 137 private void DeregisterEventHandler() { 138 Model.ThresholdsChanged -= new EventHandler(Model_ThresholdsChanged); 121 139 } 122 140 private void Model_ThresholdsChanged(object sender, EventArgs e) { … … 142 160 } 143 161 144 protected override void OnModelChanged(EventArgs e) {145 base.OnModelChanged(e);146 SetAccuracyMaximizingThresholds();147 RecalculateResults();148 }149 150 protected override void OnProblemDataChanged(EventArgs e) {151 base.OnProblemDataChanged(e);152 SetAccuracyMaximizingThresholds();153 RecalculateResults();154 }155 162 protected virtual void OnModelThresholdsChanged(EventArgs e) { 156 base.OnModelChanged(e);157 163 RecalculateResults(); 158 164 } -
branches/QAPAlgorithms/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Clustering/ClusteringSolution.cs
r6184 r6569 45 45 } 46 46 47 protected override void RecalculateResults() { 48 } 49 47 50 #region IClusteringSolution Members 48 51 -
branches/QAPAlgorithms/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisSolution.cs
r5914 r6569 86 86 } 87 87 88 protected abstract void RecalculateResults(); 89 88 90 private void ProblemData_Changed(object sender, EventArgs e) { 89 91 OnProblemDataChanged(e); … … 92 94 public event EventHandler ModelChanged; 93 95 protected virtual void OnModelChanged(EventArgs e) { 96 RecalculateResults(); 94 97 var listeners = ModelChanged; 95 98 if (listeners != null) listeners(this, e); … … 98 101 public event EventHandler ProblemDataChanged; 99 102 protected virtual void OnProblemDataChanged(EventArgs e) { 103 RecalculateResults(); 100 104 var listeners = ProblemDataChanged; 101 105 if (listeners != null) listeners(this, e); -
branches/QAPAlgorithms/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionEnsembleModel.cs
r5809 r6569 58 58 #region IRegressionEnsembleModel Members 59 59 60 public void Add(IRegressionModel model) { 61 models.Add(model); 62 } 63 60 64 public IEnumerable<IEnumerable<double>> GetEstimatedValueVectors(Dataset dataset, IEnumerable<int> rows) { 61 65 var estimatedValuesEnumerators = (from model in models -
branches/QAPAlgorithms/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionEnsembleSolution.cs
r6302 r6569 64 64 trainingPartitions = new Dictionary<IRegressionModel, IntRange>(); 65 65 testPartitions = new Dictionary<IRegressionModel, IntRange>(); 66 foreach (var model in models) { 67 trainingPartitions[model] = (IntRange)problemData.TrainingPartition.Clone(); 68 testPartitions[model] = (IntRange)problemData.TestPartition.Clone(); 69 } 66 AddModelsAndParitions(models, 67 from m in models select (IntRange)problemData.TrainingPartition.Clone(), 68 from m in models select (IntRange)problemData.TestPartition.Clone()); 70 69 RecalculateResults(); 71 70 } … … 75 74 this.trainingPartitions = new Dictionary<IRegressionModel, IntRange>(); 76 75 this.testPartitions = new Dictionary<IRegressionModel, IntRange>(); 77 var modelEnumerator = models.GetEnumerator(); 78 var trainingPartitionEnumerator = trainingPartitions.GetEnumerator(); 79 var testPartitionEnumerator = testPartitions.GetEnumerator(); 80 while (modelEnumerator.MoveNext() & trainingPartitionEnumerator.MoveNext() & testPartitionEnumerator.MoveNext()) { 81 this.trainingPartitions[modelEnumerator.Current] = (IntRange)trainingPartitionEnumerator.Current.Clone(); 82 this.testPartitions[modelEnumerator.Current] = (IntRange)testPartitionEnumerator.Current.Clone(); 83 } 84 if (modelEnumerator.MoveNext() | trainingPartitionEnumerator.MoveNext() | testPartitionEnumerator.MoveNext()) { 85 throw new ArgumentException(); 86 } 76 AddModelsAndParitions(models, trainingPartitions, testPartitions); 87 77 RecalculateResults(); 88 78 } … … 160 150 return estimatedValues.DefaultIfEmpty(double.NaN).Average(); 161 151 } 152 153 154 public void AddModelsAndParitions(IEnumerable<IRegressionSolution> solutions) { 155 foreach (var solution in solutions) { 156 var ensembleSolution = solution as RegressionEnsembleSolution; 157 if (ensembleSolution != null) { 158 var data = from m in ensembleSolution.Model.Models 159 let train = ensembleSolution.trainingPartitions[m] 160 let test = ensembleSolution.testPartitions[m] 161 select new { m, train, test }; 162 163 foreach (var d in data) { 164 Model.Add(d.m); 165 trainingPartitions[d.m] = (IntRange)d.train.Clone(); 166 testPartitions[d.m] = (IntRange)d.test.Clone(); 167 } 168 } else { 169 Model.Add(solution.Model); 170 trainingPartitions[solution.Model] = (IntRange)solution.ProblemData.TrainingPartition.Clone(); 171 testPartitions[solution.Model] = (IntRange)solution.ProblemData.TestPartition.Clone(); 172 } 173 } 174 175 RecalculateResults(); 176 } 177 178 private void AddModelsAndParitions(IEnumerable<IRegressionModel> models, IEnumerable<IntRange> trainingPartitions, IEnumerable<IntRange> testPartitions) { 179 var modelEnumerator = models.GetEnumerator(); 180 var trainingPartitionEnumerator = trainingPartitions.GetEnumerator(); 181 var testPartitionEnumerator = testPartitions.GetEnumerator(); 182 183 while (modelEnumerator.MoveNext() & trainingPartitionEnumerator.MoveNext() & testPartitionEnumerator.MoveNext()) { 184 this.trainingPartitions[modelEnumerator.Current] = (IntRange)trainingPartitionEnumerator.Current.Clone(); 185 this.testPartitions[modelEnumerator.Current] = (IntRange)testPartitionEnumerator.Current.Clone(); 186 } 187 if (modelEnumerator.MoveNext() | trainingPartitionEnumerator.MoveNext() | testPartitionEnumerator.MoveNext()) { 188 throw new ArgumentException(); 189 } 190 } 162 191 } 163 192 } -
branches/QAPAlgorithms/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionProblemData.cs
r6238 r6569 77 77 #endregion 78 78 79 public IValueParameter<StringValue> TargetVariableParameter {80 get { return ( IValueParameter<StringValue>)Parameters[TargetVariableParameterName]; }79 public ConstrainedValueParameter<StringValue> TargetVariableParameter { 80 get { return (ConstrainedValueParameter<StringValue>)Parameters[TargetVariableParameterName]; } 81 81 } 82 82 public string TargetVariable { -
branches/QAPAlgorithms/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolution.cs
r6238 r6569 20 20 #endregion 21 21 22 using System;23 22 using System.Collections.Generic; 24 23 using System.Linq; … … 110 109 Add(new Result(TestNormalizedMeanSquaredErrorResultName, "Normalized mean of squared errors of the model on the test partition", new DoubleValue())); 111 110 112 RecalculateResults();111 CalculateResults(); 113 112 } 114 113 … … 117 116 } 118 117 119 protected override void OnProblemDataChanged(EventArgs e) { 120 base.OnProblemDataChanged(e); 121 RecalculateResults(); 122 } 123 protected override void OnModelChanged(EventArgs e) { 124 base.OnModelChanged(e); 125 RecalculateResults(); 118 protected override void RecalculateResults() { 119 CalculateResults(); 126 120 } 127 121 128 pr otected void RecalculateResults() {122 private void CalculateResults() { 129 123 double[] estimatedTrainingValues = EstimatedTrainingValues.ToArray(); // cache values 130 124 IEnumerable<double> originalTrainingValues = ProblemData.Dataset.GetEnumeratedVariableValues(ProblemData.TargetVariable, ProblemData.TrainingIndizes); -
branches/QAPAlgorithms/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Classification/IClassificationEnsembleModel.cs
r5809 r6569 23 23 namespace HeuristicLab.Problems.DataAnalysis { 24 24 public interface IClassificationEnsembleModel : IClassificationModel { 25 void Add(IClassificationModel model); 25 26 IEnumerable<IClassificationModel> Models { get; } 26 27 IEnumerable<IEnumerable<double>> GetEstimatedClassValueVectors(Dataset dataset, IEnumerable<int> rows); -
branches/QAPAlgorithms/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Regression/IRegressionEnsembleModel.cs
r5809 r6569 23 23 namespace HeuristicLab.Problems.DataAnalysis { 24 24 public interface IRegressionEnsembleModel : IRegressionModel { 25 void Add(IRegressionModel model); 25 26 IEnumerable<IRegressionModel> Models { get; } 26 27 IEnumerable<IEnumerable<double>> GetEstimatedValueVectors(Dataset dataset, IEnumerable<int> rows); -
branches/QAPAlgorithms/HeuristicLab.Problems.DataAnalysis/3.4/Properties/AssemblyInfo.frame
r5860 r6569 53 53 // by using the '*' as shown below: 54 54 [assembly: AssemblyVersion("3.4.0.0")] 55 [assembly: AssemblyFileVersion("3.4. 0.$WCREV$")]55 [assembly: AssemblyFileVersion("3.4.1.$WCREV$")] -
branches/QAPAlgorithms/HeuristicLab.Problems.DataAnalysis/3.4/Tests/Properties/AssemblyInfo.cs
r5809 r6569 52 52 // by using the '*' as shown below: 53 53 [assembly: AssemblyVersion("3.4.0.0")] 54 [assembly: AssemblyFileVersion("3.4. 0.0")]54 [assembly: AssemblyFileVersion("3.4.1.0")]
Note: See TracChangeset
for help on using the changeset viewer.