- Timestamp:
- 12/21/18 14:07:02 (6 years ago)
- Location:
- stable
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
-
stable/HeuristicLab.Problems.DataAnalysis
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis merged: 15871
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Classification/ClassificationSolutionVariableImpactsCalculator.cs
r16432 r16434 100 100 var problemData = solution.ProblemData; 101 101 var dataset = problemData.Dataset; 102 var model = (IClassificationModel)solution.Model.Clone(); //mkommend: clone of model is necessary, because the thresholds for IDiscriminantClassificationModels are updated 102 103 103 104 IEnumerable<int> rows; … … 137 138 // calculate impacts for double variables 138 139 foreach (var inputVariable in allowedInputVariables.Where(problemData.Dataset.VariableHasType<double>)) { 139 var newEstimates = EvaluateModelWithReplacedVariable( solution.Model, inputVariable, modifiableDataset, rows, replacementMethod);140 var newEstimates = EvaluateModelWithReplacedVariable(model, inputVariable, modifiableDataset, rows, replacementMethod); 140 141 var newAccuracy = OnlineAccuracyCalculator.Calculate(targetValues, newEstimates, out error); 141 142 if (error != OnlineCalculatorError.None) throw new InvalidOperationException("Error during R² calculation with replaced inputs."); … … 150 151 var smallestImpact = double.PositiveInfinity; 151 152 foreach (var repl in problemData.Dataset.GetStringValues(inputVariable, rows).Distinct()) { 152 var newEstimates = EvaluateModelWithReplacedVariable( solution.Model, inputVariable, modifiableDataset, rows,153 var newEstimates = EvaluateModelWithReplacedVariable(model, inputVariable, modifiableDataset, rows, 153 154 Enumerable.Repeat(repl, dataset.Rows)); 154 155 var newAccuracy = OnlineAccuracyCalculator.Calculate(targetValues, newEstimates, out error); … … 164 165 // calculate impacts for factor variables 165 166 166 var newEstimates = EvaluateModelWithReplacedVariable( solution.Model, inputVariable, modifiableDataset, rows,167 var newEstimates = EvaluateModelWithReplacedVariable(model, inputVariable, modifiableDataset, rows, 167 168 factorReplacementMethod); 168 169 var newAccuracy = OnlineAccuracyCalculator.Calculate(targetValues, newEstimates, out error); … … 263 264 var originalValues = dataset.GetReadOnlyDoubleValues(variable).ToList(); 264 265 dataset.ReplaceVariable(variable, replacementValues.ToList()); 266 267 var discModel = model as IDiscriminantFunctionClassificationModel; 268 if (discModel != null) { 269 var problemData = new ClassificationProblemData(dataset, dataset.VariableNames, model.TargetVariable); 270 discModel.RecalculateModelParameters(problemData, rows); 271 } 272 265 273 //mkommend: ToList is used on purpose to avoid lazy evaluation that could result in wrong estimates due to variable replacements 266 274 var estimates = model.GetEstimatedClassValues(dataset, rows).ToList(); … … 273 281 var originalValues = dataset.GetReadOnlyStringValues(variable).ToList(); 274 282 dataset.ReplaceVariable(variable, replacementValues.ToList()); 283 284 285 var discModel = model as IDiscriminantFunctionClassificationModel; 286 if (discModel != null) { 287 var problemData = new ClassificationProblemData(dataset, dataset.VariableNames, model.TargetVariable); 288 discModel.RecalculateModelParameters(problemData, rows); 289 } 290 275 291 //mkommend: ToList is used on purpose to avoid lazy evaluation that could result in wrong estimates due to variable replacements 276 292 var estimates = model.GetEstimatedClassValues(dataset, rows).ToList();
Note: See TracChangeset
for help on using the changeset viewer.