- Timestamp:
- 11/05/16 09:06:31 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Algorithms.DataAnalysis.Glmnet/3.4/ElasticNetLinearRegression.cs
r14370 r14373 140 140 var dataRows = new DataRow[nCoeff]; 141 141 var allowedVars = Problem.ProblemData.AllowedInputVariables.ToArray(); 142 var numNonZeroCoeffs = new int[nLambdas]; 142 143 for (int i = 0; i < nCoeff; i++) { 143 144 var coeffId = allowedVars[i]; … … 147 148 coeffTable.Rows.Add(dataRows[i]); 148 149 } 150 for (int i = 0; i < coeff.GetLength(0); i++) { 151 for (int j = 0; j < coeff.GetLength(1); j++) { 152 if (!coeff[i, j].IsAlmost(0.0)) { 153 numNonZeroCoeffs[i]++; 154 } 155 } 156 } 149 157 150 158 Results.Add(new Result(coeffTable.Name, coeffTable.Description, coeffTable)); 151 159 152 var nmsePlot = new ScatterPlot("NMSE", "Path of NMSE values over different lambda values");160 var nmsePlot = new IndexedDataTable<double>("NMSE", "Path of NMSE values over different lambda values"); 153 161 nmsePlot.VisualProperties.YAxisMaximumAuto = false; 154 162 nmsePlot.VisualProperties.YAxisMinimumAuto = false; … … 158 166 nmsePlot.VisualProperties.YAxisMinimumFixedValue = 0; 159 167 nmsePlot.VisualProperties.YAxisMaximumFixedValue = 1.0; 168 nmsePlot.VisualProperties.XAxisLogScale = true; 160 169 nmsePlot.VisualProperties.XAxisTitle = "Log10(Lambda)"; 161 170 nmsePlot.VisualProperties.YAxisTitle = "Normalized mean of squared errors (NMSE)"; 162 nmsePlot.Rows.Add(new ScatterPlotDataRow("NMSE (train)", "Path of NMSE values over different lambda values", lambda.Zip(trainNMSE, (l, v) => new Point2D<double>(Math.Log10(l), v)))); 163 nmsePlot.Rows.Add(new ScatterPlotDataRow("NMSE (test)", "Path of NMSE values over different lambda values", lambda.Zip(testNMSE, (l, v) => new Point2D<double>(Math.Log10(l), v)))); 171 nmsePlot.VisualProperties.SecondYAxisTitle= "Number of variables"; 172 nmsePlot.Rows.Add(new IndexedDataRow<double>("NMSE (train)", "Path of NMSE values over different lambda values", lambda.Zip(trainNMSE, (l, v) => Tuple.Create(l, v)))); 173 nmsePlot.Rows.Add(new IndexedDataRow<double>("NMSE (test)", "Path of NMSE values over different lambda values", lambda.Zip(testNMSE, (l, v) => Tuple.Create(l, v)))); 174 nmsePlot.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)))); 164 175 if (lambda.Length > 2) { 165 nmsePlot.VisualProperties.XAxisMinimumFixedValue = Math.Floor(Math.Log10(lambda.Last())); 166 nmsePlot.VisualProperties.XAxisMaximumFixedValue = Math.Ceiling(Math.Log10(lambda.Skip(1).First())); 167 } 168 nmsePlot.Rows["NMSE (train)"].VisualProperties.PointSize = 5; 169 nmsePlot.Rows["NMSE (test)"].VisualProperties.PointSize = 5; 176 nmsePlot.VisualProperties.XAxisMinimumFixedValue = Math.Pow(10, Math.Floor(Math.Log10(lambda.Last()))); 177 nmsePlot.VisualProperties.XAxisMaximumFixedValue = Math.Pow(10, Math.Ceiling(Math.Log10(lambda.Skip(1).First()))); 178 } 179 nmsePlot.Rows["NMSE (train)"].VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Points; 180 nmsePlot.Rows["NMSE (test)"].VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Points; 181 nmsePlot.Rows["Number of variables"].VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Points; 182 nmsePlot.Rows["Number of variables"].VisualProperties.SecondYAxis = true; 183 170 184 171 185 Results.Add(new Result(nmsePlot.Name, nmsePlot.Description, nmsePlot));
Note: See TracChangeset
for help on using the changeset viewer.