Changeset 14374
- Timestamp:
- 11/05/16 19:30:15 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Algorithms.DataAnalysis.Glmnet/3.4/ElasticNetLinearRegression.cs
r14373 r14374 135 135 RunElasticNetLinearRegression(Problem.ProblemData, Penality, out lambda, out trainNMSE, out testNMSE, out coeff, out intercept); 136 136 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 138 148 var nLambdas = lambda.Length; 139 149 var nCoeff = coeff.GetLength(1); 140 var dataRows = new DataRow[nCoeff];150 var dataRows = new IndexedDataRow<double>[nCoeff]; 141 151 var allowedVars = Problem.ProblemData.AllowedInputVariables.ToArray(); 142 152 var numNonZeroCoeffs = new int[nLambdas]; … … 144 154 var coeffId = allowedVars[i]; 145 155 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); 148 158 coeffTable.Rows.Add(dataRows[i]); 149 159 } … … 155 165 } 156 166 } 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; 157 174 158 175 Results.Add(new Result(coeffTable.Name, coeffTable.Description, coeffTable));
Note: See TracChangeset
for help on using the changeset viewer.