Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/16/21 21:35:37 (3 years ago)
Author:
gkronber
Message:

#3128: first dump of exploratory work-in-progress code to make sure the working copy is not lost.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3128_Prediction_Intervals/HeuristicLab.Algorithms.DataAnalysis.Glmnet/3.4/ElasticNetLinearRegression.cs

    r17180 r17991  
    3434using HeuristicLab.Problems.DataAnalysis.Symbolic;
    3535using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression;
     36using HeuristicLab.Analysis.Statistics;
    3637
    3738namespace HeuristicLab.Algorithms.DataAnalysis.Glmnet {
     
    8889    }
    8990
    90   private void CreateSolution(double lambda) {
     91    private void CreateSolution(double lambda) {
    9192      double trainNMSE;
    9293      double testNMSE;
     
    9798      var solution = CreateSymbolicSolution(coeff, Problem.ProblemData);
    9899      Results.Add(new Result(solution.Name, solution.Description, solution));
     100
     101      var xy = Problem.ProblemData.Dataset.ToArray(Problem.ProblemData.AllowedInputVariables.Concat(new[] { Problem.ProblemData.TargetVariable }), Problem.ProblemData.TrainingIndices);
     102      // prepare xy for calculation of parameter statistics
     103      // the last coefficient is the offset
     104      var resid = new double[xy.GetLength(0)];
     105      for (int r = 0; r < xy.GetLength(0); r++) {
     106        resid[r] = xy[r, coeff.Length - 1] - coeff[coeff.Length - 1];
     107        xy[r, coeff.Length - 1] = 1.0;
     108      }
     109      var statistics = Statistics.CalculateParameterStatistics(xy, coeff, resid);
     110      Results.AddOrUpdateResult("Statistics", statistics.AsResultCollection(Problem.ProblemData.AllowedInputVariables.Concat(new string[] { "<const>" })));
    99111    }
    100112
Note: See TracChangeset for help on using the changeset viewer.