Free cookie consent management tool by TermsFeed Policy Generator

Changeset 14374


Ignore:
Timestamp:
11/05/16 19:30:15 (7 years ago)
Author:
gkronber
Message:

#745 added number of variables as secondary axis to the chart for coefficient values and changed x-axis to log-scaled.

File:
1 edited

Legend:

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

    r14373 r14374  
    135135      RunElasticNetLinearRegression(Problem.ProblemData, Penality, out lambda, out trainNMSE, out testNMSE, out coeff, out intercept);
    136136
    137       var coeffTable = new DataTable("Coefficient Paths", "The paths of standarized coefficient values over different lambda values");
     137      var coeffTable = new IndexedDataTable<double>("Coefficient Paths", "The paths of standarized coefficient values over different lambda values");
     138      coeffTable.VisualProperties.YAxisMaximumAuto = false;
     139      coeffTable.VisualProperties.YAxisMinimumAuto = false;
     140      coeffTable.VisualProperties.XAxisMaximumAuto = false;
     141      coeffTable.VisualProperties.XAxisMinimumAuto = false;
     142
     143      coeffTable.VisualProperties.XAxisLogScale = true;
     144      coeffTable.VisualProperties.XAxisTitle = "Log10(Lambda)";
     145      coeffTable.VisualProperties.YAxisTitle = "Coefficient value";
     146      coeffTable.VisualProperties.SecondYAxisTitle = "Number of variables";
     147
    138148      var nLambdas = lambda.Length;
    139149      var nCoeff = coeff.GetLength(1);
    140       var dataRows = new DataRow[nCoeff];
     150      var dataRows = new IndexedDataRow<double>[nCoeff];
    141151      var allowedVars = Problem.ProblemData.AllowedInputVariables.ToArray();
    142152      var numNonZeroCoeffs = new int[nLambdas];
     
    144154        var coeffId = allowedVars[i];
    145155        double sigma = Problem.ProblemData.Dataset.GetDoubleValues(coeffId).StandardDeviation();
    146         var path = Enumerable.Range(0, nLambdas).Select(r => coeff[r, i] * sigma).ToArray();
    147         dataRows[i] = new DataRow(coeffId, coeffId, path);
     156        var path = Enumerable.Range(0, nLambdas).Select(r => Tuple.Create(lambda[r], coeff[r, i] * sigma)).ToArray();
     157        dataRows[i] = new IndexedDataRow<double>(coeffId, coeffId, path);
    148158        coeffTable.Rows.Add(dataRows[i]);
    149159      }
     
    155165        }
    156166      }
     167      if (lambda.Length > 2) {
     168        coeffTable.VisualProperties.XAxisMinimumFixedValue = Math.Pow(10, Math.Floor(Math.Log10(lambda.Last())));
     169        coeffTable.VisualProperties.XAxisMaximumFixedValue = Math.Pow(10, Math.Ceiling(Math.Log10(lambda.Skip(1).First())));
     170      }
     171      coeffTable.Rows.Add(new IndexedDataRow<double>("Number of variables", "The number of non-zero coefficients for each step in the path", lambda.Zip(numNonZeroCoeffs, (l, v) => Tuple.Create(l, (double)v))));
     172      coeffTable.Rows["Number of variables"].VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Points;
     173      coeffTable.Rows["Number of variables"].VisualProperties.SecondYAxis = true;
    157174
    158175      Results.Add(new Result(coeffTable.Name, coeffTable.Description, coeffTable));
Note: See TracChangeset for help on using the changeset viewer.