A panoramic photograph of Malham Cove in North Yorkshire.

Teaching a web server how to drink.

Tom Forth, .

You can use the tool I'm talking about now at Artificiell intelligens Systembolaget.

In Sweden, drinks with over 3.5% alcohol can only be sold for consumption at home by Systembolaget, the state monopoly. There are lots of reasons why I dislike this system. I am glad we do not have the same in the UK.

But there is at least one benefit. The list of all 19963 alcoholic drinks that can be legally bought in Sweden is available to download for free with a permissive (though not open data compliant) licence. Downloads in XML and XLS format are available at Systembolaget.se/api/.

Microsoft and machine learning

In the late 2010’s Microsoft realised that they had a big problem. “Machine-learning” was becoming a major area of popular computing and it was all happening outside of the Microsoft world of programming. Scikit-learn, PyTorch, and TensorFlow were all written to work best in Python, an open-source programming language that Microsoft didn’t have a strength in. Courses, code, and tutorials like fast.ai were making these systems approachable to many new programmers.

Microsoft was nowhere. Its flagship programming framework .NET (most usually programmed in C#) had no native machine learning capabilities. Libraries like the excellent and complete Accord Framework were clunky and slow compared to what Google and Facebook were giving away for free. The eye-watering pace with which Google, Facebook, and partners like Nvidia and US universities were innovating was unthinkable in the Microsoft ecosystem.

The default for young excited minds working on machine learning was to write code in Python and deploy it on Amazon’s AWS cloud or Google’s App engine. This was a clear threat to Microsoft’s cloud strategy. If no-one was using .NET for machine learning then almost no-one would be deploying their code to Azure, its equivalent to AWS.

Nearly as bad, without a strong machine learning framework within Microsoft, products like PowerBI, Microsoft Office, and Windows that were offering “AI” features were taking longer to develop and delivering poorer results.

A team at Microsoft urgently started sticking together work that had been happening across Microsoft, most importantly at Microsoft Research and Bing, for about five years.

In 2018 the first preview releases of their solution to their problems came out. ML.NET Preview 0.1 was a buggy and incomplete mess. It was almost unusable. I remember the most basic example projects failing to compile and run. But it was clear that ML.NET was a huge improvement on what Microsoft offered before, and fixes and improvements kept on coming.

Engineers at Microsoft were blogging weekly about their ambitions for ML.NET. Issues on the project’s GitHub were being responded to within minutes. Fixes were made within weeks.

So what does this have to do with Swedish alcohol?

ML.NET and beer

Frameworks for developing software are only as good as the examples that new programmers can copy off the internet to learn them. I’m not sure why, but the people who develop programming frameworks are almost never capable of writing good demos. So to succeed, any new framework needs great demos written by outsiders.

In machine-learning any good demo needs good data. The first great demo of ML.NET used the Systembolaget database for that. It was written by Alexander Dragunov in Stockholm, who works for Amazon on the team that makes Microsoft’s .NET framework work on Amazon’s AWS cloud.

This demo was probably when I knew that ML.NET was going to succeed. I started writing versions of my existing machine-learning code in it, checking that I got the same answers, and comparing performance and stability. When the ML.NET v 1.4 preview came out in September 2019 I decided to start switching my existing projects to use ML.NET, a process that took me about six months.

The biggest advantage for me with ML.NET is that it fits into a Microsoft ecosystem where huge amounts of effort and R&D by Microsoft supports me. Visual Studio is the best IDE in the world. Deploying code from Visual Studio to Azure is easy. Running machine-learning applications at scale on Windows, within Azure, within the Microsoft world is so much simpler than what I did before. It is letting me achieve more, more quickly, for less money, and with less stress.


Today Microsoft is addressing another gap in its software products, its tools for writing complete websites powered by big databases are as poor as its machine-learning offer was before ML.NET.

Active Server Pages (ASP) is two decades old. Vue, released in 2014, Facebook’s React, released in 2015, and Google’s Angular, released in 2016, are far better than anything Microsoft offers. Young excited minds are completely uninterested in Microsoft’s clunky alternatives.

Microsoft’s answer is called Blazor. Like ML.NET it came out in 2018. A few months ago I started using it, specifically the WebAssembly variant. It wasn’t ready then, but it’s getting close. It feels the same to me as ML.NET did in mid-2019 when I first ran Alexander Dragunov’s example code.

So I’m going to try and prove it this evening. I’m going to write a UI for the machine-learning code based on Sweden’s alcoholic drinks library and deploy it. I’ll try do it in 90 minutes.

blog comments powered by Disqus