In my last post, i covered the steps i have taken to setup the environment required for ML.NET to work. Recall that we need to load the data, prepare the data, train the model and lastly using the model. We are focusing on the training and getting the model today. There are 3 ways for us to get the model of ML.NET.
In this post, I will focus on using the CLI – command line interface to test and get us the best algorithm. The sample data i am using is from https://archive.ics.uci.edu/ml/machine-learning-databases/00331/sentiment%20labelled%20sentences.zip , more specifically – i am using the Yelp file. if you are not able to get it anymore, you may download from here https://www.limguohong.com/wp-content/uploads/2019/06/yelp_labelled.txt
First, we need to understand this data that we downloaded and what it meant. If you were to open up in excel or a text editor, you will notice that everyline is a text followed by a digit at the back. The digit is binary based – 1 or 0. You will further notice that those whose line are positive and labelled with a 1 as the digit and those whose line are negative are labelled with a 0 and there are 1000 lines of text(reviews).
Problem we are solving via machine learning
In this very specific tutorial post i am making here, we are attempting to train a model to understand if a review is positive OR negative and return the result accordingly. We are using yelp review to train up the model via AutoML CLI.
As you have probably noticed, we are attempting to predict if a new review is likely POSITIVE OR NEGATIVE and this is a binary way of classification and this sheds some light on which tasks should we use.
Which tasks should we use?
We understand that there are 7 tasks in ML.NET right now. Based on the problem we are solving, we will then need to choose which tasks (or sometimes i even call it, classification of problem) will it fall within.
For explanation on what tasks do what – please check the following link – https://docs.microsoft.com/en-us/dotnet/machine-learning/resources/tasks
Now that we understand what tasks are available, we will leave it to AutoML CLI to tell us which Trainer should we use. The concept of Trainer is
Trainer = Algorithm + Task.
In this very specific tutorial we are making here, as the problem is a binary based problem, the best classification to use would be Binary Classification.
Tutorial on Binary Classification – AutoML CLI ML.NET
mlnet auto-train --task binary-classification --dataset "yelp_labelled.txt" --label-column-name sentiment_label --max-exploration-time 20
*For explanation, please refer to the end of this post.
*You may also want to attempt to run the exploration time to be longer and see if they suggest other better algorithm. In my screenshot below, i used 20 seconds and 60 seconds and the result was different.
In my next post, i will share how to make sense of the generated file.
ML.NET Command breakdown
mlnet auto-train –task binary-classification –dataset “yelp_labelled.txt” –label-column-name sentiment_label –max-exploration-time 20
Notes about the command.
Recently, a friend of mine, Maxx and myself decided to embark on a quest to start learning ML.NET. It came to our attention that ML.NET is released on Preview in 2 April 2019 and subsequently on 3 May 2019 on Stable Release.
Being in a language that I am comfortable with, i decided to give it a try and see what capabilities are available and how we are able to build something.
Every the course of next few weeks, we are going to try
More information can be found on their site on
We are also going to follow the ML.NET tutorials released –
https://docs.microsoft.com/en-gb/dotnet/machine-learning/tutorials/ then attempt to run the sample –
We have ran through the Microsoft Docs detailing ML.NET and will be extracting the important points out in the next various posts i made.
ML.NET will give developers the power to add in machine learning capabilities to .NET applications. With this ability, developers are now able to make predictions using the data presented.
The general steps required
1. Load the data
2. Prepare the data
3. Train and test the model
4. Get predictions / Using the model
ML.NET presents various functions and methods to do them and in the course of next few weeks and posts, we will present them in our blogs.
As of date of posting, ML.NET has the following Tasks.
Microsoft releases new iterations of Microsoft Office suite every three years for desktop and Microsoft Office 365 is the subscription based cloud version of their Office software. Earlier in 2016, Microsoft released the 2016 edition of Office and some updates to Office 365 which added new features in Excel. Some very useful functions like the CONCAT and TEXTJOIN functions are added which make concatenating or joining text very easier with multiple cells or strings in your spreadsheet. These functions are only available in the latest Office 2016 desktop installation and Office 365 subscription. To show these new functions, here is the Excel CONCAT and TEXTJOIN function tutorial. I am breaking them into 2 different tutorials for ease of access.
The Excel TEXTJOIN function joins or combines text from multiple cells in your spreadsheet with each string separated by a delimiter. The delimiter can be a comma or space. If the delimiter is empty, the Excel TEXTJOIN function will concatenate the strings like in the previous tutorial. Here is how to use Excel TEXTJOIN function tutorial:
The format of the Excel TEXTJOIN function is:
TEXTJOIN(delimiter, ignore_empty, text1, text2, … , textN)
Now here is how we use the Excel TEXTJOIN function:
You can view more Office Excel Tutorials in the link too!
A quick note on Web.config file in the ASP.NET project. It is worth noting that the file is a XML File (read this for more info – https://msdn.microsoft.com/en-us/library/ff400235.aspx )
One issue that hindered my process earlier was that the content in the value has special character it in, particularly, one of my SQL server’s password has a special character in it.
I would have to go and replace them accordingly. For instance, my password is <Password1& (note that < and ” is inclusive), i would have to change it to
You can refer to the list here – https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references
Recently I have a few enquries asking me to send them a summary of the tutorials that i have done up and posted on my site.
Just in case any of you are finding that. You can find it here.
or you can click on the “Tutorials” tab on the navigation bar.