AAI-695 Applied machine learning
Machine learning,
from first principles.
My machine-learning notebooks build the algorithms in NumPy before reaching for scikit-learn and TensorFlow: curve fitting, gradient descent, decision trees, a neural network and K-means. Three of them run here, in your browser, so you can change the data and the settings and watch what happens.
- NumPy from scratch
- scikit-learn
- TensorFlow · Keras
Results
Accuracy reported in the notebooks
Notebook 01 · Lab
How complex should the model be?
Noisy samples of a cubic, y = 2x + 11x² + 3x³, fitted with polynomials of order 1 to 8, as in the notebook. The error on the training data keeps falling with order; the error on fresh data from the same source shows where extra order stops helping.
Data and fitted polynomial
Error against order
Mean squared error on a log scale.
Notebook 02 · Lab
Normal equation against gradient descent
The same straight line found three ways: in closed form, by batch gradient descent and by stochastic gradient descent, with an 80/20 train/test split. The notebook's data file is not in the repository, so this lab draws a sample shaped like it (y ≈ −3.90 + 1.19x, 97 points).
The fitted lines
Test error while training
Mean squared error on the 20 % test set, log scale.
Notebook 05 · Lab
K-means clustering, one step at a time
The notebook's algorithm: pick K points as starting centroids, assign every point to its nearest centroid, move each centroid to the mean of its points, and repeat until nothing changes. Step through it, or let it run.
Points and centroids
Choosing K: the elbow
Inertia, the sum of squared distances to the nearest centroid, for K = 1 to 8 (best of five starts). The bend marks a good K.
On MNIST digits
Mini-Batch K-means on the 60,000 training images, each cluster labelled with its most common digit
More clusters capture more ways of writing each digit, so labelling accuracy rises with K.
Beyond the labs
Networks, trees and a CAD project
These notebooks need their datasets and trained models, so they are summarised here with the results they reached.
Neural network from scratch
A two-hidden-layer (128–64) network written in NumPy, with backpropagation, classifying handwritten digits.
Decision trees and random forests
Titanic survival from class, sex, age and family aboard, with pruning and a random forest.
Diabetes prediction
A dense neural network predicting diabetes onset from eight clinical measurements in the Pima Indians dataset.
Material of 3D CAD parts
Part-level features extracted from the Autodesk Fusion 360 Gallery assemblies, cleaned, and used to compare four classifiers.
The notebooks
Eight notebooks on GitHub
Graduate coursework in applied machine learning. The datasets are not included in the repository; the README lists the files each notebook needs.
Polynomial regression and model order
Open → 02Normal equation vs gradient descent
Open → 03Decision trees, pruning and random forests
Open → 04Neural network from scratch: MNIST
Open → 05K-means clustering from scratch
Open → 06Diabetes prediction with Keras
Open → 07 · Phase 1CAD material prediction: data cleaning
Open → 07 · Phase 2CAD material prediction: model comparison
Open →Shared as a portfolio of applied analysis. If you are taking a similar course, please follow your institution's academic-integrity policy. Assignment prompts and third-party datasets remain the property of their original authors.