Changeset 13889
- Timestamp:
- 06/10/16 10:53:37 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GBM/GradientBoostingRegressionAlgorithm.cs
r13724 r13889 64 64 private const string SetSeedRandomlyParameterName = "SetSeedRandomly"; 65 65 private const string CreateSolutionParameterName = "CreateSolution"; 66 private const string StoreRunsParameterName = "StoreRuns"; 66 67 private const string RegressionAlgorithmSolutionResultParameterName = "RegressionAlgorithmResult"; 67 68 … … 106 107 get { return (IFixedValueParameter<BoolValue>)Parameters[CreateSolutionParameterName]; } 107 108 } 109 public IFixedValueParameter<BoolValue> StoreRunsParameter { 110 get { return (IFixedValueParameter<BoolValue>)Parameters[StoreRunsParameterName]; } 111 } 108 112 109 113 #endregion … … 144 148 get { return CreateSolutionParameter.Value.Value; } 145 149 set { CreateSolutionParameter.Value.Value = value; } 150 } 151 152 public bool StoreRuns { 153 get { return StoreRunsParameter.Value.Value; } 154 set { StoreRunsParameter.Value.Value = value; } 146 155 } 147 156 … … 178 187 var regressionAlgs = new ItemSet<IAlgorithm>(new IAlgorithm[] { 179 188 new RandomForestRegression(), 180 sgp, 189 sgp, 181 190 mctsSymbReg 182 191 }); … … 206 215 "Flag that indicates if a solution should be produced at the end of the run", new BoolValue(true))); 207 216 Parameters[CreateSolutionParameterName].Hidden = true; 217 Parameters.Add(new FixedValueParameter<BoolValue>(StoreRunsParameterName, 218 "Flag that indicates if the results of the individual runs should be stored for detailed analysis", new BoolValue(false))); 219 Parameters[StoreRunsParameterName].Hidden = true; 208 220 } 209 221 … … 218 230 219 231 var table = new DataTable("Qualities"); 220 table.Rows.Add(new DataRow(" Loss(train)"));221 table.Rows.Add(new DataRow(" Loss(test)"));232 table.Rows.Add(new DataRow("R² (train)")); 233 table.Rows.Add(new DataRow("R² (test)")); 222 234 Results.Add(new Result("Qualities", table)); 223 235 var curLoss = new DoubleValue(); 224 236 var curTestLoss = new DoubleValue(); 225 Results.Add(new Result(" Loss(train)", curLoss));226 Results.Add(new Result(" Loss(test)", curTestLoss));237 Results.Add(new Result("R² (train)", curLoss)); 238 Results.Add(new Result("R² (test)", curTestLoss)); 227 239 var runCollection = new RunCollection(); 228 Results.Add(new Result("Runs", runCollection)); 240 if (StoreRuns) 241 Results.Add(new Result("Runs", runCollection)); 229 242 230 243 // init 231 244 var problemData = Problem.ProblemData; 232 var targetVarName = Problem.ProblemData.TargetVariable;245 var targetVarName = problemData.TargetVariable; 233 246 var activeVariables = problemData.AllowedInputVariables.Concat(new string[] { problemData.TargetVariable }); 234 247 var modifiableDataset = new ModifiableDataset( … … 303 316 } 304 317 305 runCollection.Add(run); 306 table.Rows["Loss (train)"].Values.Add(curLoss.Value); 307 table.Rows["Loss (test)"].Values.Add(curTestLoss.Value); 318 if (StoreRuns) 319 runCollection.Add(run); 320 table.Rows["R² (train)"].Values.Add(curLoss.Value); 321 table.Rows["R² (test)"].Values.Add(curTestLoss.Value); 308 322 iterations.Value = i + 1; 309 323 } … … 408 422 model = null; 409 423 using (var wh = new AutoResetEvent(false)) { 410 EventHandler<EventArgs<Exception>> handler = (sender, args) => wh.Set(); 424 Exception ex = null; 425 EventHandler<EventArgs<Exception>> handler = (sender, args) => { 426 ex = args.Value; 427 wh.Set(); 428 }; 411 429 EventHandler handler2 = (sender, args) => wh.Set(); 412 430 alg.ExceptionOccurred += handler; … … 417 435 wh.WaitOne(); 418 436 437 if (ex != null) throw new AggregateException(ex); 419 438 run = alg.Runs.Last(); 439 alg.Runs.Clear(); 420 440 var sols = alg.Results.Select(r => r.Value).OfType<IRegressionSolution>(); 421 441 if (!sols.Any()) return false;
Note: See TracChangeset
for help on using the changeset viewer.