Lesson 01.01
Rules versus learning
You will be able to decide when to use ordinary programming rules and when to consider machine learning.
What you’ll do
- RelateStart with something familiar
- ExplainUnderstand the difference
- VisualizeSee the difference in action
- ExperimentTry it yourself
- ApplyThink like an AI engineer
- ReflectCheck your understanding
- Check3 questions, with feedback
Start with something familiar
Imagine you are building an online clothing shop.
Your manager gives you two tasks:
- Allow customers to find all white shirts.
- Allow customers to find outfits that look professional.
Both sound like fairly straightforward requests. But from a software engineering perspective, they are quite different problems.


For the first task, assuming the product data is accurate, you could write this:
products.filter(product => product.color === "white")You know exactly what condition the program should check.
But what rule would you write for an outfit that looks professional?
Does it need a jacket? Can someone wear sneakers? Does professional clothing look the same in every workplace?
You could create some rules, but defining every possible combination would be difficult.
This is where machine learning can be useful.
Some problems are easy to describe using rules. Others are easier to approach using examples.
Understand the difference
Two ways to teach a computer what to do
With traditional rule-based programming, you tell the computer which rules to follow.
With machine learning, you use examples and a learning algorithm to build a model that can make predictions.
Text description
Two parallel flows. Rule-based programming: developer writes rules, program rules are written explicitly, run the program with new input, result based on written rules. Machine learning: training examples provide patterns, training algorithm learns from examples, run the trained model with new input, prediction based on learned patterns.
You've just encountered three important terms.
Term 1 of 3
Model
A mathematical system that represents learned patterns and uses them to produce outputs.
For example, a model might estimate whether an outfit is suitable for an office.
Don't worry about the mathematics behind these terms yet. We will explore how training works in subsequent lessons.
See the difference in action
Can you teach a computer to recognize professional clothing?
Imagine that we create a very basic rule:
An outfit is professional if it includes a blazer.
It sounds reasonable initially. But does it always work?
Explore the following examples.
ExperimentTest a clothing classification rule
OUR PROGRAMMED RULE
if (hasBlazer) return "professional"Example 1 of 4
Business suit
Blazer, formal trousers and dress shoes
- Contains a blazer?
- Yes
- Classification
- Professional
- EXAMPLE LABEL FOR A BUSINESS-CASUAL WORKPLACE
- Professional
Our rule works in this example.
The suit matches the rule and the example workplace label.
This is a rule-testing experiment, not a trained machine learning model. The example labels depend on the chosen workplace.
What if we learned from examples instead?
Rather than writing hundreds of clothing rules, we could collect labelled examples and train a model to recognize useful patterns.
Text description
Suit and smart casual labelled professional; sportswear labelled casual. All examples feed a learning algorithm which produces a trained model.
The model may learn that a combination of features matters, rather than relying only on whether a jacket is present.
However, it can still make mistakes. Its behavior depends on the data, the training process and the problem it is designed to solve.
Machine learning does not magically turn subjective decisions into objective facts.
Try it yourself
Which approach would you choose?
You are now the engineer responsible for deciding how to build several application features.
For each scenario, select the most appropriate starting approach.
ChallengeChoose the approach
Challenge 1 of 4
Calculate a shopping basket total
Add product prices, apply the specified discount rules and calculate the final amount.
There isn't always a single universal solution to an engineering problem. But good engineers understand why they choose a particular approach.
Think like an AI engineer
Your first AI system-design challenge
You are building a customer support chatbot for an online shop.
A customer sends this message:
DesignAssign each responsibility
“Hi, I ordered a pair of shoes last week, but they're too small. Could I get my money back?”
The chatbot needs to understand the request, check whether the customer qualifies for a refund, perform any authorized action and explain the result.
Would you give all these responsibilities to a language model?
- Incoming customer message
Understand what the customer wants
Check the order and refund policy
Authorize and process the refund
Write a helpful response to the customer
- Customer receives a response
A simplified design exercise. Real systems also need authentication, authorization, error handling, testing and appropriate approval mechanisms.
Why this matters
Building AI applications is rarely about replacing all conventional software with a model.
A good AI engineer decides which responsibilities benefit from learned predictions and which responsibilities require explicit, reliable control.
You've just made your first AI architecture decision.
Check your understanding
A common misconception
MisconceptionMachine learning is more advanced than ordinary programming, so it should replace ordinary programming.
A better understandingMachine learning is useful for certain kinds of problems. Explicit rules are often more predictable, cheaper to run and easier to test when the desired behavior is clearly defined.
Final knowledge check
These questions use new scenarios rather than repeating the examples you've already seen.