Introduction to Machine Learning; Why should you use ML.NET
Types of Machine Learning
One of the most important concepts that we have brought up in the training or learning process. This is a necessary step for every machine learning algorithm during which the algorithm uses the data to learn how to solve the task at hand. In practice, we usually have some collected data based on which we need to create our predictions, or classification, or any other processing. This data is called a training set.
As we were able to see based on behavior during the training and the nature of the training set, we have a few types of learning:
- Unsupervised learning – The training set contains only inputs. The network attempts to identify similar inputs and to put them into categories. This type of learning is biologically motivated but it is not suitable for all the problems.
- Supervised learning – The training set contains inputs and desired outputs. This way the network can check its calculated output the same as the desired output and take appropriate actions based on that. In this article, we focus on this type of learning since it is used the most in the industry.
- Reinforcement learning – The training set contains inputs, but the network is also provided with additional information during the training. What happens is that once the network calculates the output for one of the inputs, we provide information that indicates whether the result was right or wrong and possibly, the nature of the mistake that the network made. Sort of like the concept of reward and punishment for artificial neural networks. This concept is very interesting, but it is out of the scope of this book, so, in general, we will have only the first two types of training.
Architecture and High-Level Overview
Building an application with ML.NET consists of several steps:
- Loading Data – Raw data must be loaded into memory and for this IDataView is used.
- Creating a pipeline – The pipeline is composed of steps that either transform data or train a machine learning algorithm. ML.NET provides various transformational steps, like one-hot encoding and various machine learning algorithms.
- Training a machine learning model – Once the pipeline is created, the training can be started. This is done using the Fit() method that is supported in all algorithms.
- Evaluate – The model can be evaluated at any point and additional decisions can be made based on the evaluations.
- Save – Once trained, the model is saved into a file. In general, the complete application should be built in a way that one microservice trains and evaluates the machine learning model, and the other microservice utilizes it.
- Load – The machine learning model can be loaded and utilized for predictions.
Apart from the mentioned classes, there are several more components that we need to mention. The Estimator is the object we create during the creation of the pipeline. This model is not trained. The Transformer instance, on the other hand, is a trained model and it is also in charge of loading the model back into the memory.
Why should we use ML.NET?
In the end, let’s just see why should we consider ML.NET for our project. As it turned out ML.NET has really good performance. ML.NET trained a sentiment analysis model with 95% accuracy using a 9GB Amazon review data set. Other popular machine learning frameworks failed to process the dataset due to memory errors. Training on 10% of the data set, to let all the frameworks complete training, ML.NET demonstrated the highest speed and accuracy. The performance evaluation found similar results in other machine learning scenarios. Apart from that, ML.NET is easily extendable with different models from different technologies.
Extended with TensorFlow & more
ML.NET has been designed as an extensible platform so that you can consume other popular ML frameworks (TensorFlow, ONNX, Infer.NET, and more) and have access to even more machine learning scenarios, like image classification, object detection, and more.
Moreover, ML.NET is an open-source and cross-platform machine learning framework for .NET.
References:
