Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/23/11 16:12:38 (14 years ago)
Author:
gkronber
Message:

#1450: fixed bugs in calculation of estimated values in ensemble solutions for regression and classification.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationEnsembleSolution.cs

    r6239 r6254  
    106106
    107107          var selectedEnumerators = from pair in estimatedValuesEnumerators
    108                                     where trainingPartitions == null || !trainingPartitions.ContainsKey(pair.Model) ||
    109                                          (trainingPartitions[pair.Model].Start <= currentRow && currentRow < trainingPartitions[pair.Model].End)
     108                                    where RowIsTrainingForModel(currentRow, pair.Model) && !RowIsTestForModel(currentRow, pair.Model)
    110109                                    select pair.EstimatedValuesEnumerator;
    111110          yield return AggregateEstimatedClassValues(selectedEnumerators.Select(x => x.Current));
     
    126125
    127126          var selectedEnumerators = from pair in estimatedValuesEnumerators
    128                                     where testPartitions == null || !testPartitions.ContainsKey(pair.Model) ||
    129                                       (testPartitions[pair.Model].Start <= currentRow && currentRow < testPartitions[pair.Model].End)
     127                                    where RowIsTestForModel(currentRow, pair.Model)
    130128                                    select pair.EstimatedValuesEnumerator;
    131129
     
    133131        }
    134132      }
     133    }
     134
     135    private bool RowIsTrainingForModel(int currentRow, IClassificationModel model) {
     136      return trainingPartitions == null || !trainingPartitions.ContainsKey(model) ||
     137              (trainingPartitions[model].Start <= currentRow && currentRow < trainingPartitions[model].End);
     138    }
     139
     140    private bool RowIsTestForModel(int currentRow, IClassificationModel model) {
     141      return testPartitions == null || !testPartitions.ContainsKey(model) ||
     142              (testPartitions[model].Start <= currentRow && currentRow < testPartitions[model].End);
    135143    }
    136144
     
    156164      .OrderBy(g => -g.Count())
    157165      .Select(g => g.Key)
     166      .DefaultIfEmpty(double.NaN)
    158167      .First();
    159168    }
Note: See TracChangeset for help on using the changeset viewer.