Hour 1 – AI Libraries in Python (Learning & Setup)
Quick environment setup (choose one)
Option A – venv (works everywhere)
create & activate
python -m venv ai-basics
Windows:
ai-basics\Scripts\activate
macOS/Linux:
source ai-basics/bin/activate
upgrade pip


macOS Apple Silicon tip: if TensorFlow fails, try pip install tensorflow-macos
and (optional GPU) pip install tensorflow-metal
.

3) TensorFlow: tiny “learn y = 2x – 1” demo
What you’ll learn
- Build a minimal Keras model
- Train with gradient descent
- Make a prediction

print(“CUDA available?”, torch.cuda.is_available())
5) scikit-learn: quick classification (Iris + Logistic Regression)
What you’ll learn
- Train/test split
- Fit a model
- Evaluate accuracy + simple report

6) When to use which?
- TensorFlow/Keras: production pipelines, mobile (TF Lite), easy high-level APIs.
- PyTorch: research feel, very pythonic, flexible training loops, huge community.
- scikit-learn: classic ML (tabular data), fast baselines, preprocessing, metrics.
7) Common pitfalls & quick fixes
- Install errors → upgrade pip:
python -m pip install --upgrade pip
- PyTorch GPU mismatch → use CPU wheels (command above) first; add CUDA later.
- TensorFlow on Apple Silicon →
tensorflow-macos
(+tensorflow-metal
for acceleration). - Notebook kernel not seeing packages → install packages inside the same environment your Jupyter kernel uses (or
pip install ipykernel; python -m ipykernel install --user --name ai-basics
).