This repository contains practical assignments for ELE 888 (TMU Intelligent Systems): pattern classification, neural networks, and unsupervised learning in Python.
Author: Arian Fooladray · Term: Winter 2026 (where noted)
- Python 3.10+ recommended
- Common packages:
numpy,matplotlib - Lab 2, 1 (sklearn):
scikit-learn - Lab 4 (images):
imageioandPillow—pip install numpy matplotlib scikit-learn imageio pillow
All commands below are written for a shell with the repository root as the working directory unless cd is shown.
| Lab | Topic | What you get | Representative results* |
|---|---|---|---|
| 1 | Bayesian decision theory (Iris, 1D Gaussian) | Posteriors, Bayes decisions, cost-sensitive thresholds, PDF plots | Full analysis for sepal length & width; mu1 / mu2 thresholds; classification tables and risk for listed test x; saved PNGs per feature |
| 2 | Linear discriminant functions (Iris) | MSE/Adaline (batch GD), 2D decision plot, 3-class OVR + confusion | Binary (4D): 100% test on 0v1, 0v2, 1v2; 3-class OVR: ~80% test (typical; Versicolour vs Virginica is hardest) |
| 3 | 2-2-1 MLP, XOR, batch backprop, tanh | Convergence, learning curve, input/hidden decision surfaces | XOR learned; report example: converged in 2251 epochs (exact epoch count depends on random init) |
| 4 | K-means (Lloyd) on RGB; image quantization | J vs iteration, means over stages, RGB scatter, labeled images, Xie–Beni (c=5) | Part 1: c=2 with fixed inits; Part 2: c=5, two random runs; figures under lab4/figures/ |
*Exact numbers for Labs 1–2 and 4 re-run are deterministic where seeds are fixed; Lab 3 epoch count can vary with weight initialization.
Script: lab1/lab1_bayes_classifier.py
Idea: Classify Setosa vs Versicolour using a single feature at a time and Gaussian class-conditional likelihoods. Computes priors, posteriors, discriminant, optimal thresholds (equal and asymmetric costs), and risk under a high-penalty cost matrix.
cd lab1
python lab1_bayes_classifier.pyCloses or saves the matplotlib windows to finish; plots are written to the current directory, e.g. lab1_sepal_length_(cm)_analysis.png, lab1_sepal_width_(cm)_analysis.png.
- Console: priors, means/stds, thresholds mu1 (equal cost) and mu2 (high penalty for misclassifying Versicolour as Setosa), classification table for the lab’s test feature values, risk table, and a short feature comparison.
- Figures: class-conditional densities, thresholds, and data ticks at the base.
Script: lab2/lab2_linear_discriminant.py
Idea: Linear discriminants
cd lab2
python lab2_linear_discriminant.pyHeadless (no GUI; writes PNGs only):
python lab2_linear_discriminant.py --save-only- Console: train/test accuracies for three binary problems (4 features), 2D petal-only experiment, and 3-class OVR; confusion matrix for the test set.
- Figures:
lab2/figures/— learning curves, 2D decision region, OVR learning curves, confusion heatmap.
cd lab2
pdflatex lab2_report.texScript: lab3/lab3_xor.py
Idea: Four XOR patterns in eta=0.1).
cd lab3
python lab3_xor.pyHeadless + save figures to lab3/figures/:
python lab3_xor.py --save-only- Console: final weights, epoch count, LaTeX table snippet for the report.
- Figures (with
--save-onlyor after closing windows): learning curve, decision surfaces in input space and in hidden-unit space (seelab3_report.tex).
cd lab3
pdflatex lab3_report.texScript: lab4/lab4_kmeans.py
Idea: Lloyd k-means on pixels in
Place house.tiff in lab4/, or create a stand-in:
cd lab4
python create_house_image.pycd lab4
python lab4_kmeans.pyHeadless:
python lab4_kmeans.py --save-only- Console: progress, final J, mean evolution, Xie–Beni for the two c=5 runs.
- Figures:
lab4/figures/— J vs iteration, means at stages, RGB scatters, reconstructed (quantized) images.
cd lab4
pdflatex lab4_report.texele888/
README.md ← this file
lab1/lab1_bayes_classifier.py
lab2/lab2_linear_discriminant.py, lab2_report.tex, figures/
lab3/lab3_xor.py, lab3_report.tex, figures/ (after run)
lab4/lab4_kmeans.py, create_house_image.py, lab4_report.tex, figures/
Each labN/ may also keep a local README_LAB3.md / DEMO_*.md with extra demo notes; the table above is the short version.