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/Regression/RegressionEnsembleSolution.cs

    r6239 r6254  
    101101
    102102          var selectedEnumerators = from pair in estimatedValuesEnumerators
    103                                     where trainingPartitions == null || !trainingPartitions.ContainsKey(pair.Model) ||
    104                                          (trainingPartitions[pair.Model].Start <= currentRow && currentRow < trainingPartitions[pair.Model].End)
     103                                    where RowIsTrainingForModel(currentRow, pair.Model) && !RowIsTestForModel(currentRow, pair.Model)
    105104                                    select pair.EstimatedValuesEnumerator;
    106105          yield return AggregateEstimatedValues(selectedEnumerators.Select(x => x.Current));
     
    121120
    122121          var selectedEnumerators = from pair in estimatedValuesEnumerators
    123                                     where testPartitions == null || !testPartitions.ContainsKey(pair.Model) ||
    124                                       (testPartitions[pair.Model].Start <= currentRow && currentRow < testPartitions[pair.Model].End)
     122                                    where RowIsTestForModel(currentRow, pair.Model)
    125123                                    select pair.EstimatedValuesEnumerator;
    126124
     
    128126        }
    129127      }
     128    }
     129
     130    private bool RowIsTrainingForModel(int currentRow, IRegressionModel model) {
     131      return trainingPartitions == null || !trainingPartitions.ContainsKey(model) ||
     132              (trainingPartitions[model].Start <= currentRow && currentRow < trainingPartitions[model].End);
     133    }
     134
     135    private bool RowIsTestForModel(int currentRow, IRegressionModel model) {
     136      return testPartitions == null || !testPartitions.ContainsKey(model) ||
     137              (testPartitions[model].Start <= currentRow && currentRow < testPartitions[model].End);
    130138    }
    131139
     
    148156    private double AggregateEstimatedValues(IEnumerable<double> estimatedValues) {
    149157      return estimatedValues.DefaultIfEmpty(double.NaN).Average();
    150     }   
     158    }
    151159  }
    152160}
Note: See TracChangeset for help on using the changeset viewer.