Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12611


Ignore:
Timestamp:
07/06/15 15:56:59 (9 years ago)
Author:
gkronber
Message:

#2261: produce classification solution (discriminant function) when using logistic regression loss

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GBT-trunkintegration/HeuristicLab.Algorithms.DataAnalysis/3.4/GradientBoostedTrees/GradientBoostedTreesAlgorithm.cs

    r12591 r12611  
    232232
    233233      // produce solution
    234       if (CreateSolution)
    235         Results.Add(new Result("Solution", new RegressionSolution(state.GetModel(), (IRegressionProblemData)problemData.Clone())));
     234      if (CreateSolution) {
     235        // for logistic regression we produce a classification solution
     236        if (lossFunction is LogisticRegressionLoss) {
     237          var model = new DiscriminantFunctionClassificationModel(state.GetModel(),
     238            new AccuracyMaximizationThresholdCalculator());
     239          var classificationProblemData = new ClassificationProblemData(problemData.Dataset,
     240            problemData.AllowedInputVariables, problemData.TargetVariable, problemData.Transformations);
     241          model.RecalculateModelParameters(classificationProblemData, classificationProblemData.TrainingIndices);
     242
     243          var classificationSolution = new DiscriminantFunctionClassificationSolution(model, classificationProblemData);
     244          Results.Add(new Result("Solution (classification)", classificationSolution));
     245        } else {
     246          // otherwise we produce a regression solution
     247          Results.Add(new Result("Solution", new RegressionSolution(state.GetModel(), (IRegressionProblemData)problemData.Clone())));
     248        }
     249      }
    236250    }
    237251  }
Note: See TracChangeset for help on using the changeset viewer.