Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 16.1 — The AI Python Landscape: Which Library Does What
Python · Example 1 of 2

The stack as data

Each layer is a small record. Add a layer of your own (say "Docker: package it") and run it again.

AI work in Python is a stack of layers: NumPy and pandas for data, scikit-learn for classic machine learning, PyTorch for neural networks, Hugging Face for trained models, SDKs for hosted LLMs, frameworks and FastAPI on top. Knowing what each layer is for tells you what to learn first.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 6 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Write a function pick_layer(task) that returns the right library for a few tasks and a helpful default otherwise.

02

Write a function comes_first(a, b) that says whether layer a should be learned before layer b, using a list that gives the learning order.

03

Write a function layer_count(stack) that counts how many distinct layers a list mentions (the list may repeat names).

Explain it without notes

01

What is the role of Python in an AI system, given that the heavy computation is not done in Python?

02

Name the layers of the AI Python stack and say what each is for.

03

When would you use scikit-learn instead of PyTorch, and when would you call a hosted LLM instead of either?

04

A teammate proposes an LLM call to classify 2 million support tickets into 12 fixed categories you already have labelled history for. What do you ask, and what would you try first?

The stack as data
Sign in to run this example in your browser.

Expected output

1. Python                 glue: files, functions, classes, errors
2. NumPy, pandas          fast arrays and tables
3. scikit-learn           classic machine learning
4. PyTorch                tensors, autograd, neural nets
5. Hugging Face           download and run trained models
6. LLM APIs and SDKs      rent a big model over HTTP
7. Frameworks             ready-made RAG and agent parts
8. FastAPI, vector stores serve it, store vectors

LLM engineers start at layer 6