Member-only story
Scikit-Learn Hello World
How to create a simple machine learning application and Dockerize it
This article is a simple example of using Scikit-Learn to create a simple classifier based on the Iris dataset. The Python code is then Dockerized at the end so you can share it easily or have a platform-independent setup.
TL;DR
The final result is available on GitHub.

Installation
In this example, we use Python version 3.12.0 together with virtualenv. Ubuntu 24.04 comes with Python 3.12 pre-installed. To install Python 3.12 on MacOS, you can use Homebrew:
brew install python@3.12
On Windows, you can use the official Python installer from the Python website.
Later we also use Docker to run the Python code in a container. The easiest way to install Docker is to install Docker Desktop. On Linux, you can alternatively install Docker Engine natively.
Create the Project with a Hello World Python script
First, create a new directory for the project and navigate into it. Then create a new file called main.py
with the following content:
def main():
print("Hello, world!")
if __name__ == '__main__'…