Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7729 for branches


Ignore:
Timestamp:
04/16/12 09:14:38 (13 years ago)
Author:
sforsten
Message:

#1776:

  • bugfix the method GetEstimatedValues of DiscriminantClassificationWeightCalculator returns real values and not class values
  • changed arguments of method DiscriminantAggregateEstimatedClassValues of DiscriminantClassificationWeightCalculator
  • added two calculators
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  
    9797    <Reference Include="HeuristicLab.Common.Resources-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    9898    <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>
    100102    <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>
    104112    <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>
    108122    <Reference Include="HeuristicLab.Persistence-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    109123    <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>
    111127    <Reference Include="System" />
    112128    <Reference Include="System.Core">
  • branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj

    r7596 r7729  
    9393  </PropertyGroup>
    9494  <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>
    104122    <Reference Include="System" />
    105123    <Reference Include="System.Core">
     
    129147    <Compile Include="Implementation\Classification\DiscriminantFunctionClassificationSolutionBase.cs" />
    130148    <Compile Include="Implementation\Classification\WeightCalculators\AccuracyWeightCalculator.cs" />
     149    <Compile Include="Implementation\Classification\WeightCalculators\AverageThresholdCalculator.cs" />
    131150    <Compile Include="Implementation\Classification\WeightCalculators\ContinuousPointCertaintyWeightCalculator.cs" />
    132151    <Compile Include="Implementation\Classification\WeightCalculators\DiscriminantClassificationWeightCalculator.cs" />
     152    <Compile Include="Implementation\Classification\WeightCalculators\MedianPointThresholdCalculator.cs" />
    133153    <Compile Include="Implementation\Classification\WeightCalculators\MedianThresholdCalculator.cs" />
    134154    <Compile Include="Implementation\Classification\WeightCalculators\NeighbourhoodWeightCalculator.cs" />
  • branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/WeightCalculators/DiscriminantClassificationWeightCalculator.cs

    r7562 r7729  
    5959
    6060      IEnumerable<IDictionary<IClassificationSolution, double>> estimatedClassValues = GetEstimatedClassValues(solutions, dataset, rows, handler);
    61       IEnumerable<IDictionary<IClassificationSolution, double>> estimatedValues = GetEstimatedValues(discriminantSolutions, dataset, rows, handler);
     61      IEnumerable<IDictionary<IDiscriminantFunctionClassificationSolution, double>> estimatedValues = GetEstimatedValues(discriminantSolutions, dataset, rows, handler);
    6262
    6363      return from zip in estimatedClassValues.Zip(estimatedValues, (classValues, values) => new { ClassValues = classValues, Values = values })
     
    6565    }
    6666
    67     protected virtual double DiscriminantAggregateEstimatedClassValues(IDictionary<IClassificationSolution, double> estimatedClassValues, IDictionary<IClassificationSolution, double> estimatedValues) {
     67    protected virtual double DiscriminantAggregateEstimatedClassValues(IDictionary<IClassificationSolution, double> estimatedClassValues, IDictionary<IDiscriminantFunctionClassificationSolution, double> estimatedValues) {
    6868      return AggregateEstimatedClassValues(estimatedClassValues);
    6969    }
    7070
    71     protected IEnumerable<IDictionary<IClassificationSolution, 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) {
    7272      var estimatedValuesEnumerators = (from solution in solutions
    73                                         select new { Solution = solution, EstimatedValuesEnumerator = solution.Model.GetEstimatedClassValues(dataset, rows).GetEnumerator() })
     73                                        select new { Solution = solution, EstimatedValuesEnumerator = solution.Model.GetEstimatedValues(dataset, rows).GetEnumerator() })
    7474                                        .ToList();
    7575
     
    7979                      where handler(enumerator.Solution.ProblemData, rowEnumerator.Current)
    8080                      select enumerator)
    81                       .ToDictionary(x => (IClassificationSolution)x.Solution, x => x.EstimatedValuesEnumerator.Current);
     81                      .ToDictionary(x => x.Solution, x => x.EstimatedValuesEnumerator.Current);
    8282      }
    8383    }
  • branches/ClassificationEnsembleVoting/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/WeightCalculators/MedianThresholdCalculator.cs

    r7562 r7729  
    4747    protected double[] classValues;
    4848
    49     /// <summary>
    50     ///
    51     /// </summary>
    52     /// <param name="discriminantSolutions"></param>
    53     /// <returns>median instead of weights, because it doesn't use any weights</returns>
    5449    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());
    6455      }
    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 points
    82           targetValues.RemoveAt(point - removed);
    83           removed++;
    84         }
    85       }
    86       AccuracyMaximizationThresholdCalculator.CalculateThresholds(solutionProblemData[0], median, targetValues, out classValues, out threshold);
    8756      return Enumerable.Repeat<double>(1, discriminantSolutions.Count());
    8857    }
    8958
    90     protected override double DiscriminantAggregateEstimatedClassValues(IDictionary<IClassificationSolution, double> estimatedClassValues, IDictionary<IClassificationSolution, double> estimatedValues) {
     59    protected override double DiscriminantAggregateEstimatedClassValues(IDictionary<IClassificationSolution, double> estimatedClassValues, IDictionary<IDiscriminantFunctionClassificationSolution, double> estimatedValues) {
    9160      IList<double> values = estimatedValues.Select(x => x.Value).ToList();
    9261      if (values.Count <= 0)
     
    12291        else {
    12392          double distance = threshold[1] - classValues[0];
    124           return (1 / distance) * (median - classValues[0]);
     93          return (1 / distance) * (threshold[1] - median);
    12594        }
    12695      } else if (estimatedClassValue.Equals(classValues[1])) {
     
    131100        else {
    132101          double distance = classValues[1] - threshold[1];
    133           return (1 / distance) * (classValues[1] - median);
     102          return (1 / distance) * (median - threshold[1]);
    134103        }
    135104      } else
Note: See TracChangeset for help on using the changeset viewer.