Learn Without Walls
← Back to Machine Learning Basics
Module 1 of 8 — Machine Learning Basics

What IS Machine Learning?

Rules vs learning — and why that difference changes everything

← Course Home Module 1 of 8 Module 2: Your First Dataset →
⏳ Loading Python… (first load ~15 seconds)

📌 Before You Start

What you need for this module:

Estimated time: ~45 minutes

What you’ll learn: The core idea behind ML, the 3 types of ML, and the workflow every ML project follows.

💡 The Big Idea

Traditional programming: You write the rules. The computer follows them.

Machine learning: You show the computer examples. The computer finds the rules.

Think about spam email. A traditional programmer might write: "if the email contains 'free money' or 'click here', mark it spam." This works — until spammers change their wording.

A machine learning approach shows the computer thousands of labeled examples (spam / not spam) and lets it figure out the patterns. When spammers adapt, you retrain with new examples. The rules update themselves.

This is the core shift: from explicit rules to learned patterns.

🧠 How It Works

The 3 Types of Machine Learning

🏫 Supervised Learning

You provide labeled examples (inputs + correct answers). The model learns to map inputs to outputs.

Examples: spam detection, image classification, predicting house prices.

🔍 Unsupervised Learning

You provide data without labels. The model finds hidden structure and patterns on its own.

Examples: customer segmentation, topic discovery in documents, anomaly detection.

🎲 Reinforcement Learning

An agent learns by trial and error, receiving rewards for good actions and penalties for bad ones.

Examples: game-playing AI (chess, Go), self-driving car navigation.

The ML Workflow

1
Collect Data — Gather labeled examples relevant to your problem. More diverse, high-quality data = better model.
2
Prepare Features — Clean missing values, encode categories, scale numbers. Raw data is rarely model-ready.
3
Train the Model — Show the model your training examples. It adjusts its internal parameters to minimize errors.
4
Evaluate on Test Data — Check how well the model performs on data it has never seen. This is the true measure.
5
Predict & Iterate — Use the model on new data. Collect feedback, improve, retrain. ML is a cycle, not a finish line.

ML You Already Use

▶️ See It In Code

This example shows the conceptual difference: a traditional rule-based classifier vs what the ML approach looks like. Run it and observe the output.

# ============================================ # TRADITIONAL PROGRAMMING: You write the rules # ============================================ def classify_email_traditional(email): email = email.lower() spam_words = ["free money", "click here", "winner", "congratulations you've won"] for word in spam_words: if word in email: return "SPAM" return "not spam" # Test it emails = [ "Win free money now! Click here!", "Meeting at 3pm tomorrow in Room 204", "Congratulations you've won a prize!", "Can you review my pull request?" ] print("=== Traditional Rule-Based Classifier ===") for email in emails: result = classify_email_traditional(email) print(f" [{result:^10}] {email[:50]}") print() print("=== The ML Approach (coming in Module 4!) ===") print(" Instead of writing rules, we'll show the model") print(" thousands of labeled examples like these:") print() training_examples = [ ("Win free money now!", "spam"), ("Meeting at 3pm tomorrow", "not spam"), ("Click here to claim your prize", "spam"), ("Your invoice is attached", "not spam"), ] for text, label in training_examples: print(f" Label: {label:^10} | Text: {text}") print() print(" The model learns the pattern. We'll build this in Module 4!")

This is a static display — the interactive exercise below lets you modify the code.

👋 Your Turn

The classify_email_traditional function currently only catches 4 types of spam phrases. Add 3 more spam phrases to the spam_words list and test them.

Try phrases like: "act now", "limited time offer", "you have been selected" — or make up your own!

Output will appear here after you click Run…
💡 Hint: Add strings to the list like "act now". The .lower() call means you don’t need to worry about capitalization — just use lowercase in your list.

☕ Brain Break — 2 Minutes

Think about 3 apps you use regularly. For each one, ask yourself:

If yes to any of the above — it almost certainly uses ML.

Examples to get you started: Spotify, TikTok, Google Maps, Gmail, Instagram, Duolingo, your phone’s keyboard. What does each one learn about you?

✅ Key Takeaways

🎉 Module 1 Complete!

You now understand the core idea behind machine learning. In the next module, we’ll work with a real dataset and learn how to explore it before building any model.

Continue to Module 2: Your First Dataset →

← Course Home Module 1 of 8 Module 2: Your First Dataset →