Learning track — pick your next page
Start here for environments and core language habits, then branch. Each page is self-contained but assumes you can run Python 3.10+ locally.
Hub & Python core
Virtual environments, pip, syntax, data structures, functions, classes, packages, and testing basics.
Data science & ML
NumPy, Pandas, visualization, scikit-learn pipelines, and the classical ML workflow.
PyTorch & theory
Tensors, autograd, nn.Module, training loops, loss, optimizers, regularization.
FastAPI & engineering
REST APIs, Pydantic, async I/O, serving models, batch/streaming and ops touchpoints.
Environments & tooling
Virtual environments & installs
Isolate dependencies per project — non-negotiable for ML stacks
Never install PyTorch or Pandas into the system Python on your laptop. Use a venv (stdlib) or conda/mamba for scientific stacks, or uv for fast installs. Pin versions in requirements.txt or pyproject.toml for anything you ship.
# Create and activate (Windows PowerShell) python -m venv .venv .\.venv\Scripts\Activate.ps1 # macOS / Linux python3 -m venv .venv source .venv/bin/activate pip install --upgrade pip pip install numpy pandas scikit-learn torch fastapi uvicorn pip freeze > requirements.txt
requirements.txt or lockfile; add .venv/ to .gitignore. For GPU PyTorch, follow the official install matrix (CUDA vs CPU).Syntax, types & collections
Idioms you will see everywhere
List/dict comprehensions, unpacking, f-strings
# Comprehensions — prefer over map/filter for readability squares = [x * x for x in range(10) if x % 2 == 0] # Dict & set comprehensions word_lengths = {w: len(w) for w in ["ai", "ml", "de"]} # Unpacking first, *rest, last = [1, 2, 3, 4, 5] # f-strings (Python 3.8+) name, loss = "train", 0.42 print(f"epoch={name!r} loss={loss:.4f}")
For data work you will live in iterables and generators when files or streams are too large to load at once—see the FastAPI page for streaming responses.
Type hints & data classes
Readable APIs — pairs well with Pydantic on the FastAPI page
from dataclasses import dataclass from typing import Optional, Sequence @dataclass class BatchConfig: batch_size: int = 32 shuffle: bool = True drop_last: Optional[bool] = None def moving_average(xs: Sequence[float], window: int) -> list[float]: """Hints document intent; mypy/pyright catch mistakes.""" ...
Project layout & testing
Packages, src/ layout & pytest
How ML repos are usually organized
project/
pyproject.toml
src/mypkg/
__init__.py
train.py
tests/test_train.py
Assert data transforms, metric computation, and inference code—models are hard to test end-to-end, but pure functions should be deterministic.
# tests/test_metrics.py — example pattern import pytest def accuracy(y_true, y_pred): return sum(a == b for a, b in zip(y_true, y_pred)) / len(y_true) def test_accuracy_perfect(): y_true = [0, 1, 1] y_pred = [0, 1, 1] assert accuracy(y_true, y_pred) == pytest.approx(1.0)
→ Data & ML — NumPy, Pandas, scikit-learn
→ PyTorch & AI — deep learning core
→ FastAPI & engineering — ship models behind HTTP
Theory (visuals): ML & AI theory hub