Skip to main content

Course

Machine Learning

NewAI & ML

Machine learning, made visual

CodeWithPurpose lessons that explain core ML ideas through live demos and clear visuals. Click any topic to explore — no setup required.

0%

Ready when you are

Go at your own pace. Your progress saves on this device.

Syllabus

What you'll learn

Take it one chapter at a time. A short quick check at the end of each one opens the next.

Part 1

What Machine Learning Is

What the field actually does, what data has to look like, and what it means for a model to learn.

  1. What Is Machine Learning?Some problems cannot be solved by writing rules, no matter how many you write. Stack rules one at a time and watch each one buy you less than the last.
  2. Features and LabelsData does not arrive ready to learn from. See how two measurements that are each useless on their own combine into one that works.
  3. How a Model LearnsDrag one number, watch total error rise and fall, and find the bottom of the bowl yourself.

Part 2

Getting It Right

The two questions you can ask, why you hold data back, and the failure that catches everyone.

  1. Classification vs RegressionCategories or numbers? The line between them is a choice you make — and chopping a number into categories can make your accuracy look better while the model gets less useful.
  2. Train/Test SplitA model graded on the data it studied will always flatter itself. Re-roll the split and watch the score you would have reported swing by six points.
  3. Overfitting and UnderfittingThe central failure of machine learning. Add bends to a curve until it passes through every training point — and gets dramatically worse at everything else.
  4. Measuring a ModelAccuracy is the first number everyone reaches for and the first one that will mislead you. Drag a decision threshold and watch precision and recall trade against each other.

Part 3

Models You Can Picture

Three real algorithms, each simple enough to run by hand on paper — and each wrong in its own instructive way.

  1. k-Nearest NeighboursA model that learns nothing at all, and still beats a careless one. Move a student across the chart and watch five neighbours vote on their future.
  2. Decision TreesTwenty questions, asked in the right order. Pick the split yourself, see how much confusion each one clears, and find out why the greedy choice is not always the best one.
  3. Random ForestsOne deep tree memorises its training data. A forest of them, each deliberately handicapped, does not. Add trees one at a time and watch the boundary settle down.

Part 4

Making the Number Honest

How to evaluate a model beyond a single score.

  1. Cross-ValidationChapter five left you with a score that was partly luck. Rotate which slice is held back, average the five results, and watch a lottery ticket turn into a measurement.
  2. Data LeakageThe bug that makes your model look brilliant in testing and useless in production. Four realistic pipelines, one of them honest — find the leak before you scroll to the answer.
  3. Class ImbalanceWhen one answer is rare, accuracy stops meaning anything and most fixes quietly make the model worse. Rebalance a fraud dataset and watch what each repair actually costs.
  4. BaselinesBefore you can say a model is good you need something for it to be better than. Race four models against a rule a child could write, and find out which ones lose.

Part 5

Learning Without Labels

Every model so far needed somebody to write the right answer down first. Three that do not, and the new ways each of them can be wrong.

  1. ClusteringEvery model up to here needed somebody to write the right answer down first. Step a k-means run one move at a time and watch the groups it settles on change with where you started it.
  2. Dimensionality ReductionForty columns is not forty times more information than one, and the extra ones cost you accuracy. Rotate the line a cloud of points is flattened onto and watch how much of the spread survives.
  3. Anomaly DetectionThe cases you care about most are the ones you have almost no examples of, which is exactly why training a classifier on them fails. Move a cut-off and watch caught fraud trade against false alarms.

Part 6

How the Fitting Actually Works

Under the fit is a search, and under the search is a step size. What the optimiser is doing, what it costs, and what happens to a model after it ships.

  1. Feature ScalingDistance arithmetic does not know that one column is in years and another in pounds, so the big column quietly decides every answer. Rescale the axes and watch a nearest-neighbour verdict flip.
  2. Gradient DescentTrying every slope works with one parameter and never works again after that. Set a step size and watch the same search converge, crawl, or throw itself off the hill entirely.
  3. RegularisationOverfitting has a fix that is not "collect more data", and it works by charging the model rent on its own complexity. Turn the penalty up and watch coefficients fall over one at a time.
  4. Neural NetworksA neural network is not a brain. It is the straight-line fit you already understand, stacked, with one small bend between the layers — add hidden units one at a time and watch a flat boundary learn to curve.
  5. From Notebook to ProductionA model that scored well on Tuesday's data is not a system, and the gap between the two is where most projects quietly die. Age a deployed model month by month and watch the score decay before anyone files a bug.

Open source

Your lesson goes here

Every lesson here was written by a student. Propose your own topic, or fix one that confused you. Drafts stay invisible until they are ready, so nothing you start can break the site.

Keep building your ML foundation

These lessons are part of CodeWithPurpose's free learning library — built by students, for students, everywhere.