24 topics

Machine learning help, including why 99% accuracy can be worthless

A fraud detector that flags nothing at all is 99.8% accurate, because 99.8% of transactions are not fraud. That single example is where most machine learning courses really begin, and students who skip past it end up reporting a number that says nothing about whether the model works. Choosing the metric is not a formality before the modelling — it is the modelling decision.

Where students get stuck

My accuracy is high but the model is apparently bad

Look at the class balance first. If one class is 95% of the data, predicting that class every time scores 95% while learning nothing. Build the confusion matrix and read the two error cells, not the diagonal. Then pick the metric that matches the cost of being wrong: recall when a missed positive is expensive, such as a missed tumour, precision when a false alarm is expensive, such as a wrongly blocked account. F1 splits the difference when neither dominates. Report the metric you chose and say why.

I don't understand what the validation set is for

The test set answers one question once: how does this model do on data it has never seen. Every time you look at it and change something, you have leaked information from it into your model, and it stops being an honest estimate. The validation set exists to absorb that. You tune hyperparameters against validation as many times as you like, then touch the test set at the very end, ideally once. If your test score is far worse than validation, you tuned too aggressively against validation itself.

Gradient descent: what is the gradient, physically?

It is the direction in parameter space where the loss increases fastest, so you step the other way. Picture the loss as a surface over your weights. The gradient is the uphill arrow at the point you are standing on, and the learning rate is your stride length. A stride that is too large overshoots the valley and the loss oscillates or explodes; too small and it crawls. That is why the first diagnostic when training misbehaves is always the learning rate, not the architecture.

Why does penalising large weights reduce overfitting?

Large weights are how a model produces a wildly wiggly boundary that bends around individual training points. Adding the size of the weights to the loss makes that wiggling cost something, so the fit only bends where the data really demands it. L2 shrinks weights smoothly toward zero and keeps every feature slightly involved. L1 drives some weights exactly to zero, which is why it doubles as feature selection. Higher penalty means simpler model, more bias, less variance.

Bias and variance keep swapping in my head

Tie each to a symptom you can observe. High bias means the model is too simple to capture the pattern, and you see it as bad training error and bad validation error together — a straight line through a curve. High variance means the model memorised the training set, and you see it as excellent training error with poor validation error. The gap between the two curves is the variance. Once you name which one you have, the fix is obvious: more capacity for bias, more data or regularisation for variance.

What's covered

Machine Learning topics you can work through with a tutor, generate practice on, or turn into flashcards and a study plan.

Foundations

  • Supervised, unsupervised, and reinforcement learning
  • Features, labels, and the design matrix
  • Train, validation, and test splits
  • Cross-validation
  • The bias–variance tradeoff

Core models

  • Linear and polynomial regression
  • Logistic regression and decision boundaries
  • Decision trees and random forests
  • k-nearest neighbours and k-means clustering
  • Support vector machines
  • Naive Bayes

Training and optimisation

  • Loss functions: MSE and cross-entropy
  • Gradient descent and learning rates
  • L1 and L2 regularisation
  • Feature scaling and normalisation
  • Hyperparameter search

Neural networks

  • Perceptrons and activation functions
  • Backpropagation
  • Convolutional networks for images
  • Overfitting, dropout, and early stopping

Evaluation and ethics

  • Confusion matrices, precision, and recall
  • ROC curves and AUC
  • Data leakage
  • Bias in training data and fairness

Machine Learning questions

How much maths do I need before this makes sense?

Partial derivatives for gradient descent, matrix multiplication for the forward pass, and basic probability for anything Bayesian. If one of those is the actual gap, a session can be spent on that instead, which is usually faster than pushing on through the model material.

My notebook throws an error I don't understand. Can it help?

Share your screen and it reads the traceback with you. Shape mismatches and silently misaligned indices cause most of them, and both are much easier to find with the array shapes visible than described from memory.

Will it write my model code for the assignment?

It is set up to work through the design with you — which model suits the data, why your loss is not falling — rather than hand back a finished notebook. Submitting generated code is a question for your school's academic integrity policy, and it also leaves you unable to defend a single choice in the write-up.

Can it help me interpret a result I already got?

Yes, and that is often the most useful session. Bring the confusion matrix or the learning curves, put them on screen, and talk through what the shape of the gap between training and validation is telling you.

Stuck on machine learning right now?

Talk it through out loud, share your screen, and watch it worked out step by step on a whiteboard.

Start free — no card