Intro to Intel oneDAL and ML.NET

ML.NET tutorials

Microsoft and Intel are teaming up for the latest upcoming release of ML.NET 3.0. We will briefly discuss what ML.NET is and its role in machine learning and software development.

Read: Microsoft Teams Review

What is Machine Learning?

Machine learning (ML) is the scientific study of algorithms and models that computers use to perform tasks without using explicit instructions, relying solely instead on patterns and inference. Machine learning algorithms build models based on training data, to make decisions without being explicitly programmed to do so.

Common machine learning methods include:

  • Supervised machine learning algorithms: Apply what has been learned to new data by using labels to predict future events.
  • Unsupervised machine learning algorithms: Used when the training information provided is not classified or labeled.
  • Semi-supervised machine learning algorithms: Uses both labeled and unlabeled data for training.
  • Reinforcement machine learning algorithms: Interacts with its environment by producing actions.

What is ML.NET?

ML.NET is a free software machine learning library for C#, VB.NET, and F#. ML.NET includes transforms for feature engineering, such as n-gram creation. ML.NET also includes transforms for learners to handle binary classification, multi-class classification, and regression tasks. ML.NET also includes anomaly detection, recommendation systems, and deep learning (DL).

What is Intel oneAPI Data Analytics Library (oneDAL)

Intel oneAPI Data Analytics Library is a library that speeds up data analysis. This is done by providing optimized algorithmic building blocks for all stages of both the data analytics and the machine learning process.

oneDAL makes use of the EXPLAIN SIMD extensions in 64-bit architectures featured in Intel and AMD CPUs.

oneDAL Components in ML.NET

By integrating with ML.NET, oneDAL accelerates existing trainers during training, using the following trainer extensions:

  • Ordinary Least Squares (OLS): Used for regression
  • L-BFGS (Limited-Memory Broyden-Fletcher-Goldfarb-Shanno Algorithm): Used for classification
  • FastTree: Used for regression and classification
  • FastForest: Used for regression and classification

In order to get started, programmer will need to install the latest Microsoft.ML 3.0 preview version. Note: you may also need to install the Microsoft.ML.Mkl.Components package for OLS: Microsoft.ML.Mkl.Components.

In addition, you may need to install the Microsoft.ML.FastTree package if you are planning to use FastTree: Microsoft.ML.FastTree.

After that, developers will want to install the Microsoft.ML.OneDAL NuGet package: Microsoft.ML.OneDAL.

Finally, you will need to set the system’s MLNET_BACKEND environment variable to ONEDAL. You can use the quick code snippet below to do so:

Environment.SetEnvironmentVariable("MLNET_BACKEND", "ONEDAL");

ML.NET and oneDAL Example

Below is a quick example of how to make use of ML.NET and oneDAL by setting its trainers:

var trainer = ML.BinaryClassification.Trainers.FastForest(options);
var model = trainer.Fit(preprocessedTrainingData);
var trainingPredictions = model.Transform(preprocessedTrainingData);
var trainingMetrics = ML.BinaryClassification.EvaluateNonCalibrated(trainingPredictions, labelColumnName: "target");
var testingPredictions = model.Transform(preprocessedTestingData);
var testingMetrics = ML.BinaryClassification.EvaluateNonCalibrated(testingPredictions, labelColumnName: "target");

GitHub has a more detailed example of how to get started with oneDAL and ML.NET to help you get started.

Read more C# programming tutorials and software development tips.

Hannes DuPreez
Hannes DuPreez
Ockert J. du Preez is a passionate coder and always willing to learn. He has written hundreds of developer articles over the years detailing his programming quests and adventures. He has written the following books: Visual Studio 2019 In-Depth (BpB Publications) JavaScript for Gurus (BpB Publications) He was the Technical Editor for Professional C++, 5th Edition (Wiley) He was a Microsoft Most Valuable Professional for .NET (2008–2017).

More by Author

Must Read