Lesson 02 · 9 min read

Machine Learning Basics

Machine learning teaches a computer to recognize patterns in examples. The result is a model that can make useful predictions on new data.

How a model learns

A dataset contains examples. Each example may include features—measurements such as price, size, or word count—and sometimes a label, the answer we want the model to learn.

During training, an algorithm adjusts the model so its predictions become closer to known answers. We then test it on unseen data to check whether it learned a general pattern.

01CollectGather representative data.
02TrainFind patterns in examples.
03EvaluateTest on unseen data.

Common learning styles

  • Supervised: examples include the correct label.
  • Unsupervised: the model finds structure without labels.
  • Reinforcement: an agent learns through feedback and rewards.
Remember

Good data beats clever guesses.

Use representative data and review important outputs.

Example

const examples = [{ hours: 1, score: 55 }, { hours: 2, score: 65 }];
const predictedScore = 45 + (hours * 10);