We're making some improvements. Some features may be temporarily unavailable.
beginner20 min

Machine Learning Basics

How machines learn from data — supervised, unsupervised, and reinforcement learning

What is Machine Learning?

Machine Learning (ML) is a subset of AI where computers learn patterns from data without being explicitly programmed for every scenario.

Traditional Programming vs Machine Learning

Traditional Programming: Rules + Data → Answers
Machine Learning: Data + Answers → Rules

Instead of writing the rules, you provide examples and the machine learns the rules on its own.

Types of Machine Learning

Supervised Learning

The model learns from labeled data — each training example has an input and the correct output.

Examples:

  • Spam detection (email → spam/not spam)
  • House price prediction (features → price)
  • Image classification (image → "cat" or "dog")

Think of it like learning with an answer key.

Unsupervised Learning

The model finds patterns in unlabeled data — no correct answers provided.

Examples:

  • Customer segmentation (grouping similar shoppers)
  • Anomaly detection (finding unusual transactions)
  • Recommendation systems ("users like you also bought...")

Think of it like finding patterns without a teacher.

Reinforcement Learning

The model learns by trial and error — receiving rewards for good actions and penalties for bad ones.

Examples:

  • Game-playing AI (AlphaGo, chess engines)
  • Robot navigation
  • Self-driving cars

The ML Workflow

  1. Collect Data — Gather relevant, quality data
  2. Prepare Data — Clean, format, and split into training/test sets
  3. Choose Model — Select an algorithm appropriate for the problem
  4. Train — Feed training data to the model
  5. Evaluate — Test on unseen data to measure accuracy
  6. Deploy — Use the model in real applications

Simple Example in Python

Here's how a simple ML model works conceptually:

Simple Pattern Learning

Output
Run your code to see output here

This is a very simple example, but it demonstrates the core idea: learn patterns from data, make predictions on new data.

Check Your Understanding

In supervised learning, what does the training data include?

Check Your Understanding

Which type of learning uses rewards and penalties?

Questions & Discussion

Sign in to ask a question or join the discussion.

Loading comments...