Packaging and containerization

End-to-End Machine Learning

Joshua Stapleton

Machine Learning Engineer

Deployment und Containerisierung

Deployment

  • Modell + Abhängigkeiten zu Einheiten packen
  • Für das Ausführen in anderen Umgebungen
  • De-facto-Framework für Container & Deployment: Docker

Deployment phase of machine learning lifecycle

End-to-End Machine Learning

Docker

  • Plattform, die Entwicklung mit Containern vereinfacht

Container:

  • Packen Apps als eigenständige Einheiten
  • Plattformunabhängig konzipiert
  • Get Docker

 

DataCamp Docker Course

Docker logo

End-to-End Machine Learning

Docker: Teil 1

Dockerfile: Anweisungen zum Bauen des Containers

# Use an official Python runtime as a parent image
FROM Python:3.7

# Set the working directory in the container to /app WORKDIR /ML_pipeline
# Copy the current directory contents into the container at /app ADD . /ML_pipeline
# Install any needed packages specified in requirements.txt RUN pip install --no-cache-dir -r requirements.txt
End-to-End Machine Learning

Docker: Teil 2

# ... continued
# Make port 80 available to the world outside this container
EXPOSE 80
# Define environment variable
ENV NAME World
# Run app.py when the container launches
CMD ["Python", "ML_pipeline.py"]

Definiertes Image bauen:

docker build -t heart_disease_model .
End-to-End Machine Learning

Container taggen

Tagging:

docker tag heart_disease_model:latest heart_disease_model:1.0
  • Macht Images/Container leichter erkennbar und verwaltbar.
  • Unterstützt eine detaillierte, robuste Modell-Registry.
  • Nach dem Tagging sind wir bereit zum Deployen!

Deployment visualized as an arrow

End-to-End Machine Learning

Best Practices

Docker macht das Packen von Modellen leicht …

  • Sicherheit mitdenken
  • Keine sensiblen Daten einbauen
  • Vertrauenswürdige Images nutzen (verifizierte Entwickler)

Wenn deine App sensible Infos hat …

  • Umgebungsvariablen verwenden
  • Z. B. für Connection-Strings/Passwörter

Security lock

End-to-End Machine Learning

Lass uns üben!

End-to-End Machine Learning

Preparing Video For Download...