Changeset 13898 for trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GBM/GradientBoostingRegressionAlgorithm.cs
- Timestamp:
- 06/15/16 21:51:14 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GBM/GradientBoostingRegressionAlgorithm.cs
r13889 r13898 286 286 IRegressionModel model; 287 287 IRun run; 288 288 289 // try to find a model. The algorithm might fail to produce a model. In this case we just retry until the iterations are exhausted 289 if (TryExecute(alg, RegressionAlgorithmResult, out model, out run)) {290 if (TryExecute(alg, rand.Next(), RegressionAlgorithmResult, out model, out run)) { 290 291 int row = 0; 291 292 // update predictions for training and test … … 419 420 } 420 421 421 private static bool TryExecute(IAlgorithm alg, string regressionAlgorithmResultName, out IRegressionModel model, out IRun run) {422 private static bool TryExecute(IAlgorithm alg, int seed, string regressionAlgorithmResultName, out IRegressionModel model, out IRun run) { 422 423 model = null; 424 SetSeed(alg, seed); 423 425 using (var wh = new AutoResetEvent(false)) { 424 426 Exception ex = null; … … 464 466 return model != null; 465 467 } 468 469 private static void SetSeed(IAlgorithm alg, int seed) { 470 // no common interface for algs that use a PRNG -> use naming convention to set seed 471 var paramItem = alg as IParameterizedItem; 472 473 if (paramItem.Parameters.ContainsKey("SetSeedRandomly")) { 474 ((BoolValue)paramItem.Parameters["SetSeedRandomly"].ActualValue).Value = false; 475 ((IntValue)paramItem.Parameters["Seed"].ActualValue).Value = seed; 476 } else { 477 throw new ArgumentException("Base learner does not have a seed parameter (algorithm {0})", alg.Name); 478 } 479 480 } 466 481 } 467 482 }
Note: See TracChangeset
for help on using the changeset viewer.