Changeset 7729
- Timestamp:
- 04/16/12 09:14:38 (13 years ago)
- Location:
- branches/ClassificationEnsembleVoting
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj
r7596 r7729 97 97 <Reference Include="HeuristicLab.Common.Resources-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 98 98 <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 99 <Reference Include="HeuristicLab.Core.Views-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 99 <Reference Include="HeuristicLab.Core.Views-3.3"> 100 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Core.Views-3.3.dll</HintPath> 101 </Reference> 100 102 <Reference Include="HeuristicLab.Data-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 101 <Reference Include="HeuristicLab.Data.Views-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 102 <Reference Include="HeuristicLab.MainForm-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 103 <Reference Include="HeuristicLab.MainForm.WindowsForms-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 103 <Reference Include="HeuristicLab.Data.Views-3.3"> 104 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Data.Views-3.3.dll</HintPath> 105 </Reference> 106 <Reference Include="HeuristicLab.MainForm-3.3"> 107 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.MainForm-3.3.dll</HintPath> 108 </Reference> 109 <Reference Include="HeuristicLab.MainForm.WindowsForms-3.3"> 110 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.MainForm.WindowsForms-3.3.dll</HintPath> 111 </Reference> 104 112 <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 105 <Reference Include="HeuristicLab.Optimization.Views-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 106 <Reference Include="HeuristicLab.Optimizer-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 107 <Reference Include="HeuristicLab.Parameters.Views-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 113 <Reference Include="HeuristicLab.Optimization.Views-3.3"> 114 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Optimization.Views-3.3.dll</HintPath> 115 </Reference> 116 <Reference Include="HeuristicLab.Optimizer-3.3"> 117 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Optimizer-3.3.dll</HintPath> 118 </Reference> 119 <Reference Include="HeuristicLab.Parameters.Views-3.3"> 120 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Parameters.Views-3.3.dll</HintPath> 121 </Reference> 108 122 <Reference Include="HeuristicLab.Persistence-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 109 123 <Reference Include="HeuristicLab.PluginInfrastructure-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 110 <Reference Include="HeuristicLab.Visualization.ChartControlsExtensions-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 124 <Reference Include="HeuristicLab.Visualization.ChartControlsExtensions-3.3"> 125 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Visualization.ChartControlsExtensions-3.3.dll</HintPath> 126 </Reference> 111 127 <Reference Include="System" /> 112 128 <Reference Include="System.Core"> -
branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj
r7596 r7729 93 93 </PropertyGroup> 94 94 <ItemGroup> 95 <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 96 <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 97 <Reference Include="HeuristicLab.Common.Resources-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 98 <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 99 <Reference Include="HeuristicLab.Data-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 100 <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 101 <Reference Include="HeuristicLab.Parameters-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 102 <Reference Include="HeuristicLab.Persistence-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 103 <Reference Include="HeuristicLab.PluginInfrastructure-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 95 <Reference Include="HeuristicLab.Collections-3.3"> 96 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Collections-3.3.dll</HintPath> 97 </Reference> 98 <Reference Include="HeuristicLab.Common-3.3"> 99 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath> 100 </Reference> 101 <Reference Include="HeuristicLab.Common.Resources-3.3"> 102 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Common.Resources-3.3.dll</HintPath> 103 </Reference> 104 <Reference Include="HeuristicLab.Core-3.3"> 105 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath> 106 </Reference> 107 <Reference Include="HeuristicLab.Data-3.3"> 108 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Data-3.3.dll</HintPath> 109 </Reference> 110 <Reference Include="HeuristicLab.Optimization-3.3"> 111 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Optimization-3.3.dll</HintPath> 112 </Reference> 113 <Reference Include="HeuristicLab.Parameters-3.3"> 114 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Parameters-3.3.dll</HintPath> 115 </Reference> 116 <Reference Include="HeuristicLab.Persistence-3.3"> 117 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Persistence-3.3.dll</HintPath> 118 </Reference> 119 <Reference Include="HeuristicLab.PluginInfrastructure-3.3"> 120 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath> 121 </Reference> 104 122 <Reference Include="System" /> 105 123 <Reference Include="System.Core"> … … 129 147 <Compile Include="Implementation\Classification\DiscriminantFunctionClassificationSolutionBase.cs" /> 130 148 <Compile Include="Implementation\Classification\WeightCalculators\AccuracyWeightCalculator.cs" /> 149 <Compile Include="Implementation\Classification\WeightCalculators\AverageThresholdCalculator.cs" /> 131 150 <Compile Include="Implementation\Classification\WeightCalculators\ContinuousPointCertaintyWeightCalculator.cs" /> 132 151 <Compile Include="Implementation\Classification\WeightCalculators\DiscriminantClassificationWeightCalculator.cs" /> 152 <Compile Include="Implementation\Classification\WeightCalculators\MedianPointThresholdCalculator.cs" /> 133 153 <Compile Include="Implementation\Classification\WeightCalculators\MedianThresholdCalculator.cs" /> 134 154 <Compile Include="Implementation\Classification\WeightCalculators\NeighbourhoodWeightCalculator.cs" /> -
branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/WeightCalculators/DiscriminantClassificationWeightCalculator.cs
r7562 r7729 59 59 60 60 IEnumerable<IDictionary<IClassificationSolution, double>> estimatedClassValues = GetEstimatedClassValues(solutions, dataset, rows, handler); 61 IEnumerable<IDictionary<I ClassificationSolution, double>> estimatedValues = GetEstimatedValues(discriminantSolutions, dataset, rows, handler);61 IEnumerable<IDictionary<IDiscriminantFunctionClassificationSolution, double>> estimatedValues = GetEstimatedValues(discriminantSolutions, dataset, rows, handler); 62 62 63 63 return from zip in estimatedClassValues.Zip(estimatedValues, (classValues, values) => new { ClassValues = classValues, Values = values }) … … 65 65 } 66 66 67 protected virtual double DiscriminantAggregateEstimatedClassValues(IDictionary<IClassificationSolution, double> estimatedClassValues, IDictionary<I ClassificationSolution, double> estimatedValues) {67 protected virtual double DiscriminantAggregateEstimatedClassValues(IDictionary<IClassificationSolution, double> estimatedClassValues, IDictionary<IDiscriminantFunctionClassificationSolution, double> estimatedValues) { 68 68 return AggregateEstimatedClassValues(estimatedClassValues); 69 69 } 70 70 71 protected IEnumerable<IDictionary<I ClassificationSolution, double>> GetEstimatedValues(IEnumerable<IDiscriminantFunctionClassificationSolution> solutions, Dataset dataset, IEnumerable<int> rows, CheckPoint handler) {71 protected IEnumerable<IDictionary<IDiscriminantFunctionClassificationSolution, double>> GetEstimatedValues(IEnumerable<IDiscriminantFunctionClassificationSolution> solutions, Dataset dataset, IEnumerable<int> rows, CheckPoint handler) { 72 72 var estimatedValuesEnumerators = (from solution in solutions 73 select new { Solution = solution, EstimatedValuesEnumerator = solution.Model.GetEstimated ClassValues(dataset, rows).GetEnumerator() })73 select new { Solution = solution, EstimatedValuesEnumerator = solution.Model.GetEstimatedValues(dataset, rows).GetEnumerator() }) 74 74 .ToList(); 75 75 … … 79 79 where handler(enumerator.Solution.ProblemData, rowEnumerator.Current) 80 80 select enumerator) 81 .ToDictionary(x => (IClassificationSolution)x.Solution, x => x.EstimatedValuesEnumerator.Current);81 .ToDictionary(x => x.Solution, x => x.EstimatedValuesEnumerator.Current); 82 82 } 83 83 } -
branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/WeightCalculators/MedianThresholdCalculator.cs
r7562 r7729 47 47 protected double[] classValues; 48 48 49 /// <summary>50 ///51 /// </summary>52 /// <param name="discriminantSolutions"></param>53 /// <returns>median instead of weights, because it doesn't use any weights</returns>54 49 protected override IEnumerable<double> DiscriminantCalculateWeights(IEnumerable<IDiscriminantFunctionClassificationSolution> discriminantSolutions) { 55 List<List<double>> estimatedValues = new List<List<double>>(); 56 List<List<double>> estimatedClassValues = new List<List<double>>(); 57 58 List<IClassificationProblemData> solutionProblemData = discriminantSolutions.Select(sol => sol.ProblemData).ToList(); 59 Dataset dataSet = solutionProblemData[0].Dataset; 60 IEnumerable<int> rows = Enumerable.Range(0, dataSet.Rows); 61 foreach (var solution in discriminantSolutions) { 62 estimatedValues.Add(solution.Model.GetEstimatedValues(dataSet, rows).ToList()); 63 estimatedClassValues.Add(solution.Model.GetEstimatedValues(dataSet, rows).ToList()); 50 classValues = discriminantSolutions.First().Model.ClassValues.ToArray(); 51 var modelThresholds = discriminantSolutions.Select(x => x.Model.Thresholds.ToArray()); 52 threshold = new double[modelThresholds.First().GetLength(0)]; 53 for (int i = 0; i < modelThresholds.First().GetLength(0); i++) { 54 threshold[i] = GetMedian(modelThresholds.Select(x => x[i]).ToList()); 64 55 } 65 66 List<double> median = new List<double>();67 List<double> targetValues = dataSet.GetDoubleValues(solutionProblemData[0].TargetVariable).ToList();68 IList<double> curTrainingpoints = new List<double>();69 int removed = 0;70 int count = targetValues.Count;71 for (int point = 0; point < count; point++) {72 curTrainingpoints.Clear();73 for (int solutionPos = 0; solutionPos < solutionProblemData.Count; solutionPos++) {74 if (PointInTraining(solutionProblemData[solutionPos], point)) {75 curTrainingpoints.Add(estimatedValues[solutionPos][point]);76 }77 }78 if (curTrainingpoints.Count > 0)79 median.Add(GetMedian(curTrainingpoints.OrderBy(p => p).ToList()));80 else {81 //remove not used points82 targetValues.RemoveAt(point - removed);83 removed++;84 }85 }86 AccuracyMaximizationThresholdCalculator.CalculateThresholds(solutionProblemData[0], median, targetValues, out classValues, out threshold);87 56 return Enumerable.Repeat<double>(1, discriminantSolutions.Count()); 88 57 } 89 58 90 protected override double DiscriminantAggregateEstimatedClassValues(IDictionary<IClassificationSolution, double> estimatedClassValues, IDictionary<I ClassificationSolution, double> estimatedValues) {59 protected override double DiscriminantAggregateEstimatedClassValues(IDictionary<IClassificationSolution, double> estimatedClassValues, IDictionary<IDiscriminantFunctionClassificationSolution, double> estimatedValues) { 91 60 IList<double> values = estimatedValues.Select(x => x.Value).ToList(); 92 61 if (values.Count <= 0) … … 122 91 else { 123 92 double distance = threshold[1] - classValues[0]; 124 return (1 / distance) * ( median - classValues[0]);93 return (1 / distance) * (threshold[1] - median); 125 94 } 126 95 } else if (estimatedClassValue.Equals(classValues[1])) { … … 131 100 else { 132 101 double distance = classValues[1] - threshold[1]; 133 return (1 / distance) * ( classValues[1] - median);102 return (1 / distance) * (median - threshold[1]); 134 103 } 135 104 } else
Note: See TracChangeset
for help on using the changeset viewer.