11 : “AI'll be back” - AI is taking over the world!

25 Feb 2022

Rowan and Andy are chatting about ML.net Microsoft's open source and cross-platform machine learning framework. We look at what it ML.net is and how you can use it using the tools you are already familiar with.

Random fact

The circulatory system is more than 60,000 miles long If a child’s entire circulatory system—we’re talking veins, arteries, and capillaries—were laid out flat, it would stretch for more than 60,000 miles, according to the Franklin Institute. By the time we reach adulthood, our bodies have become home to approximately 100,000 miles of blood vessels.

Introduction

ML is appearing all over the place these days. It is now common place to be using ML powered services - everything from:

  • Spam filters
  • home insurance policy premium calculations,
  • ai in your mobile phone
    • facial recognition in cameras,
    • augmented reality experiences on phones - apples animoji
  • my ring doorbell that recognises people
  • alexa / siri - voice commands and recognition
  • IOT devices
  • Github Autopilot / Visual Studio code completion - ML driven

It is now easier than ever to leverage the power of ML in software. We have been talking about how we could use ML in the software that we build.

Machine learning (ML) is the process of using mathematical models of data to help a computer learn without direct instruction. It’s considered a subset of artificial intelligence (AI). Machine learning uses algorithms to identify patterns within data, and those patterns are then used to create a data model that can make predictions. With increased data and experience, the results of machine learning are more accurate – much like how humans improve with more practice.

Other ML frameworks / platforms / tools

Framework/platform/tool Comment Price OS Support Language
Weka Data preparation Classification Regression Clustering Visualization Association rules mining Free Linux, Mac OS, Windows Java
KNIME Provides a library for dataflow programming. Free Linux, Mac OS, Windows Java
TensorFlow Provides a library for dataflow programming. Free Linux, Mac OS, Windows Python, C++, CUDA
Apache Mahout Preprocessors Regression Clustering Recommenders Distributed Linear Algebra. Free Cross-platform Java Scala
Accors.Net Classification Regression Distribution Clustering Hypothesis Tests & Kernel Methods Image, Audio & Signal. & Vision Free Cross-platform C#
Rapid Miner Data loading & Transformation Data preprocessing & visualization. Free Cross-platform Java
Colab Supports libraries of PyTorch, Keras, TensorFlow, and OpenCV Free Cloud Service
Shogun Regression Classification Clustering Support vector machines. Dimensionality reduction Online learning etc. Free Linux, Mac OS, Windows, UNIX C++
Keras.io API for neural networks Free Cross-platform Python
PyTorch Autograd Module Optim Module nn Module Free Linux, Mac OS, Windows Python, C++, CUDA

How to do it in .net - ML.net

ML.NET is a cross-platform open-source machine learning (ML) framework for .NET.

ML.NET allows developers to easily build, train, deploy, and consume custom models in their .NET applications without requiring prior expertise in developing machine learning models or experience with other programming languages like Python or R. The framework provides data loading from files and databases, enables data transformations, and includes many ML algorithms.

With ML.NET, you can train models for a variety of scenarios, like sentiment analysis, price prediction, product recommendation, sales forecasting, image classification, object detection and anomaly detection.

What types of apps can I deploy ML.NET models to?

You can use ML.NET with almost any .NET app, including web apps and services, Microservices/Containers, desktop apps (WPF and WinForms), Azure Functions and any Azure server-side app type, and console apps.

What frameworks can I use with ML.NET?

ML.NET is supported on both .NET, .NET Core (version 2.0 and above) and .NET Framework (version 4.6.1 and above).

What OS can I use with ML.NET?

ML.NET is cross platform, so it is supported on macOS, Linux, and Windows.

Is ML.NET free?

Yes! Like the rest of the .NET platform, ML.NET is 100% free. For more information, see .NET is free. ML.NET is licensed under the MIT license.

What is the best programming language for ML.NET?

ML.NET is currently supported for both C# and F#.

You can also consume both TensorFlow and ONNX models within ML.NET which makes the framework more extensible and expands the number of supported scenarios.

Need to know about algorithms?

ML.net does it all for you - obviously like everything it's worth having some background knowledge about it but it's like a car people know how it works but not how to build an engine.

Workflow with ML.Net:

  1. Create ML.NET context

    1. similar conceptually to DbContext in Entity Framework
  2. Load data

    1. LoadFromTextFile allows you to load data from TXT, CSV, TSV, and other file formats.
  3. Transform data

    1. In most cases, the data that you have available isn't suitable to be used directly to train a machine learning model
    2. Transformers take data, do some work on it, and return new, transformed data.
      1. text —> FeaturizeText() —> Featurized text (perhaps numeric)
  4. Choose algorithm

    Algorithm Trainer
    Binary classification (for example, sentiment analysis) AveragedPerceptronTrainer, SdcaLogisticRegressionBinaryTrainer
    Multi-class classification (for example, topic categorization) LightGbmMulticlassTrainer, OneVersusAllTrainer
    Regression (for example, price prediction) LbfgsPoissonRegressionTrainer, FastTreeRegressionTrainer
    Clustering (for example, customer segmentation) KMeansTrainer
    Anomaly Detection (for example, shampoo sales spike detection) RandomizedPcaTrainer
    Recommendation (for example, movie recommender) MatrixFactorizationTrainer
    Ranking (for example, search results) LightGbmRankingTrainer, FastTreeRankingTrainer
  5. Train model

    1. algorithms you have specified are not executed until you call the Fit() method (because of ML.NET's lazy loading approach). This is when model training happens
  6. Evaluate model

    ML.NET offers evaluators that assess the performance of your model on a variety of metrics:

    • Accuracy
    • Area under the curve (AUC)
    • R-Squared
    • Root Mean Squared Error (RMSE)
  7. Deploy & consume model

    1. You can save your trained model as a binary file that is then integrated into your .NET applications.

    Andy: OR

    Untitled

How does that workflow compare with what I would have to do with other tools like Tensorflow?

  • ML.Net uses AutoML (AutomatedML) - this automates a lot of the process around creating a performant model
  • It will take a lot longer - you can be done in minutes
  • Still have to get data
  • Still have to train and build a model, but this is much more complex
  • You'd have to learn Python!

It is extensible - ML.NET has been designed as an extensible platform so that you can consume other popular ML frameworks (TensorFlow, ONNX, Infer.NET, and more)

Get data sets from....

https://cml.ics.uci.edu/

https://archive.ics.uci.edu/ml/datasets/Sentiment+Labelled+Sentences - 588 Data Sets

and many other places

More information and to give it a try

You can get started with ML.NET with this tutorial (https://dotnet.microsoft.com/learn/ml-dotnet/get-started-tutorial/intro), or you can check out our ML.NET docs (https://docs.microsoft.com/en-gb/dotnet/machine-learning/?WT.mc_id=dotnet-35129-website) to learn more.

OS project/utility of the week

https://docs.microsoft.com/en-us/sysinternals/

The Sysinternals web site was created in 1996 by Mark Russinovich to host his advanced system utilities and technical information. Whether you’re an IT Pro or a developer, you’ll find Sysinternals utilities to help you manage, troubleshoot and diagnose your Windows systems and applications.

  • File and Disk
  • Networking
  • Process
  • Security
  • System Information
  • Misc - BGInfo, ZoomIt, PsShutdown