{"id":12567,"date":"2019-05-06T11:30:36","date_gmt":"2019-05-06T18:30:36","guid":{"rendered":"http:\/\/devblogs.microsoft.com\/cesardelatorre\/?p=12567"},"modified":"2019-05-06T12:50:58","modified_gmt":"2019-05-06T19:50:58","slug":"what-is-ml-net-1-0-machine-learning-for-net","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/what-is-ml-net-1-0-machine-learning-for-net\/","title":{"rendered":"What is ML.NET 1.0 &#8211; Machine Learning for .NET"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/github.com\/CESARDELATORRE\/MLNET-Posts\/raw\/master\/Posts\/002-What-is-MLNET-1.0\/MLNET-Blog-Post-images\/mldotnet.png\" alt=\"alt text\" title=\"ML.NET logo\" style=\"max-width:100%;\"><\/p>\n<p>Today, coinciding with \/\/BUILD 2019\/ conference, we\u2019re thrilled by launching <a href=\"http:\/\/dot.net\/ml\" rel=\"nofollow\">ML.NET<\/a> 1.0 release!<\/p>\n<p>You can read the <a href=\"https:\/\/aka.ms\/mlnet1-announcement-blog-post\" rel=\"nofollow\">official ML.NET 1.0 release announcement Blog Post here<\/a> and get started at the <a href=\"https:\/\/dotnet.microsoft.com\/apps\/machinelearning-ai\/ml-dotnet\" rel=\"nofollow\">ML.NET  site here<\/a>.<\/p>\n<p>In this blog post I&#8217;m providing quite a few additional technical details along with my personal vision that you might find interesting, though.<\/p>\n<p>This is the first main milestone of a great journey in the open that started on <a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/introducing-ml-net-cross-platform-proven-and-open-source-machine-learning-framework\/\" rel=\"nofollow\">May 2018 when we released ML.NET 0.1 as open source<\/a>. Since then we&#8217;ve been releasing monthly, 12 preview releases plus this final 1.0 release, as shown in the roadmap below:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/github.com\/CESARDELATORRE\/MLNET-Posts\/raw\/master\/Posts\/002-What-is-MLNET-1.0\/MLNET-Blog-Post-images\/all-mlnet-versions-till-v1.png\" alt=\"alt text\" title=\"ML.NET past roadmap\" style=\"max-width:100%;\"><\/p>\n<p>The diagram above shows the the development in the open of ML.NET, however, as explained below, ML.NET has been internally used by Microsoft for quite a few years and used by other Microsoft products such as <em>Bing Ads, Office, Windows, Azure<\/em>, etc.<\/p>\n<h2><a id=\"user-content-what-is-mlnet\" class=\"anchor\" aria-hidden=\"true\" href=\"#what-is-mlnet\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"><\/path><\/svg><\/a>What is ML.NET?<\/h2>\n<p><a href=\"http:\/\/dot.net\/ml\" rel=\"nofollow\">ML.NET<\/a> is an <strong>open-source<\/strong> and <strong>cross-platform<\/strong> machine learning framework (Windows, Linux, macOS), created by Microsoft, <strong>for .NET developers<\/strong>.<\/p>\n<p>Using <a href=\"http:\/\/dot.net\/ml\" rel=\"nofollow\">ML.NET<\/a>, developers can leverage their existing tools and skillsets to develop and infuse custom AI into their applications by creating <strong>custom machine learning models<\/strong> for common scenarios like <em>Sentiment Analysis, Product Recommendation, Sales forecasts, Price Predictions, Customers Segmentation, Image Classification<\/em> and many more!.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/github.com\/CESARDELATORRE\/MLNET-Posts\/raw\/master\/Posts\/002-What-is-MLNET-1.0\/MLNET-Blog-Post-images\/value-props-mlnet.png\" alt=\"alt text\" title=\"ML.NET Value proposition\" style=\"max-width:100%;\"><\/p>\n<h2><a id=\"user-content-mlnet-10-architecture\" class=\"anchor\" aria-hidden=\"true\" href=\"#mlnet-10-architecture\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"><\/path><\/svg><\/a>ML.NET 1.0 Architecture<\/h2>\n<p>Below you can see a high level architecture diagram and after it you can read additional details about what&#8217;s supported, what&#8217;s not and other architecture explanations.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/github.com\/CESARDELATORRE\/MLNET-Posts\/raw\/master\/Posts\/002-What-is-MLNET-1.0\/MLNET-Blog-Post-images\/architecture-mlnet-1.0.png\" alt=\"ML.NET 1.0 Architecture diagram\" title=\"ML.NET Value proposition\" style=\"max-width:100%;\"><\/p>\n<h3><a id=\"user-content-supported-in-mlnet-10\" class=\"anchor\" aria-hidden=\"true\" href=\"#supported-in-mlnet-10\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"><\/path><\/svg><\/a>Supported in ML.NET 1.0<\/h3>\n<p><strong>Operating system and framework support:<\/strong><\/p>\n<ul>\n<li>\n<p>Windows, Linux, and macOS using .NET Core<\/p>\n<\/li>\n<li>\n<p>Windows using .NET Framework.<\/p>\n<\/li>\n<\/ul>\n<p><strong>Hardware \/ Processor architecture support<\/strong><\/p>\n<ul>\n<li>x64 bit is supported on all platforms.<\/li>\n<li>x86 is supported on Windows, except for TensorFlow, LightGBM, and ONNX related functionality.<\/li>\n<\/ul>\n<p><strong>.NET versions support<\/strong><\/p>\n<ul>\n<li>\n<p>.NET Core 2.1 or later is supported.<\/p>\n<\/li>\n<li>\n<p>.NET Framework 4.6.1 or later is supported, but 4.7.2 or later is recommended.<\/p>\n<\/li>\n<li>\n<p>.NET Stardard 2.x (best choice for class libraries).<\/p>\n<\/li>\n<\/ul>\n<h3><a id=\"user-content-not-supported-in-mlnet-10\" class=\"anchor\" aria-hidden=\"true\" href=\"#not-supported-in-mlnet-10\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"><\/path><\/svg><\/a>Not supported in ML.NET 1.0<\/h3>\n<p>ML.NET 1.0 is currently not supported on ARM processor architecture, impacting Xamarin apps (iOS, Android) and ARM-based IoT devices, although you can always run the ML models in the &#8216;server side&#8217;. UWP and Unity are also still not supported. However, in upcoming releases the roadmap plan is to support all these technologies, as well.<\/p>\n<p>ML.NET 1.0 can work on UWP apps and Unity after some hacking, but they are still not officially supported, yet.<\/p>\n<h2><a id=\"user-content-end-user-application-architecture\" class=\"anchor\" aria-hidden=\"true\" href=\"#end-user-application-architecture\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"><\/path><\/svg><\/a>End-user Application Architecture<\/h2>\n<p>ML.NET 1.0 is composed by a <a href=\"https:\/\/www.nuget.org\/packages?q=Microsoft.ML\" rel=\"nofollow\">set of NuGet packages<\/a>. Therefore you can use it  within your own .NET application wherever it is running (on-premises, cloud, client, server, etc.).<\/p>\n<p>You can run ML.NET 1.0 NuGet packages as part of the following common  application workload types:<\/p>\n<ul>\n<li>ASP.NET Core web apps &amp; WebAPI services<\/li>\n<li>ASP.NET web apps &amp; WebAPI services<\/li>\n<li>Azure Functions<\/li>\n<li>Any other Azure app model app (server side)<\/li>\n<li>.NET WPF desktop app<\/li>\n<li>.NET WinForms desktop app<\/li>\n<li>.NET Core console app (usually for ML model training)<\/li>\n<li>.NET Framework console app (usually for ML model training)<\/li>\n<\/ul>\n<p>Those are the most common application types, but there are additional app types you can run ML.NET 1.0 on as long as they are supported on the mentioned architecture processors and OS above.<\/p>\n<p>Here&#8217;s a high-level diagram with multiple possible application architectures when running ML.NET models.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/github.com\/CESARDELATORRE\/MLNET-Posts\/raw\/master\/Posts\/002-What-is-MLNET-1.0\/MLNET-Blog-Post-images\/application-architecture-mlnet.png\" alt=\"Application Architecture diagram\" title=\"ML.NET Value proposition\" style=\"max-width:100%;\"><\/p>\n<p>(*) Note that even when with Blazor you can run ML.NET on the browser (because with Blazor client you can run .NET assemblies and code on the browser), if the browser running the web app is on a mobile device (ARM processor: iOS\/Android), the ML.NET model won&#8217;t run. ML.NET 1.0 will run only if the browser runs on x64\/x86 devices.<\/p>\n<p>There might be additional architecture possibilities, but those are probably the most common.<\/p>\n<h2><a id=\"user-content-why-would-you-want-to-use-mlnet\" class=\"anchor\" aria-hidden=\"true\" href=\"#why-would-you-want-to-use-mlnet\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"><\/path><\/svg><\/a>Why would you want to use ML.NET?<\/h2>\n<h2><a id=\"user-content-create-custom-and-specialized-ml-models-for-your-business-scenarios-and-data\" class=\"anchor\" aria-hidden=\"true\" href=\"#create-custom-and-specialized-ml-models-for-your-business-scenarios-and-data\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"><\/path><\/svg><\/a>Create custom and specialized ML models for your business scenarios and data<\/h2>\n<p>In the general AI ecosystem you have on one hand <em>&#8216;Pre-built AI&#8217;<\/em> services such as <em>Azure Cognitive Services<\/em> which in many cases might be enough for your AI scenarios.<\/p>\n<p>However, on the other hand there are many other cases where you need to create your own custom ML model especially made for your business problems and trained with your own data. This second case is known as <em>&#8216;Custom AI&#8217;<\/em>. This is when a framework like ML.NET should be used.<\/p>\n<p>ML.NET is a &#8216;code-first&#8217; machine learning framework that allows you to create your own ML models by training them with your own data while taking advantage of a great flexibility and customization by being able to deep dive and select the ML algorithms and approaches you consider better for your business.<\/p>\n<h2><a id=\"user-content-runs-as-native-net-execution-for-model-scoring-and-training\" class=\"anchor\" aria-hidden=\"true\" href=\"#runs-as-native-net-execution-for-model-scoring-and-training\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"><\/path><\/svg><\/a>Runs as native .NET execution (For model scoring and training)<\/h2>\n<p>If your end-user applications are based on .NET, the advantage of ML.NET compared to other ML frameworks based on Python or other languages is that you can natively run your ML models on .NET apps. In most cases that means better performance when running predictions and a much lower cost of operationalization when deploying your ML models in production apps for end-users based on .NET such as ASP.NET, ASP.NET Core, desktop apps, etc.<\/p>\n<h2><a id=\"user-content-familiar-net-skills\" class=\"anchor\" aria-hidden=\"true\" href=\"#familiar-net-skills\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"><\/path><\/svg><\/a>Familiar .NET skills<\/h2>\n<p>If your development skills are fundamentally based on .NET (C#, F#, VB), you will be able to create machine learning models without needing to learn other languages.<\/p>\n<h2><a id=\"user-content-machine-learning-scenarios-you-can-create-with-mlnet\" class=\"anchor\" aria-hidden=\"true\" href=\"#machine-learning-scenarios-you-can-create-with-mlnet\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"><\/path><\/svg><\/a>Machine Learning Scenarios you can create with ML.NET<\/h2>\n<p>There are hundreds of ML scenarios you can implement with ML.NET. The following are only a few example scenarios you can implement:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/github.com\/CESARDELATORRE\/MLNET-Posts\/raw\/master\/Posts\/002-What-is-MLNET-1.0\/MLNET-Blog-Post-images\/Scenarios.png\" alt=\"alt text\" title=\"ML.NET Scenarios\" style=\"max-width:100%;\"><\/p>\n<p>All these scenarios and many more can be mapped to the following <strong>ML Tasks<\/strong> you can implement with ML.NET for your models:<\/p>\n<ul>\n<li>Binary Classification<\/li>\n<li>Multi-Class Classification<\/li>\n<li>Regression<\/li>\n<li>Recommendation<\/li>\n<li>Anomaly Detection and Time Series<\/li>\n<li>Clustering<\/li>\n<li>Ranking<\/li>\n<li>Computer Vision in Deep Learning (Integration with TensorFlow and ONNX models)<\/li>\n<\/ul>\n<h2><a id=\"user-content-production-ready\" class=\"anchor\" aria-hidden=\"true\" href=\"#production-ready\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"><\/path><\/svg><\/a>Production ready<\/h2>\n<p>ML.NET was originally developed by Microsoft as an internal framework for .NET and evolved over the last decade; it is a production-proven framework because it is currently used across many products in Microsoft like <strong>Windows, Bing, Azure, Office, PowerBI<\/strong> and many more.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/github.com\/CESARDELATORRE\/MLNET-Posts\/raw\/master\/Posts\/002-What-is-MLNET-1.0\/MLNET-Blog-Post-images\/mlnet-is-proven.png\" alt=\"alt text\" title=\"ML.NET is battle proven\" style=\"max-width:100%;\"><\/p>\n<p>In early 2018 Microsoft decided to make it available as a framework for customers. Since May 2018 when releasing its first preview release, we&#8217;ve been polishing a new API easier to use by developers, while creating documentation and samples. However, the main core engine and proven ML algorithms are mostly the same battle-proved artifacts used by Microsoft teams for quite a few years.<\/p>\n<p>You can also check out additional showcased customers who are currently using it <a href=\"https:\/\/dotnet.microsoft.com\/apps\/machinelearning-ai\/ml-dotnet\/customers\" rel=\"nofollow\">here<\/a><\/p>\n<h2><a id=\"user-content-main-components-in-mlnet\" class=\"anchor\" aria-hidden=\"true\" href=\"#main-components-in-mlnet\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"><\/path><\/svg><\/a>Main components in ML.NET<\/h2>\n<p>ML.NET is being launched as a part of the .NET Foundation and the repo today contains the .NET API(s) for both model training and consumption, along with a variety of transforms and learners required for many popular ML tasks like regression and classification, as shown in the following diagram.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/github.com\/CESARDELATORRE\/MLNET-Posts\/raw\/master\/Posts\/002-What-is-MLNET-1.0\/MLNET-Blog-Post-images\/mlnet-components.png\" alt=\"alt text\" title=\"ML.NET Components\" style=\"max-width:100%;\"><\/p>\n<p>ML.NET is aimed at providing the E2E workflow for infusing ML into .NET apps across pre-processing, feature engineering, modeling, evaluation, and operationalization.<\/p>\n<p>ML.NET comes with support for the types and runtime needed for all aspects of machine learning, including core data types, extensible pipelines, data structures for tabular data, AutoML (explained below in further details), tooling support, and more.<\/p>\n<h2><a id=\"user-content-creatingtraining-and-running-mlnet-models\" class=\"anchor\" aria-hidden=\"true\" href=\"#creatingtraining-and-running-mlnet-models\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"><\/path><\/svg><\/a>Creating\/training and running ML.NET models<\/h2>\n<p>The high level machine learning process using ML.NET can be simplified as the following diagram illustrates:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/github.com\/CESARDELATORRE\/MLNET-Posts\/raw\/master\/Posts\/002-What-is-MLNET-1.0\/MLNET-Blog-Post-images\/ml-process-2.png\" alt=\"alt text\" title=\"ML process\" style=\"max-width:100%;\"><\/p>\n<p>You can see how there are two very differentiated workflows:<\/p>\n<ul>\n<li>\n<p>Cyclic workflow to create\/train\/evaluate the ML model based on historic data. When you are happy with the model&#8217;s quality, you save it as a serialized ML.NET model file (.zip format).<\/p>\n<\/li>\n<li>\n<p>Run\/deploy your custom trained ML model in your end-user application to perform predictions.<\/p>\n<\/li>\n<\/ul>\n<p>The ML.NET NuGet packages runs on all those processes, as shown in the diagram. Since ML.NET is a framework, you can run it on the environment and application type you want.<\/p>\n<h2><a id=\"user-content-getting-started-installation\" class=\"anchor\" aria-hidden=\"true\" href=\"#getting-started-installation\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"><\/path><\/svg><\/a>Getting Started Installation<\/h2>\n<p>You can follow the official guided <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/machine-learning\/tutorials\/sentiment-analysis\">&#8216;ML.NET Getting started Tutorial&#8217;<\/a>. However, below I&#8217;m highlighting the main steps to take into account and most important pieces of C# code to use.<\/p>\n<p>To get started with ML.NET, install the ML.NET NuGet from the CLI using:<\/p>\n<pre class=\"lang:default decode:true\">\r\ndotnet add package Microsoft.ML\r\n<\/pre>\n<p>Or from package manager:<\/p>\n<pre class=\"lang:default decode:true\">\r\nInstall-Package Microsoft.ML\r\n<\/pre>\n<h2><a id=\"user-content-train-your-own-ml-model\" class=\"anchor\" aria-hidden=\"true\" href=\"#train-your-own-ml-model\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"><\/path><\/svg><\/a>Train your own ML model<\/h2>\n<p>Here is a simplified code snippet to train a model for **sentiment analysis classification scenario** (which is a binary-classification ML task) that you can run for instance on a console app (full sample can be found <a href=\"https:\/\/github.com\/dotnet\/machinelearning-samples\/tree\/master\/samples\/csharp\/getting-started\/BinaryClassification_SentimentAnalysis\">here<\/a>).<\/p>\n<pre class=\"lang:default decode:true\">\r\n\/\/ Create MLContext\r\nMLContext mlContext = new MLContext();\r\n\r\n\/\/ Load training data\r\nIDataView trainData = mlContext.Data.LoadFromTextFile<SentimentIssue>(DataPath);\r\n\r\n\/\/ Data transformations needed for the machine learning algorithms\r\nvar dataProcessPipeline = mlContext.Transforms.Text.FeaturizeText(outputColumnName:\"Features\", inputColumnName:\"Text\");\r\n\r\n\/\/ Set the training algorithm\r\nvar trainer = mlContext.BinaryClassification.Trainers.FastTree(labelColumnName:\"Label\", featureColumnName:\"Features\");\r\nvar trainingPipeline = dataProcessPipeline.Append(trainer);\r\n\r\n\/\/ Train the model fitting to the training DataSet\r\nITransformer trainedModel = trainingPipeline.Fit(testTrainSplit.TrainSet);\r\n<\/pre>\n<p>Let\u2019s go through this in a bit more detail. We create an MLContext needed for all ML operations when loading data, transforming data and applying the algorithm. These are the steps required to train a machine learning model.<\/p>\n<p>The second step is to load data with <code>LoadFromTextFile()<\/code> which loads the data from our training file into a IDataView structure. We then apply a FeaturizeText() to convert the &#8216;Text&#8217; column into a numeric vector called &#8216;Features&#8217; which can be used by the machine learning algorithm (as algorithms only work with number-based structures). This is our preprocessing\/featurization step.<\/p>\n<p>FastTree is the trainer (algorithm) we use in this pipeline. Like the featurization step, trying out different trainers available in ML.NET and changing their parameters may enable identifying better results.<\/p>\n<p>Finally, trainingPipeline.Fit(testTrainSplit.TrainSet) trains the model with the training dataset. The whole process\/experiment is not executed until this train\/fit method happens.<\/p>\n<h2><a id=\"user-content-consuming-mlnet-models-in-your-end-user-apps\" class=\"anchor\" aria-hidden=\"true\" href=\"#consuming-mlnet-models-in-your-end-user-apps\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"><\/path><\/svg><\/a>Consuming ML.NET models in your end-user apps<\/h2>\n<p>Consuming a model to run predictions is very straightforward and can be done in a couple of lines:<\/p>\n<pre class=\"lang:default decode:true\">\r\n\/\/ Create prediction engine related to the loaded trained model\r\nvar predEngine= trainedModel.CreatePredictionEngine<SentimentIssue, SentimentPrediction>(mlContext);\r\n\r\n\/\/Get sample data to make a prediction with\r\nSentimentIssue sampleComment = new SentimentIssue { Text = \"This is a very rude movie!\" };\r\n\r\n\/\/ Predict\r\nvar resultprediction = predEngine.Predict(sampleComment);\r\n<\/pre>\n<p>From the resultPrediction object you can get the actual <code>Prediction<\/code> (in this case <code>PositiveSentiment = true\/false<\/code>) and the <code>Probability<\/code>.<\/p>\n<p><strong>Important:<\/strong> If you want to run your model on a <strong>scalable<\/strong> and <strong>multi-threaded application<\/strong> such as an <strong>ASP.NET Core web app or WebAPI service<\/strong>, please use the recommended approach explained in the section below named <strong>&#8216;Running your ML models on ASP.NET Core web apps and services&#8217;.<\/strong><\/p>\n<h2><a id=\"user-content-mlnet-tools-and-extensions-in-preview\" class=\"anchor\" aria-hidden=\"true\" href=\"#mlnet-tools-and-extensions-in-preview\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"><\/path><\/svg><\/a>ML.NET Tools and Extensions (in Preview)<\/h2>\n<h2><a id=\"user-content-automatically-createtrain-models-with-mlnet-automl\" class=\"anchor\" aria-hidden=\"true\" href=\"#automatically-createtrain-models-with-mlnet-automl\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"><\/path><\/svg><\/a>Automatically create\/train models with ML.NET AutoML<\/h2>\n<p>Machine Learning in general and any ML framework in particular can be challenging for .NET developers who are not data scientists because of the needed skills about ML algorithms and special data transformations and configuration settings like algorythm&#8217;s hyperparameters.<\/p>\n<p>ML.NET AutoML eliminates the task of selecting different algorithms, hyperparameters. AutoML will intelligently generate many combinations of algorithms and hyperparameters. It means as a user, you do not need to know or understand what each of these algorithms are and which one you need to use. Simply bring your dataset and let AutoML build a Machine Learning model for you.<\/p>\n<p>You can use AutoML in ML.NET through three different alternatives. API, CLI and UI\/VisualStudio, as shown in the diagram below:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/github.com\/CESARDELATORRE\/MLNET-Posts\/raw\/master\/Posts\/002-What-is-MLNET-1.0\/MLNET-Blog-Post-images\/using-automl.png\" alt=\"alt text\" title=\"AutoML options\" style=\"max-width:100%;\"><\/p>\n<p>In most developers, the most common and easier way to get started is to use either the CLI or Visual Studio. However, for scenarios where you need to generate an ML model &#8216;on the fly&#8217; (such as from a product), AutoML API would be the right choice.<\/p>\n<h2><a id=\"user-content-mlnet-cli-command-line-interface---preview\" class=\"anchor\" aria-hidden=\"true\" href=\"#mlnet-cli-command-line-interface---preview\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"><\/path><\/svg><\/a>ML.NET CLI (Command-Line Interface) &#8211; Preview<\/h2>\n<p>The ML.NET CLI (command-line interface) is a tool you run on any command-prompt (Windows, Mac or Linux) for generating good quality ML.NET models and source code based on training datasets you provide. It is internally using ML.NET AutoML, so you can create good quality models and generate related C# code directly from the command-line.<\/p>\n<p>The ML.NET CLI is part of ML.NET and its main purpose is to &#8220;democratize&#8221; ML.NET for .NET developers when learning ML.NET so it is very simple to get the right C# code to create a good quality ML.NET model and the sample C# code to run\/score the model. In addition, you can generate a good quality model file (.zip file) without coding, so it also improves your productivity even if you already know ML.NET.<\/p>\n<p>Currently, the ML Tasks supported by the CLI are the same than with AutoML:<\/p>\n<ul>\n<li>Regression<\/li>\n<li>Binary Classification<\/li>\n<li>Multi-class Classification<\/li>\n<\/ul>\n<p>Other ML Tasks in the future such as recommendation, anomaly detection, clustering, etc. will be supported.<\/p>\n<p>Here&#8217;s how easy is to use the ML.NET CLI to automatically generate an ML model plus its related C# code (to run it and the C# code that was used to train it).<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/github.com\/CESARDELATORRE\/MLNET-Posts\/raw\/master\/Posts\/002-What-is-MLNET-1.0\/MLNET-Blog-Post-images\/mlnet-CLI-recorded.gif\" alt=\"alt text\" title=\"CLI recorded video\" style=\"max-width:100%;\"><\/p>\n<p>After that CLI execution, you get the serialized ML.NET model in a .zip file plus the C# code:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/github.com\/CESARDELATORRE\/MLNET-Posts\/raw\/master\/Posts\/002-What-is-MLNET-1.0\/MLNET-Blog-Post-images\/CLI-code-projects.png\" alt=\"alt text\" title=\"CLI generated C# code\" style=\"max-width:100%;\"><\/p>\n<p>In that generated C# code you get the model consumption code that you can directly use in your end-user application to make predictions. That code is very similar to the three lines explained above for running\/scoring a model, but in this case the code is running your own generated ML model.<\/p>\n<p>In addition and for more advanced leearning, you also get the C# training code that was used to train the model by the CLI tool so you can research that code, as well.<\/p>\n<h3><a id=\"user-content-see-also\" class=\"anchor\" aria-hidden=\"true\" href=\"#see-also\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"><\/path><\/svg><\/a>See also<\/h3>\n<p>Explore this complete <a href=\"https:\/\/github.com\/dotnet\/machinelearning-samples\/tree\/master\/samples\/CLI\/BinaryClassification_CLI\">sample using the CLI here<\/a>.<\/p>\n<h2><a id=\"user-content-mlnet-model-builder-for-visual-studio---preview\" class=\"anchor\" aria-hidden=\"true\" href=\"#mlnet-model-builder-for-visual-studio---preview\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"><\/path><\/svg><\/a>ML.NET Model Builder for Visual Studio &#8211; Preview<\/h2>\n<p><strong>ML.NET Model Builder for Visual Studio<\/strong> is currently an .VSIX Visual Studio extension you can <a href=\"https:\/\/aka.ms\/mlnettemplates\" rel=\"nofollow\">install from here<\/a><\/p>\n<p>Its initial functionality is pretty similar than the functionality provided by the CLI but guided on a visual UI from Visual Studio. Therefore it allows you to automatically create\/train a custom model but starting from your end-user application solution in Visual Studio, as in the following screenshot series:<\/p>\n<h2><a id=\"user-content-using-mlnet-builder-in-visual-studio\" class=\"anchor\" aria-hidden=\"true\" href=\"#using-mlnet-builder-in-visual-studio\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"><\/path><\/svg><\/a>Using ML.NET Builder in Visual Studio<\/h2>\n<p><img decoding=\"async\" src=\"https:\/\/github.com\/CESARDELATORRE\/MLNET-Posts\/raw\/master\/Posts\/002-What-is-MLNET-1.0\/MLNET-Blog-Post-images\/vs-model-builder-multiple.png\" alt=\"alt text\" style=\"max-width:100%;\"><\/p>\n<p>For further information on <strong>ML.NET Model Builder for Visual Studio<\/strong> usage go <a href=\"https:\/\/aka.ms\/mlnettemplates\" rel=\"nofollow\">here<\/a><\/p>\n<h2><a id=\"user-content-automl-api---preview\" class=\"anchor\" aria-hidden=\"true\" href=\"#automl-api---preview\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"><\/path><\/svg><\/a>AutoML API &#8211; Preview<\/h2>\n<p>ML.NET AutoML API is basically a set of libraries packaged as a NuGet package you can use from your .NET code.<\/p>\n<p>Currently, the ML Tasks supported by AutoML are:<\/p>\n<ul>\n<li>Regression<\/li>\n<li>Binary Classification<\/li>\n<li>Multi-class Classification<\/li>\n<\/ul>\n<p>Here is a simplified code snippet to train a model with the AutoML API and predict with it afterwards.<\/p>\n<pre class=\"lang:default decode:true\">\r\n\r\nTextLoader textLoader = mlContext.Data.CreateTextLoader(textLoaderOptions);\r\nIDataView trainDataView = textLoader.Load(TrainDataPath);\r\n\r\n\/\/ Auto featurize, auto train and auto hyperparameter tune\r\nIEnumerable<RunDetails<BinaryClassificationMetrics>> runDetails = mlContext.Auto()\r\n                                                                    .CreateBinaryClassificationExperiment(ExperimentTime)\r\n                                                                    .Execute(trainDataView);\r\n\r\nRunDetails<BinaryClassificationMetrics> best = runDetails.Best();\r\n\r\nITransformer trainedModel = best.Model;\r\n\r\n<\/pre>\n<p>In the previous code using AutoML you can observe that you don&#8217;t need to select any specific algorithm\/trainer for your desired ML task, not even need to specify any explicit data transformation. All that complexity is don for you by AutoML.<\/p>\n<p>You simply provide the data, specify the type of ML task experiment, and that&#8217;s all.<\/p>\n<p>Then, the prediction execution using the generated model would be the same code as when simply using ML.NET to run a model in the previous ML.NET sample.<\/p>\n<h3><a id=\"user-content-see-also-1\" class=\"anchor\" aria-hidden=\"true\" href=\"#see-also-1\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"><\/path><\/svg><\/a>See also<\/h3>\n<p>See a <a href=\"https:\/\/github.com\/dotnet\/machinelearning-samples\/tree\/master\/samples\/csharp\/getting-started\/BinaryClassification_AutoML\">sample using the AutoML API here<\/a>.<\/p>\n<h2><a id=\"user-content-running-your-models-on-aspnet-core-web-apps-and-services\" class=\"anchor\" aria-hidden=\"true\" href=\"#running-your-models-on-aspnet-core-web-apps-and-services\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"><\/path><\/svg><\/a>Running your ML models on ASP.NET Core web apps and services<\/h2>\n<p>When scaling out and running your models on multi-threaded applications, the way you should run your models for executing predictions should be implemented in a slightly different way so it is optimized for multi-threaded environments. The problem is explained in detail in this blog post I wrote:<\/p>\n<p><em>Blog Post: <a href=\"https:\/\/devblogs.microsoft.com\/cesardelatorre\/how-to-optimize-and-run-ml-net-models-on-scalable-asp-net-core-webapis-or-web-apps\/\" rel=\"nofollow\">How to optimize and run ML.NET models on scalable ASP.NET Core WebAPIs or web apps<\/a><\/em><\/p>\n<p>However, having to implement such a &#8216;plumbing infrastructure&#8217; explained in that blog post, based on a thread-safe object pool of Prediction Engines by yourself might significantly complicate your development.<\/p>\n<p>The good news is that we&#8217;ve also been working on this concern and we are providing a new &#8216;.NET Core Integration Package&#8217; in Preview that greatly simplifies the way you can run ML.NET models in scalable and multi-threaded apps or services (usually ASP.NET Core and any .NET Core app using dependecy injection).<\/p>\n<h2><a id=\"user-content-microsoftextensionsml-and-the-predictionenginepool\" class=\"anchor\" aria-hidden=\"true\" href=\"#microsoftextensionsml-and-the-predictionenginepool\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"><\/path><\/svg><\/a>Microsoft.Extensions.ML and the PredictionEnginePool<\/h2>\n<p>That mentioned &#8216;.NET Core Integration Package for ML.NET&#8217; (Preview) is currently named as Microsoft.Extensions.ML NuGet package.<\/p>\n<p>This library allows to run\/score ML.NET models very easily while getting high optimization for ASP.NET Core web apps, WebAPIs or even for any .NET Core process using Dependency Injection.<\/p>\n<p>You might be familiar when using comparable integration packages such as when using EF (Entity Framework) or SignalR. For instance, the following code-snippet shows how you register EF in the ASP.NET Core services:<\/p>\n<pre class=\"lang:default decode:true\">\r\nStartup.cs from your ASP.NET Core app\/service\r\n\r\npublic void ConfigureServices(IServiceCollection services)\r\n{\r\n   services.AddMvc();\r\n   \r\n    var connection = @\"<YOUR-DATABASE-CONNECTION-STRING>\";\r\n    services.AddDbContext<MyDbContext>\r\n        (options => options.UseSqlServer(connection));\r\n}\r\n<\/pre>\n<p>Then you would use the DbConext injected from any ASP.NET Controller or class.<\/p>\n<p>In a similar way, with this new .NET Core integration package for ML.NET you can register the Prediction Engine infrastructure like in the following code:<\/p>\n<pre class=\"lang:default decode:true\">\r\n\/\/Startup.cs from your ASP.NET Core app\/service\r\n\r\nusing Microsoft.Extensions.ML;\r\n\/\/... Other code\r\npublic void ConfigureServices(IServiceCollection services)\r\n{\r\n   services.AddMvc();\r\n   \/\/...\r\n   services.AddPredictionEnginePool<ModelInput, ModelOutput>()\r\n                    .FromFile(Configuration[\"MyModel.zip\"]);\r\n}\r\n<\/pre>\n<p>With this straightforward registration, you can now make predictions by using the Prediction Engine infrastructure injected in the constructors of your controllers or service classes, such as the following code:<\/p>\n<pre class=\"lang:default decode:true\">\r\nMyController.cs from your ASP.NET Core app\/service\r\n\r\n[Route(\"[controller]\")]\r\n[ApiController]\r\npublic class PredictionController : ControllerBase\r\n{\r\n   private PredictionEnginePool<ModelInput, ModelOutput> _predictionEnginePool;\r\n\r\n   \/\/The predictionEnginePool is injected through the constructor\r\n   public PredictionController(PredictionEnginePool<ModelInput, ModelOutput> predictionEnginePool)\r\n   {\r\n      _predictionEnginePool = predictionEnginePool;\r\n   }\r\n\r\n   [HttpPost()]\r\n   public ActionResult<SentimentPrediction> GetSentiment(SentimentObservation inputDataSample)\r\n   {\r\n      return _predictionEnginePool.Predict(inputDataSample);\r\n   }\r\n}\r\n<\/pre>\n<p>It is that simple while getting an optimized and thread-safe ML.NET prediction infrastructure for multi-threaded ASP.NET Core apps. Please, try it out and give us feedback.<\/p>\n<p>You can find and end-to-end WebAPI sample running an ML.NET model by using the Microsoft.Extensions.ML, here:<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/dotnet\/machinelearning-samples\/tree\/master\/samples\/csharp\/end-to-end-apps\/ScalableMLModelOnWebAPI-IntegrationPkg\">ASP.NET Core WebAPI sample optimized for scalability and performance when runnig\/scoring an ML.NET model<\/a><\/li>\n<\/ul>\n<h2><a id=\"user-content-positioning-mlnet-with-other-ml-frameworks\" class=\"anchor\" aria-hidden=\"true\" href=\"#positioning-mlnet-with-other-ml-frameworks\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"><\/path><\/svg><\/a>Positioning ML.NET with other ML frameworks<\/h2>\n<p>If you are looking for any comparison with other existing ML frameworks, I&#8217;d say that  <strong>Scitkit-Learn<\/strong> (Python-based) is probably the framework with most similar machine learning capabilities. Scitkit-Learn is a great ML framework for Python developers that also runs on Microsoft platforms such as Azure.<\/p>\n<p>The biggest difference lays on the fact that ML.NET is &#8220;native .NET&#8221; and targets .NET developers primarily.<\/p>\n<p>ML.NET also provides <strong>bindings for Python<\/strong> (named <strong><a href=\"https:\/\/docs.microsoft.com\/en-us\/nimbusml\/overview\" rel=\"nofollow\">NimbusML<\/a><\/strong>) which is currently an experimental solution. This is a collateral scenario that can be useful for data scientists working on Python and collaborating with .NET developers through the same ML.NET models. But, as previously mentioned, ML.NET targets .NET developers as the main user or &#8216;persona&#8217;.<\/p>\n<h2><a id=\"user-content-get-started-with-mlnet-10\" class=\"anchor\" aria-hidden=\"true\" href=\"#get-started-with-mlnet-10\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"><\/path><\/svg><\/a>Get started with ML.NET 1.0!<\/h2>\n<p><img decoding=\"async\" src=\"https:\/\/github.com\/CESARDELATORRE\/MLNET-Posts\/raw\/master\/Posts\/002-What-is-MLNET-1.0\/MLNET-Blog-Post-images\/get-started-rocket.png\" alt=\"alt text\" title=\"Get started icon\" style=\"max-width:100%;\"><\/p>\n<p>This current blog post is providing significant technical details. For a simpler ML.NET 1.0 release announcement, check out the <a href=\"https:\/\/aka.ms\/mlnet1-announcement-blog-post\" rel=\"nofollow\">official ML.NET 1.0 announcement Blog Post here<\/a>.<\/p>\n<p>Get started with ML.NET by exploring the following resources:<\/p>\n<ul>\n<li><strong>Get started<\/strong> with <a href=\"https:\/\/www.microsoft.com\/net\/learn\/apps\/machine-learning-and-ai\/ml-dotnet\/get-started\" rel=\"nofollow\">ML.NET here<\/a>.<\/li>\n<li><strong>Tutorials<\/strong> and resources at the <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/machine-learning\/\" rel=\"nofollow\">Microsoft Docs ML.NET Guide<\/a><\/li>\n<li><strong>Sample apps<\/strong> using ML.NET at the <a href=\"https:\/\/github.com\/dotnet\/machinelearning-samples\">machinelearning-samples GitHub repo<\/a><\/li>\n<\/ul>\n<p>Thanks and happy coding with <a href=\"http:\/\/dot.net\/ml\" rel=\"nofollow\">ML.NET<\/a>!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today, coinciding with \/\/BUILD 2019\/ conference, we\u2019re thrilled by launching ML.NET 1.0 release! You can read the official ML.NET 1.0 release announcement Blog Post here and get started at the ML.NET site here. In this blog post I&#8217;m providing quite a few additional technical details along with my personal vision that you might find interesting, [&hellip;]<\/p>\n","protected":false},"author":362,"featured_media":12588,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[8,21,308,309,299],"class_list":["post-12567","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cesardelatorre","tag-net-core","tag-asp-net-core","tag-machine-learning","tag-ml","tag-ml-net"],"acf":[],"blog_post_summary":"<p>Today, coinciding with \/\/BUILD 2019\/ conference, we\u2019re thrilled by launching ML.NET 1.0 release! You can read the official ML.NET 1.0 release announcement Blog Post here and get started at the ML.NET site here. In this blog post I&#8217;m providing quite a few additional technical details along with my personal vision that you might find interesting, [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/posts\/12567","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/users\/362"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/comments?post=12567"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/posts\/12567\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/media\/12588"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/media?parent=12567"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/categories?post=12567"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/tags?post=12567"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}