public static async Task <Dictionary <string, object> > chooseBestFastTreeRegressor() { double bestLoss = Double.MaxValue; Dictionary <string, object> bestVersion = new Dictionary <string, object>(); foreach (int numLeaves in numLeavesList) { foreach (double learningRates in learningRatesList) { foreach (int maxBins in maxBinsList) { Dictionary <string, object> kwargs = new Dictionary <string, object>() { { "numLeaves", numLeaves }, { "learningRates", learningRates }, { "maxBins", maxBins } }; var model = await Train("FastTreeRegressor", kwargs); double loss = Evaluate(model); WorldCupPrediction predictionForEngland = model.Predict(TestData.TestEngland); WorldCupPrediction predictionForSweden = model.Predict(TestData.TestSweden); if (loss < bestLoss) { Console.WriteLine($"Best fast tree regressor so far is: NumLeaves = {numLeaves}, LearningRates = {learningRates}, MaxBins = {maxBins}, with loss (RMS) {loss}"); Console.WriteLine($"-- Predicted result is: England VS Sweden = {predictionForEngland.HomeTeamGoals} : {predictionForSweden.HomeTeamGoals}"); bestLoss = loss; bestVersion["type"] = "FastTreeRegressor"; bestVersion["numLeaves"] = numLeaves; bestVersion["learningRates"] = learningRates; bestVersion["maxBins"] = maxBins; bestVersion["England"] = predictionForEngland.HomeTeamGoals; bestVersion["Sweden"] = predictionForSweden.HomeTeamGoals; bestVersion["loss"] = loss; } } } } return(bestVersion); }
public static async Task <Dictionary <string, object> > chooseBestStochasticDualCoordinateAscentRegressor() { double bestLoss = Double.MaxValue; Dictionary <string, object> bestVersion = new Dictionary <string, object>(); foreach (float biasLearningRate in biasLearningRateList) { foreach (float l1Threshold in l1ThresholdList) { foreach (float l2Const in l2ConstList) { Dictionary <string, object> kwargs = new Dictionary <string, object>() { { "biasLearningRate", biasLearningRate }, { "l1Threshold", l1Threshold }, { "l2Const", l2Const } }; var model = await Train("StochasticDualCoordinateAscentRegressor", kwargs); double loss = Evaluate(model); WorldCupPrediction predictionForEngland = model.Predict(TestData.TestEngland); WorldCupPrediction predictionForSweden = model.Predict(TestData.TestSweden); if (loss < bestLoss) { Console.WriteLine($"Best stochastic dual coordinate ascent regressor so far is: BiasLearningRate = {biasLearningRate}, L1Threshold = {l1Threshold}, L2Const = {l2Const}, with loss (RMS) {loss}"); Console.WriteLine($"-- Predicted result is: England VS Sweden = {predictionForEngland.HomeTeamGoals} : {predictionForSweden.HomeTeamGoals}"); bestLoss = loss; bestVersion["type"] = "StochasticDualCoordinateAscentRegressor"; bestVersion["biasLearningRate"] = biasLearningRate; bestVersion["l1Threshold"] = l1Threshold; bestVersion["l2Const"] = l2Const; bestVersion["England"] = predictionForEngland.HomeTeamGoals; bestVersion["Sweden"] = predictionForSweden.HomeTeamGoals; bestVersion["loss"] = loss; } } } } return(bestVersion); }