ML.NET Intro
ML.NET Introduction
ML.Net(Machine Learning .NET) is an open-source machine learning library provided by Microsoft.
It is also cross-platform & can run on Windows, Linux, macOS.
It is mainly developed for DotNet developers.
C# & F# can be used to develop ML.NET applications.
Below are the steps in machine learning.
1. Algorithm: For working with ML, we need to select an algorithm e.g. clustering, regression, anomaly detection, etc.
2. Train: It is a process in which input data is analyzed by the algorithm. The output of the algorithm is the "Trained Model". This data is used to learn the pattern. With this trained model, predictions are made based on input.
3. Evaluate: This will be performed once the training step is completed. The model builder uses the trained model to make predictions for input data.
4. Code: Once the Evaluation phase is completed, the model builder outputs a file & code that can be used to add a model to your application.
Pre-requisite
ML.NET Model Builder used to train & use your first ML model. It is shipped with Visual Studio 2019 16.6.1 or Later. As it is still a preview feature, you need to enable it explicitly.
Go to Tools > Options > Environment > Preview Features & check "Enable ML.NET Model Builder".
Also, make sure that the below workload is also installed.
In this article, we'll develop our first ML.NET app using a simple approach. We'll initially provide trained data that shows if an item was cheap or expensive based on the amount.
1. Open Visual Studio & create a C# Console App (.NET Core).
2. Now add a new machine learning module to it.
3. This will show the below wizard to create the final trained model. For this example, we'll select "Text Classification".
4. Next step is selecting train data. Make sure this train data contains more data so that the predicted output will be more accurate.
The input file contains 2 columns of amount & cost. The amount is treated as Features i.e input to the algorithm. Whereas costly is Label i.e. output expected by the algorithm. Select the correct columns as Label.
5. Now next step is to train the machine learning model. In this, we specify "Time To Train" the model. This much time is used by Model Builder to explore various models. For a larger dataset, this value will be larger. Click on the Start Training button. Once training is finished you can see the result in the Output screen.
6. Next step is Evaluate. in this we'll evaluate our generated model by providing some sample input. We'll enter some data & results will be predicted based on our model.
7. Next step is very simple. It automatically generates all the required codes.
And Output of the above code is :
In the next article, we'll learn about another approach to create a simple ML.NET application.
HAPPY LEARNING........
“Any fool can write code that a computer can understand. Good programmers write code that humans can understand.” – Martin Fowler
Comments
Post a Comment