AI in Practice: Libraries and Tools
Explore the real tools data scientists and ML engineers use — NumPy, Pandas, scikit-learn, PyTorch
The AI/ML Ecosystem
You don't build AI from scratch. A rich ecosystem of libraries makes it practical. Here's what professionals actually use:
Python ML Stack
Data Handling Modeling Deployment
─────────── ────────── ───────────
NumPy Scikit-learn FastAPI
Pandas PyTorch Docker
Polars TensorFlow ONNX
NumPy — The Foundation
NumPy provides fast, multi-dimensional arrays — the fundamental data structure of AI:
NumPy — The Foundation
Pandas — Data Wrangling
Pandas gives you DataFrames — think Excel spreadsheets in Python:
Pandas — Data Wrangling
Scikit-learn — Classical ML
The most popular ML library — consistent API across dozens of algorithms:
Scikit-learn — Consistent ML API
Check Your Understanding
Why is scikit-learn's consistent API (.fit() and .predict()) so valuable?
PyTorch & TensorFlow — Deep Learning
For neural networks and deep learning:
| Feature | PyTorch | TensorFlow |
|---|---|---|
| Style | Pythonic, imperative | Graph-based (eager since 2.0) |
| Debugging | Standard Python debugger | Special tools needed |
| Adoption | Dominant in research | Strong in production |
| Ecosystem | torchvision, torchaudio | TensorFlow Serving, TF Lite |
# PyTorch example (conceptual)
# model = torch.nn.Sequential(
# torch.nn.Linear(784, 128),
# torch.nn.ReLU(),
# torch.nn.Linear(128, 10),
# )
#
# # Training loop
# for epoch in range(10):
# for images, labels in dataloader:
# pred = model(images)
# loss = loss_fn(pred, labels)
# loss.backward()
# optimizer.step()
The ML Workflow
Every ML project follows this pattern:
1. PROBLEM Define what you're solving
2. DATA Collect and clean data
3. EXPLORE Visualize, find patterns
4. PREPROCESS Scale, encode, split
5. MODEL Choose and train algorithm
6. EVALUATE Test on held-out data
7. DEPLOY Make it usable by others
8. MONITOR Track performance over time
Check Your Understanding
What step should come FIRST in any ML project?
Exercise
Write a Python function `train_test_metrics(y_true, y_pred)` that simulates evaluating a binary classifier. It should calculate: (1) Accuracy: (TP+TN)/total, (2) Precision: TP/(TP+FP), (3) Recall: TP/(TP+FN). Count TP, TN, FP, FN from the two lists (1=positive, 0=negative). Print all three metrics.
Getting Started in 2026
- Learn NumPy first — it's the foundation of everything
- Master Pandas — you'll spend 60-80% of your time on data prep
- Start with scikit-learn — the easiest path to ML
- Move to PyTorch when you need deep learning
- Build projects — Kaggle competitions are great practice
- Deploy something — even a simple Streamlit app
Key Takeaways
- NumPy = fast arrays, Pandas = DataFrames, Scikit-learn = classical ML, PyTorch/TensorFlow = deep learning
- The ML workflow is: problem → data → explore → preprocess → model → evaluate → deploy → monitor
- Consistent APIs (like scikit-learn's) make experimentation easy
- You don't need a PhD to use ML libraries — start building!
- The best way to learn is by doing: pick a dataset and build something