Machine Learning (ML)
Machine learning is an AI technique in which an algorithm learns patterns from sample data and builds a model from them that makes predictions for new data, without every rule being written by hand.
Machine learning (ML) is a technique of artificial intelligence: an algorithm learns patterns from sample data and builds a model from them that makes predictions or assignments for new data. Nobody writes the rules by hand; they emerge from the data.
How it works
The model is the central object. It contains the steps that turn input data into a prediction. The data from which it determines its parameters is called training data. The inputs are called features, the known correct values labels. The simplest example is a linear regression: the price of a house results from its size times a factor plus a base value, and both numbers are estimated from pairs of size and price.
Typical tasks are classification (sorting customer feedback into positive and negative), regression (predicting a value), anomaly detection (conspicuous transactions), recommendations, and forecasts from time series. A model is checked against data the training has never seen, and it is retrained when needed.
ML for .NET developers
For this, Microsoft offers ML.NET: an open-source, cross-platform framework with which you train models of your own in C# or F# and build them into .NET applications without leaving the .NET world. The flow in code is always the same: load data into an IDataView, define a pipeline of transformations and an algorithm, train with Fit, evaluate the model, save it, load it again, and make predictions with it. Heavier training can be moved to Azure Machine Learning, and pretrained models in the ONNX format can be included.
Many third-party training tools speak Python. For training and use in a .NET application, that is not necessary.
ML and language models: not the same
A language model is an ML model, but not every ML model is a language model. A small trained model can be cheaper, faster, always the same for the same input, and easier to explain. A language model understands free text, costs money per call, and does not answer the same way every time. The choice depends on the question, not on fashion.
An example from the Kladde
In the AI track, the Kladde, the sample application of a small IT office, first assesses tenders with a language model. After that, you train a small model with ML.NET that predicts the fit from three made-up features, and you compare both on the same cases: hit rate and costs.
Common misconceptions
- More data does not cure everything. Bad or biased data results in a bad model.
- The hit rate on training data says little. What counts is what the model achieves on unknown data.
- ML is no substitute for rules that must always hold. Such rules belong in code.
In the course
You learn this in the AI track, module T10, in the lesson Classic ML at a glance. Where language models fit in is covered in module T1, What a language model does, and measuring quality in module T9, Measuring quality with Microsoft.Extensions.AI.Evaluation.
Further reading on the blog
Sources
- Microsoft Learn, What is ML.NET and how does it work?: https://learn.microsoft.com/dotnet/machine-learning/mldotnet-api
- Microsoft Learn, Overview of ML.NET: https://learn.microsoft.com/dotnet/machine-learning/overview
- Microsoft Learn, AI technology overview: https://learn.microsoft.com/azure/architecture/ai-ml/ai-overview