Ignore:
Timestamp:
12/21/18 14:10:11 (5 months ago)
Author:
mkommend
Message:

#2871: Merged r15626, r15637, r15665, r15673, r15727, r15728, r15752, r15796, r15797, r15798, r15799, r15802, r15998, r15999, r16015, r16021, r16023 into stable.

Location:
stable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Problems.DataAnalysis

  • stable/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolutionVariableImpactsCalculator.cs

    r15584 r16435  
    9696      DataPartitionEnum data = DataPartitionEnum.Training,
    9797      ReplacementMethodEnum replacementMethod = ReplacementMethodEnum.Median,
    98       FactorReplacementMethodEnum factorReplacementMethod = FactorReplacementMethodEnum.Best) {
     98      FactorReplacementMethodEnum factorReplacementMethod = FactorReplacementMethodEnum.Best,
     99      Func<double, string, bool> progressCallback = null) {
    99100
    100101      var problemData = solution.ProblemData;
     
    134135      var allowedInputVariables = dataset.VariableNames.Where(v => inputvariables.Contains(v)).ToList();
    135136
     137      int curIdx = 0;
     138      int count = allowedInputVariables.Where(problemData.Dataset.VariableHasType<double>).Count();
    136139      // calculate impacts for double variables
    137140      foreach (var inputVariable in allowedInputVariables.Where(problemData.Dataset.VariableHasType<double>)) {
     141        //Report the current progress in percent. If the callback returns true, it means the execution shall be stopped
     142        if (progressCallback != null) {
     143          curIdx++;
     144          if (progressCallback((double)curIdx / count, string.Format("Calculating impact for variable {0} ({1} of {2})", inputVariable, curIdx, count))) { return null; }
     145        }
    138146        var newEstimates = EvaluateModelWithReplacedVariable(solution.Model, inputVariable, modifiableDataset, rows, replacementMethod);
    139147        var newR2 = OnlinePearsonsRCalculator.Calculate(targetValues, newEstimates, out error);
     
    180188    }
    181189
     190
    182191    private static IEnumerable<double> EvaluateModelWithReplacedVariable(IRegressionModel model, string variable, ModifiableDataset dataset, IEnumerable<int> rows, ReplacementMethodEnum replacement = ReplacementMethodEnum.Median) {
    183192      var originalValues = dataset.GetReadOnlyDoubleValues(variable).ToList();
Note: See TracChangeset for help on using the changeset viewer.