From the course: Machine Learning with ML.NET

ML.NET introduction - .NET Tutorial

From the course: Machine Learning with ML.NET

ML.NET introduction

- In this video, we will take a quick look at ML.NET. ML.NET is an open source and cross-platform machine learning framework. It has the following key highlights. It is built for .NET developers. So as a .NET developer you can use your existing C# and F# skills and use ML.NET in any .NET application. It allows custom machine learning models to be made easily with tools such as Model Builder or CLI and it uses automated machine learning as a way to increase the performance of the models that users give. The framework and the ecosystem is fairly extensible. So you can bring in other popular libraries, such as TensorFlow and other popular model formats such as Onyx. So you can build machine learning models for the variety of different scenarios. Lastly, the framework is trusted, privacy and proven at scale. That means that the framework runs locally within your app. So all the training happens within your app. And then the framework has been used heavily for the last 10 plus years, both internally at Microsoft and now externally by customers. So it's hardened quite a lot. Let's take a quick look at the ML.NET website and a "Hello World" tutorial for ML.NET. This is how you can learn more about ML.NET. It's a custom machine learning framework for .NET developers. And here, this piece of code is showing you how we can use your C# libraries to build a custom machine learning model. You can do the following scenarios with ML.NET. So you can build models for sentiment analysis, product recommendation, price prediction, image classification, sales forecasting and a lot more. And you can check out these samples that we have on GitHub to learn more about other scenarios possible with ML.NET. ML.NET also uses automated machine learning under the covers with tools like the Model Builder and the CLI which allows you to build custom machine learning models without any configuration required. So as a developer, you don't have to know the intrinsics of all machine learning models and settings and you can quickly build custom models using these tools. You can easily bring in the ecosystem for other scenarios, such as image classification, object detection, natural language processing or building models on sound and sort of audio-based data by using TensorFlow and other popular libraries from the ecosystem. And ML.NET performs really well. It has got high performance and accuracy. This was a performance paper which shows how ML.NET pipelines compared to scikit-learn and each tool. And you can read more using this link about the performance characteristics. So here are some of the customers using ML.NET today. So let's take a quick overview of getting started with the MachineLearning.NET in your .NET application. So what I have over here is a blazer application and you can think about this application as an e-commerce site, where customers can go and leave you reviews. In this case, I can come over here as a customer and I can say ML is hard, but as an e-commerce site owner, it's very hard for me to understand what was the sentiment of this customer. Was this customer happy or was this customer sad? Now as a web developer, I would like to use machine learning to build a custom model for doing sentiment analysis so I can better understand this customer behavior. So let's go back to Visual Studio and build this custom machine learning model. I can right click on my project and I have a new option saying, add machine learning. This option is available if you download the Model Builder tool for Visual Studio. If I launch this extension, I'm presented with an option of choosing a scenario. Now, as a developer, I'm more likely to understand what scenarios are possible with machine learning rather than the actual machine learning tasks. So in this case, since I want to build a model for sentiment analysis, I'm going to choose that template. The next step in the machine learning journey is around connecting to your data. And since most of the developers have the data in SQL, I can choose to either upload a flat file which is a CSV or TSV, or I can directly connect to SQL server where my application specific data is. So let's go ahead and quickly connect to SQL server. In this case, I'm going to connect to a SQL server instance, which is locally running on my box. I'm going to use Windows authentication and I'm going to load up my table of customer reviews which has all the reviews of the customer comments. I'm going to select the table column, table review, and I can get a quick overview of what my data looks like. So I have three columns and the appropriate sentiment and the actual sentiment text which was the common text that the user entered. In this case, I want to predict the sentiment of the particular text. So I would choose sentiment from this dropdown which is the output of the machine learning model which is, what column are you predicting? The next step in this process is around training the machine learning model. In this case, Model Builder uses automated machine learning which explores different models with various settings. And it's going to come back with the best model it found so far. The longer I trained for, the better model I'll get. In this case Model Builder chooses some defaults based on how large my data set was. So in this case, it looks like the training completed and I can evaluate this training process to see what was the accuracy of the models. In this case, I got SDCA logistic regression with an 81% accuracy, and this tool is telling me that it tried two other different models in this timeframe. The last step in this process is code. Since I'm running my web application, I can easily add code for how the model was trained and code to consume this model in my application. So when I hit add projects, it added these two projects to my solution. One is a project for how the model was trained and it actually has the training code. The other one is around how the model can be consumed in my blazer app. So I'm going to right click and add a reference to this generated class library. And then I'm going to go back to my blazer app and I'm going to consume this model in my application. So here, the uncommon thing is the code to consume the model and the predict function is a function I could call to predict the sentiment of a text. I'll go back to my razor view and I will include a view which is going to give me a happiness scale and it's going to give me emojis for a happy face or a sad face. And lastly, I'm going to call into this predict function which is going to pass in the text, the common text, and it's going to give me a sentiment back. So let's start this application again and see what was the impact of building a custom machine learning model. So if I now go to review screen, you will see that there are emojicons that appeared because of the changes of the view. And if I say ML is hard, now I can see what the sentiment of my customer is. And if I change it to ML is fun with ML.NET you can see it's about a 99% accuracy. So just to summarize very quickly, I started with an app which had no machine learning and I quickly launched Model Builder using right-click add machine learning which allowed me to build a custom model for doing sentiment analysis, which I was easily able to include in my application. And then I'm better able to understand customer sentiments on my e-commerce website. So this was a quick overview of how to get started with the ML.NET. What ML.NET also provides is, it's got a very strong momentum in the open source community. This is the URL for our GitHub location. We have 250K plus downloads, 1800 commits, 1500 PRs, like 100 plus people contributing on the open source repo. The framework is used both internally for the last five plus years at different products at Microsoft. It's also been used externally quite heavily. Here are a few case studies from customers using ML.NET in production. BRENMOR uses ML.NET to classify free-form comments from patient surveys. So they get a lot of surveys and they want to classify those surveys into different categories in their departments. So they've built a custom machine learning model for it. Evolution Software is using ML.NET to predict hazelnut moisture levels. The challenge that they have over here is hazelnut drying is a very complicated process and it takes a lot of manual labor to figure out what's the right humidity level for the hazelnuts to dry. So they've built a custom machine model which takes different inputs and then predicts the moisture content. They ended up building a website and a tablet app as well to figure out the hazelnut drying levels. In this video, we took a quick overview introduction to MachineLearning.NET. In the next video, we'll be looking at how to get started with ML.NET.

Contents