May we use cookies so Meta, Google, LinkedIn and ChatGPT see your visit and we learn which ads work? PrivacyMay we use cookies to see which pages help, and let Meta, Google, LinkedIn and ChatGPT see your visit, so we know which of our ads work? That way we spend less on ads that do not work. We do not sell your data, and the site works the same if you decline. You can change your answer at any time under Cookie settings at the foot of the page. Privacy policy
Loading...
AI Engineering · Packaging And Registry
Free preview: the first 2 parts of this 28-part lesson.
Already bought the course? Sign in to read the whole lesson.
this lesson is part of
Generative AI and Agentic AI Engineering
Unlock this lesson and the 208 other paid lessons
$35 once, by card or PayPal
See the Generative AI and Agentic AI courseread the rest of this lesson in
Generative AI and Agentic AI Engineering
Unlock this lesson and the 208 other paid lessons
$35 once, by card or PayPal
See the Generative AI and Agentic AI coursein Packaging And Registry
This lesson is part of the AI Engineering course. Unlock the full course, a separate one-time payment, for lifetime access.
One-time payment by card or PayPal
Get Lifetime AccessOne-time payment: UPI, card or netbanking
Get Lifetime AccessFoundation lessons of this course are free, no payment needed. Try them now
Let me start with a trip, like the one in the picture.
Imagine you are going away for a week. You could put your whole home in a truck: the bed, the kitchen, the tools in the garage, every book. You would certainly have everything you need. But the truck is slow and costly to move, and almost none of it will be used.

So you pack one bag instead. A small bag is quick to carry. But a small bag has a risk too. If you forget the charger for your phone, the trip goes badly, and a lighter bag does not fix that.
A trained model also has to travel: from the laptop where it was made, to a server where it answers questions. In this lesson I pack the same model into bags of different sizes, weigh each bag, and check that the model inside still gives exactly the same answers.
This lesson uses the model from the features chapter. If it is new to you, please read what a feature is first. That lesson built six features for each customer of a real online shop. It asked one question: at the start of a month, will this customer buy something in the next 30 days? The model is a gradient boosted tree model from scikit-learn, and it scored a test AP of 0.5450. AP, average precision, is a score from 0 to 1 for how well the model ranks the buyers above the others.
Two lessons of this chapter come just before this one. Library version skew showed that a saved model often fails to load when the library versions change. Pinning dependencies showed how to write down the exact versions. Here I take the next step: put the model, the exact libraries and Python itself into one sealed package.
The survey lesson on model packaging and containerization explains Dockerfiles in words, with example sizes. I will not repeat it. Here I build real images and measure them.