Code and Data
Copy a worked example. Change its data. Check the result.
Set up Python
Use Python 3.10 or newer. Run these commands in a new project folder.
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt
On Windows, activate with .venv\Scripts\activate.
Start with a full run
The examples use small synthetic data. They need no private datasets or paid API keys.
python q4_ml_coding_01.py
python q4_ml_coding_02.py
python q3_deep_learning_08.py
The first scripts fit linear and logistic models. The last trains a small PyTorch model.
The PyTorch run uses CPU or CUDA when present. Its training accuracy does not prove test accuracy.
Read helper examples
A file that only defines functions may print nothing. Call its function with the input shapes shown in the lesson.
Some code uses pandas, scikit-learn, or PyYAML. Install the listed packages before running it.
Numerical values may vary with library versions. Tests check results with a tolerance.
ML Fundamentals
Examples 1 to 5
- focal_loss, best_threshold
- sigmoid, fit_logreg
- Worked numerical example
- target_encode_oof
- ece, fit_temperature
Examples 6 to 6
Statistics and Probability
Examples 1 to 2
Deep Learning and LLMs
Examples 1 to 5
Examples 6 to 8
ML Coding from Scratch
Examples 1 to 5
- fit_linear_gd, fit_linear_closed
- sigmoid, LogisticRegression
- sq_dists, kmeans_pp_init
- pairwise_sq_dists, knn_predict
- log_softmax, softmax
Examples 6 to 10
Experimentation and Causal Inference
Examples 1 to 5
Examples 6 to 7
Learning Theory
Examples 1 to 3
Statistical Inference
Examples 1 to 4
Probability and Information Theory
Examples 1 to 5
Optimization
Examples 1 to 5
Linear Algebra and Matrix Calculus
Examples 1 to 5
- Worked numerical example
- Worked numerical example
- Worked numerical example
- Worked numerical example
- softmax