We're making some improvements. Some features may be temporarily unavailable.
intermediate20 min

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

Output
Run your code to see output here

Pandas — Data Wrangling

Pandas gives you DataFrames — think Excel spreadsheets in Python:

Pandas — Data Wrangling

Output
Run your code to see output here

Scikit-learn — Classical ML

The most popular ML library — consistent API across dozens of algorithms:

Scikit-learn — Consistent ML API

Output
Run your code to see output here

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:

FeaturePyTorchTensorFlow
StylePythonic, imperativeGraph-based (eager since 2.0)
DebuggingStandard Python debuggerSpecial tools needed
AdoptionDominant in researchStrong in production
Ecosystemtorchvision, torchaudioTensorFlow 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.

Python will load on first run

Getting Started in 2026

  1. Learn NumPy first — it's the foundation of everything
  2. Master Pandas — you'll spend 60-80% of your time on data prep
  3. Start with scikit-learn — the easiest path to ML
  4. Move to PyTorch when you need deep learning
  5. Build projects — Kaggle competitions are great practice
  6. 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

Questions & Discussion

Sign in to ask a question or join the discussion.

Loading comments...