Skip to main content
The Python AI Stack — What Each Library Is For

Data Foundations

The Python AI Stack — What Each Library Is For

Reading12 min read

The Python AI Stack — What Each Library Is For

"AI in Python" can feel like a wall of library names. In practice, the stack has a few clear layers, and knowing which layer a problem lives in tells you which tool to reach for — and, for a QA engineer, which kind of testing it needs.

The Layers

LayerLibrariesWhat it's for
Numerical coreNumPyFast arrays and vector maths — everything else builds on it
Data wranglingpandas (or Polars)Loading, cleaning, joining, summarising tabular data
Visualisationmatplotlib, seaborn, plotlySeeing distributions, trends, outliers
Classic MLscikit-learnClassification, regression, clustering on tabular data
Deep learningPyTorch (also JAX, TensorFlow)Training neural networks; mostly specialists
Pretrained modelsHugging Face transformers, sentence-transformersDownloading and running existing models locally
LLM APIsanthropic, other provider SDKsCalling hosted large language models
ValidationPydanticEnforcing structure on model inputs and outputs
RetrievalVector stores: Chroma, pgvector, FAISSSearching by meaning for RAG
Evaluationpytest + your own eval harness, specialist eval toolsMeasuring whether any of it works

You won't use all of them. This path focuses on the ones most engineers actually touch: NumPy, pandas, scikit-learn, an LLM SDK, embeddings, and — most importantly for QA — evaluation.

Two Very Different Kinds of "AI"

Classic machine learning (Module 2) learns patterns from your labelled data: predict whether a test is flaky from its history, classify a bug's severity from its fields. You train the model, and you own its data.

Large language models (Modules 3–5) are huge pretrained models you call through an API. You don't train them; you instruct them with prompts, give them context (RAG), and let them call tools (agents).

Both share one property that matters enormously for testing: their output is probabilistic. The same input can produce different outputs, and "correct" is often a matter of degree. That's why the final module is about evaluation — and why QA engineers who understand AI systems are in demand.

Setting Up

Create a fresh project with its own environment (see the Master Python path, Lesson 1):

uv init ai-lab && cd ai-lab
uv add numpy pandas matplotlib scikit-learn jupyter
uv add anthropic pydantic sentence-transformers chromadb

Jupyter notebooks (uv run jupyter lab) are great for exploring data step by step. Once something works, move it into normal .py modules with tests — notebooks are for exploration, not for code other people depend on.

Keep API Keys Out of Code

LLM APIs need a key. Store it in an environment variable, never in a notebook or a committed file:

export ANTHROPIC_API_KEY="sk-ant-..."     # or use a .env file listed in .gitignore

SDKs read the variable automatically. A key pasted into a notebook cell ends up in git history, screenshots and shared files — and keys are billed per use.

Cost and Data Awareness

Two habits from day one:

  1. Every LLM call costs money. Use small inputs while developing, cache results, and know roughly what a run costs before you loop over 10,000 rows.
  2. Know what data you're sending. Production logs and bug reports can contain customer data. Check your company's policy before sending anything to an external API, and strip personal data when you can.

How This Path Is Structured

  1. Data Foundations — NumPy and pandas on realistic QA data.
  2. Classic ML — the scikit-learn workflow and, crucially, how to measure it.
  3. LLM APIs — prompts, structured output, cost, and a working classifier.
  4. RAG — embeddings, search, and measuring retrieval.
  5. Tools and Agents — letting models call your functions, safely.
  6. Testing AI Code — evals, golden datasets, and a capstone.

💬 Discussion

Which repetitive judgement call in your QA work — triage, classification, summarising — would you most like an AI system to help with, and how would you know if it was doing a good job?

Q
Knowledge Check
1 / 3

Which library is the right first choice for loading, filtering and summarising a CSV of test results?

Next Lesson

NumPy — Arrays, Vectors, and Why Loops Are Slow