{"id":17495,"date":"2018-05-07T17:41:28","date_gmt":"2018-05-08T00:41:28","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/dotnet\/?p=17495"},"modified":"2019-02-22T14:53:30","modified_gmt":"2019-02-22T21:53:30","slug":"introducing-ml-net-cross-platform-proven-and-open-source-machine-learning-framework","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/dotnet\/introducing-ml-net-cross-platform-proven-and-open-source-machine-learning-framework\/","title":{"rendered":"Introducing ML.NET: Cross-platform, Proven and Open Source Machine Learning Framework"},"content":{"rendered":"<p>Today at \/\/Build 2018, we are excited to announce the preview of <strong> ML.NET, a cross-platform, open source machine learning framework<\/strong>. ML.NET will allow .NET developers\u00a0to develop their own models and infuse custom ML into their applications without prior expertise in developing or tuning machine learning models.<\/p>\n<p>ML.NET was originally developed in Microsoft Research and evolved into a significant framework over the last decade; it is used across many product groups in Microsoft like <strong> Windows, Bing, Azure, and more <\/strong>.<\/p>\n<p>With this first preview release, ML.NET enables ML tasks like classification (e.g. text categorization and sentiment analysis) and regression (e.g. forecasting and price prediction). Along with these ML capabilities, this first release of ML.NET also brings the first draft of .NET APIs for training models, using models for predictions, as well as the core components of this framework, such as learning algorithms, transforms, and core ML data structures.<\/p>\n<p>ML.NET is first and foremost a framework, which means that it can be extended to add popular ML Libraries like TensorFlow, Accord.NET, and CNTK. We are committed to bringing the full experience of ML.NET\u2019s internal capabilities to ML.NET in open source.<\/p>\n<p>To sum it all up, ML.NET is our commitment to make ML great in .NET.<\/p>\n<p>Please come and join us over on GitHub and help shape the future of ML in .NET:<\/p>\n<p><a href=\"https:\/\/github.com\/dotnet\/machinelearning\">https:\/\/github.com\/dotnet\/machinelearning<\/a><\/p>\n<p>Over time, ML.NET will enable other ML scenarios like recommendation systems, anomaly detection, and other approaches, like deep learning, by leveraging popular deep learning libraries like TensorFlow, Caffe2, and CNTK, and general machine learning libraries like Accord.NET.<\/p>\n<p>ML.NET also complements the experience that Azure Machine Learning and Cognitive Services provides by allowing for a code-first approach, supports app-local deployment and the ability to build your own models.<\/p>\n<p>The rest of this blog post provides more details about ML.NET; feel free to jump to the one that interests you the most.<\/p>\n<ul>\n<li><a href=\"#corecomponents\">ML.NET Core Components<\/a><\/li>\n<li><a href=\"#sentiment\">Sentiment Classification with ML.NET<\/a><\/li>\n<li><a href=\"#roadahead\">The Road Ahead<\/a><\/li>\n<li><a href=\"#feedback\">Help shape ML.NET for your needs<\/a><\/li>\n<\/ul>\n<p><em>This blog is Co-authored by Gal Oshri,\u00a0Niklas Gustafsson, Markus Weimer &amp; Nagesh Pabbisetty<\/em><\/p>\n<h3 id=\"corecomponents\">ML.NET Core Components<\/h3>\n<p>ML.NET is being launched as a part of the .NET Foundation and the repo today contains the .NET C# 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.<\/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, high performance math, data structures for heterogeneous data, tooling support, and more.<\/p>\n<p>The table below describes the entire list of components that are being released as a part of ML.NET 0.1.<\/p>\n<p><a href=\"http:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2018\/05\/POSTS.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2018\/05\/POSTS.png\" alt=\"\" width=\"587\" height=\"294\" class=\"alignnone wp-image-17575\" srcset=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2018\/05\/POSTS.png 1529w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2018\/05\/POSTS-300x150.png 300w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2018\/05\/POSTS-768x385.png 768w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2018\/05\/POSTS-1024x514.png 1024w\" sizes=\"(max-width: 587px) 100vw, 587px\" \/><\/a><\/p>\n<p>We aim to make ML.NET\u2019s APIs generic, such that other frameworks like CNTK, Accord.NET, TensorFlow and other libraries can become usable through one shared API.<\/p>\n<h3>Getting Started Installation<\/h3>\n<p>To get started with ML.NET, install the ML.NET NuGet from the CLI using:\n<code><\/code><\/p>\n<pre>dotnet add package Microsoft.ML\r\n<\/pre>\n<p>From package manager:\n<code><\/code><\/p>\n<pre>Install-Package Microsoft.ML\r\n<\/pre>\n<p>You can build the framework directly from <a href=\"https:\/\/github.com\/dotnet\/machinelearning\">https:\/\/github.com\/dotnet\/machinelearning<\/a>.<\/p>\n<h3 id=\"sentiment\">Sentiment Classification with ML.NET<\/h3>\n<h4>Train your own model<\/h4>\n<p>Here is a simple snippet to train a model for sentiment classification (full snippet of code can be found <a href=\"https:\/\/github.com\/dotnet\/machinelearning\/\">here<\/a>).<\/p>\n<pre><code>\r\nvar pipeline = new LearningPipeline();\r\n\r\npipeline.Add(new TextLoader&lt;SentimentData&gt;(dataPath, separator: \",\"));\r\n\r\npipeline.Add(new TextFeaturizer(\"Features\", \"SentimentText\"));\r\n\r\npipeline.Add(new FastTreeBinaryClassifier());\r\n\r\npipeline.Add(new PredictedLabelColumnOriginalValueConverter(PredictedLabelColumn = \"PredictedLabel\"));\r\n\r\nvar model = pipeline.Train&lt;SentimentData, SentimentPrediction&gt;();\r\n<\/code><\/pre>\n<p>Let\u2019s go through this in a bit more detail. We create a <strong>LearningPipeline<\/strong> which will encapsulate the data loading, data processing\/featurization, and learning algorithm. These are the steps required to train a machine learning model which allows us to take the input data and output a prediction.<\/p>\n<p>The first part of the pipeline is the <strong>TextLoader<\/strong>, which loads the data from our training file into our pipeline. We then apply a <strong>TextFeaturizer<\/strong> to convert the SentimentText column into a numeric vector called Features which can be used by the machine learning algorithm (as it cannot take text input). This is our preprocessing\/featurization step.<\/p>\n<p><strong>FastTreeBinaryClassifier<\/strong> is a decision tree learner we will use in this pipeline. Like the featurization step, trying out different learners available in ML.NET and changing their parameters may enable identifying better results. <strong>PredictedLabelColumnOriginalValueConverter<\/strong> converts the model\u2019s predicted labels back to their original value\/format.<\/p>\n<p><strong>pipeline.Train&lt;SentimentData, SentimentPrediction&gt;()<\/strong> trains the pipeline (loads the data, trains the featurizer and learner). The experiment is not executed until this happens.<\/p>\n<h4>Use the trained model for predictions<\/h4>\n<pre><code>\r\nSentimentData data = new SentimentData\r\n{\r\n    SentimentText = \"Today is a great day!\"\r\n};\r\n\r\nSentimentPrediction prediction = model.Predict(data);\r\n\r\nConsole.WriteLine(\"prediction: \" + prediction.Sentiment);\r\n<\/code><\/pre>\n<p>To get a prediction, we use <strong>model.Predict()<\/strong> on new data. Note that the input data is a string and the model includes the featurization, so our pipeline stays in sync during both training and prediction. We didn\u2019t have to write preprocessing\/featurization code specifically for predictions.<\/p>\n<p>For more scenarios for getting started please refer to the documentation walkthroughs which go over sentiment analysis and taxi fare prediction in more detail.<\/p>\n<h3 id=\"roadahead\">The Road Ahead<\/h3>\n<p>There are many capabilities we aspire to add to ML.NET, but we would love to understand what will best fit your needs. The current areas we are exploring are:<\/p>\n<ul>\n<li>Additional ML Tasks and Scenarios<\/li>\n<li>Deep Learning with TensorFlow &amp; CNTK<\/li>\n<li>ONNX support<\/li>\n<li>Scale-out on Azure<\/li>\n<li>Better GUI to simplify ML tasks<\/li>\n<li>Integration with VS Tools for AI<\/li>\n<li>Language Innovation for .NET<\/li>\n<\/ul>\n<h3 id=\"feedback\">Help shape ML.NET for your needs<\/h3>\n<p>Take it for a spin, build something with it, and tell us what ML.NET should be better at. File a couple of issues and suggestions on GitHub and help shape ML.NET for your needs.<\/p>\n<p><a href=\"https:\/\/github.com\/dotnet\/machinelearning\">https:\/\/github.com\/dotnet\/machinelearning<\/a><\/p>\n<p>If you prefer reaching out to us directly, you can do so by providing your details through this <a href=\"https:\/\/www.research.net\/r\/8DN9NGK\">very short survey<\/a>.<\/p>\n<p><em>This blog was Co-authored by Gal Oshri,\u00a0Niklas Gustafsson, Markus Weimer &amp; Nagesh Pabbisetty<\/em><\/p>\n<p>Thanks,\nML.NET Team<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today at \/\/Build 2018, we are excited to announce the preview of ML.NET, a cross-platform, open source machine learning framework. ML.NET will allow .NET developers\u00a0to develop their own models and infuse custom ML into their applications without prior expertise in developing or tuning machine learning models. ML.NET was originally developed in Microsoft Research and evolved [&hellip;]<\/p>\n","protected":false},"author":362,"featured_media":58792,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[195,691],"tags":[],"class_list":["post-17495","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dotnet-framework","category-ml-dotnet"],"acf":[],"blog_post_summary":"<p>Today at \/\/Build 2018, we are excited to announce the preview of ML.NET, a cross-platform, open source machine learning framework. ML.NET will allow .NET developers\u00a0to develop their own models and infuse custom ML into their applications without prior expertise in developing or tuning machine learning models. ML.NET was originally developed in Microsoft Research and evolved [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/17495","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/users\/362"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/comments?post=17495"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/17495\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media\/58792"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media?parent=17495"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/categories?post=17495"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/tags?post=17495"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}