D2OECD AILit — Designing AI, Competency 2

Rule-based vs Machine Learning

Two Approaches to AI

Not all AI learns from data. Some AI follows hard-coded rules written by programmers. Understanding when to use rules vs machine learning is a key design decision. Rules work great for well-defined problems; ML shines when patterns are complex and data is plentiful.

Rules vs ML Chatbot

See how a rule-based chatbot and an ML-based chatbot respond differently to the same questions.

Test 1/5
💬 Hello, how are you?
Rule-Based
Hi! How can I help you today?
ML-Based
Hey there! I’m doing great, thanks for asking! What can I help you with today?

When to Use Which

Rule-based AI works best when: rules are clear and finite, edge cases are few, the domain is narrow, and explainability is critical (e.g., tax calculations, compliance checks).

Machine Learning works best when: patterns are complex, data is abundant, the task involves perception (vision, language), and the problem changes over time.

Hybrid approaches combine both: ML handles the complex parts while rules enforce business logic and safety constraints.
The Right Tool for the Right Job
Don’t use ML when simple rules work. Don’t write 10,000 rules when ML can learn patterns from data. Good AI designers choose the approach that fits the problem.

Check Your Understanding

1. When is rule-based AI better than ML?
2. What does ML need to work well?
3. What is a hybrid AI approach?

Answer all questions. You need 70% to pass.