Machine Learning with ML.Net
SAMBEET DAS
Technical Architect | Product Roadmap & Engineering | System Design | Full Stack Engineering | Artificial Intelligence | Cloud Migration
Machine Learning
Machine Learning is a process of finding patterns from the data and predicting the future out of it.
Example:
o Detecting credit card fraud.
o Determining whether a customer is likely to switch to the competitor.
If you compare with Real World:
How did you learn to read?
Identifying patterns of letters/alphabets. Recognizing those patterns when you see them again.
That what ML does with the data we provide.
Training Data
Prepared data use to create a Model is called Training Data.
Creating a model is called training a model.
Types of ML
Supervised Learning
o Value you want to Predict is in the training data. Target value is part of training data.
o Data is labeled.
Unsupervised Learning
o Value you want to Predict is not in the training data.
o Data is unlabeled.
Types of ML Problem
Regression
o Uses Supervised Learning.
o This is a type of problem where we need to predict the continuous-response value.
o Examples:
§ what is the price of house in a specific city?
§ what is the value of the stock?
§ how many total runs can be on board in a cricket game?
§ How many units of this product will we sell next month?
Classification
o Uses Supervised Learning.
o This is a type of problem where we predict the categorical response value where the data can be separated into specific “classes”.
o Examples:
§ this email is spam or not?
§ will it rain today or not?
§ is this picture a cat or not?
Clustering
o Uses Unsupervised Learning.
o This is a type of problem where we group similar things together.
o Bit similar to multi class classification but here we don’t provide the labels, the system understands from data itself and cluster the data.
§ given news articles, cluster into different types of news
§ given a set of tweets, cluster based on content of tweet
§ given a set of images, cluster them into different objects
Machine Learning is Achieved with the Following steps:
1. Obtain your Data set
2. Understand the Data set
3. Define the Data structure
4. Create a pipeline and Load Data
5. Transform the Data
6. Choose and Add a Learning Algorithm
7. Train the Model
8. Use the Model to make prediction
Example of a POC in ML.Net
ML.Net is the Microsoft’s technology for Machine Learning.
It is Open Source and Cross Platform.
Step 1:
We will start the Machine Learning with the famous Iris-data.
This is one of the best known data set to be found in the pattern recognition literature.
The data set contains 3 classes of 50 instances each, where each class refers to a type of iris plant.
Attribute Information:
o sepal length in cm
o sepal width in cm
o petal length in cm
o petal width in cm
o Class:
- Iris Setosa
- Iris Versicolour
- Iris Virginica
Before Adding the Data set to the solution, the actual ML.Net Solution needs to be created.
Take a .Net Core ‘Console APP’
After creating the project go to the build tab and change the Platform target to x64.
ML.Net supports the project targeted to x64 as platform.
Once the target is ready. Add the nugget for ML.Net
Add the Iris-data.txt to the solution
Step 2:
Define the input and output Data structure for the Machine Learning.
Step 3:
Create the Pipeline and load the data into it.
A machine learning pipeline is used to help automate machine learning workflows. They operate by enabling a sequence of data to be transformed and correlated together in a model that can be tested and evaluated to achieve an outcome.
Step 4:
Transform the Data
The main purpose of data transformation and feature extraction is to enhance the data in such a way that it increases the likelihood that the classification algorithm will be able to make meaningful predictions.
Step 5:
Choosing an Algorithm is the most important step in Machine Learning
Step 6:
Following function is used to train the Model.
Training a Model is called creating a trained Model to Predict the best output.
Step 7:
Model can be used to Predict the future.
Step 8:
Following is the Predicted flower type.