Machine learning projects
Machine-learning projects I have built while learning the field. The code is on GitHub.
- Setting
- Self-directed, alongside my physics work
- Period
- 2026
- Stack
- Python, PyTorch, scikit-learn, Hugging Face Transformers, LangChain, ChromaDB, FastAPI
Dialogue summarisation with a fine-tuned T5
The goal was a model that turns a chat conversation into a one- or two-sentence summary. I fine-tunedt5-small on SAMSum, a dataset of messenger-style dialogues with human-written summaries, and wrapped the result in a small web app.
Approach
- Sampled 4,000 training and 500 validation dialogues from SAMSum (fixed random seed).
- Cleaned the text (line breaks, extra whitespace, HTML tags, lower case) and tokenised it with the T5 tokenizer: 512 tokens for dialogues, 150 for summaries.
- Fine-tuned with the Hugging Face
Trainerfor 6 epochs, batch size 8, weight decay 0.01 and 500 warm-up steps, on a CUDA GPU. - Served the model with FastAPI: a
POST /summarize/endpoint and a simple HTML front end, decoding with 4-beam search.
Results
| Epoch | 1 | 2 | 3 | 4 | 5 | 6 |
|---|---|---|---|---|---|---|
| Validation loss | 0.381 | 0.359 | 0.355 | 0.351 | 0.350 | 0.350 |
From the trainer log of the main run. Most of the improvement comes in the first two epochs.

Retrieval-augmented generation over PDFs
A question-answering pipeline over my own documents. Instead of asking a language model directly, it first finds the passages most relevant to the question and gives them to the model as context.
Approach
- Loaded PDFs and text with LangChain loaders and split them into 500-character chunks with 50 characters of overlap.
- Embedded the chunks with the sentence-transformer
all-MiniLM-L6-v2(384 dimensions) and stored them in a persistent ChromaDB collection with per-chunk metadata. - Wrote small classes for the embedding model, the vector store and the retriever.
- For a question, retrieved the top-k chunks and prompted an LLM served through the Groq API (
openai/gpt-oss-120b) to answer from that context.

Supervised learning projects
Three end-to-end classification problems on tabular data, each with cleaning, encoding, scaling, a train–test split and a comparison of several models.
Loan approval
Predicting whether a loan application is approved from 1,000 records with 20 columns. After imputing missing values and encoding categories, I compared logistic regression, KNN and Gaussian Naive Bayes, then added engineered features such as a squared credit score and log-transformed income.

Health-risk classification
Classifying 9,800 health records as healthy or unhealthy, comparing single models with ensembles. Random forest did best, with gradient boosting close behind.

Purchase intent
Predicting whether an online shopping session ends in a purchase, from 12,330 sessions. A pruned decision tree in a scikit-learn pipeline with class balancing reached F1 0.628, against a target of 0.55; a grid search over depth and leaf size gave 0.634.
| Project | Best model | Test result |
|---|---|---|
| Loan approval | Logistic regression, engineered features | Accuracy 0.88, F1 0.81 |
| Health risk | Random forest, 200 trees | Accuracy 0.938, recall 0.959 |
| Purchase intent | Pruned decision tree, grid search | F1 0.634 |
| Employee turnover | Logistic regression, L1 | Accuracy 0.870 |
Neural networks in PyTorch
Four networks written in PyTorch, each trained and evaluated on a held-out test set: feed-forward networks for a classification and a regression problem, a convolutional network for images and a recurrent network for text.

| Network | Task | Test result |
|---|---|---|
| Feed-forward | Date-fruit variety, 7 classes | Accuracy 95.6% |
| Feed-forward | Power-plant energy output (regression) | R² 0.935 |
| Convolutional, 10 epochs | CIFAR-10 images, 10 classes | Accuracy 72.5% |
| Recurrent, TF-IDF inputs | IMDB review sentiment | Accuracy 85.2% |
Machine learning from scratch
To understand what the libraries do, I wrote several algorithms in NumPy alone: KNN for classification and regression, linear regression by gradient descent and by ordinary least squares, and logistic regression by gradient descent. Alongside these are notebooks on clustering (K-means, hierarchical, DBSCAN), PCA, anomaly detection and SVMs.
Known gaps
The summariser has not been scored with ROUGE yet, so the losses above are its only evaluation.
The padding tokens in the labels are not masked out, so the loss values are not comparable to published SAMSum results.
The RAG similarity score is computed as 1 − distance on Chroma's default L2 distance, so it is not a true cosine similarity.
Creating the collection with cosine distance would fix this.
The recurrent network classifies TF-IDF vectors rather than word sequences, and the stop-word step strips some characters from words.
Visible in the preprocessing outputs of the notebook.