/// <summary> /// Do the <c>SimpleNumlWorkflow</c> using a <c>LinearRegression</c> generator/model. /// </summary> /// <param name="simpleData">If true, uses a preset small sample data set; else generates a larger, pseudo-random one.</param> /// <param name="maxIterations"></param> /// <param name="learningRate"></param> /// <param name="lambda"></param> static void DoSimple_LinearRegression(bool simpleData = true, int maxIterations = 500, double learningRate = 0.01d, double lambda = 1) { SimpleNumlWorkflowImpl( getData: () => SampleData.GetTennisData(simpleData), getDescriptor: () => Descriptor.Create <Tennis>(), // This is where we choose the actual algorithm getGenerator: (descriptor) => { var generator = new numl.Supervised.Regression.LinearRegressionGenerator() { Descriptor = descriptor, MaxIterations = maxIterations, LearningRate = learningRate, Lambda = lambda }; return(generator); }, getToPredict: () => { return(new Tennis() { Outlook = Outlook.Rainy, Temperature = Temperature.Low, Windy = true }); }, getPredictionDesc: (t) => "Play: " + t.Play.ToString(), trainingPercentage: 0.8d, repeat: 10 ); }
/// <summary> /// Do the <see cref="SimpleNumlWorkflow" /> using a <c>LinearRegression</c> generator/model. /// </summary> static void DoSimple_LinearRegression(Outlook outlook = Outlook.Sunny, double tempF = 15.0d, bool windy = true, int maxIterations = 500, double learningRate = 0.01d, double lambda = 1, int repeat = 10) { SimpleNumlWorkflow.SimpleNumlWorkflowImpl( getData: () => SampleData_ComplexType.GetTennisData_ComplexType(predetermined: false), getDescriptor: () => Descriptor.Create<Tennis_Complex>(), // This is where we choose the actual algorithm getGenerator: (descriptor) => { var generator = new numl.Supervised.Regression.LinearRegressionGenerator() { Descriptor = descriptor, MaxIterations = maxIterations, LearningRate = learningRate, Lambda = lambda }; return generator; }, getToPredict: () => { return new Tennis_Complex() { WeatherConditions = new WeatherConditions() { Outlook = outlook, Temperature = tempF, Windy = windy, } }; }, getPredictionDesc: (t) => "Play: " + t.Play, trainingPercentage: 0.8d, repeat: repeat ); }