mdabros / SharpLearning

Machine learning for C# .Net
MIT License
380 stars 83 forks source link

Add support for enabling/disabling messages from learners during training. #60

Open mdabros opened 6 years ago

mdabros commented 6 years ago

Currently, some of the learners in SharpLearning will output information during the training period. This includes the early stopping with gradient boost and neural networks. It should be possible to enable and disable these messages, and preferably, also possible to choose where the messages should be outputted. For instance to Console, Trace, or alternatively a log file.

This could be made by adding an Action to receive the message. This should probably be part of a separate interface, for learners supporting this. Something like:

public interface ILogger
{
   public Action<string> Log { get; set }
}

The learners would then add the message to the log. Likewise, other algorithms like the optimizers could also implement this interface.

ZenBoer commented 5 years ago

We have a running ML solution, but I'm considering replacing the Neural Net bits with SharpLearning. This is one of the first things I will add since the progress given through to the user is important. I would suggest added an overload to the Learn methods to take a progress Action. Inside the learning process, just check if Progress obj is not null. Form should be Func<double,string,bool> double = percentage completed, string is some message, bool indicates if learning process should stop. e.g. timelimit of 10 minutes has been reached or user cancels operation.