What is machine learning, and when would you build a rule-based system instead?
Machine learning means a program learns the link between inputs and an outcome from past examples instead of a person writing the logic. Build rules when the logic is known, stable and must be exactly right, like a refund policy. Use machine learning when the pattern is real but too tangled for anyone to write down.
Interviewers ask this to see whether you reach for a model by reflex.
Take Indian Railways. The refund on a cancelled ticket is set by policy: a deduction that depends on the class of travel and the hours left before departure. The rules are written down and the right answer is never in doubt. A model trained on past refunds could only approximate them, and when the policy changes you would retrain instead of editing one line. Rules win.
Now ask: will a ticket at WL 37 on a Diwali-week train to Patna get confirmed? It depends on the route, the quota, the days left, how many people usually cancel on that train in that season, and how those interact. Nobody can write that as if-else conditions, but millions of past bookings with known outcomes contain the pattern. Machine learning learns the mapping from examples when you have labelled history but cannot state the logic.
A quick test you can say out loud:
- Can an expert write the rule completely? Then write it.
- Is there enough history with known outcomes? If not, a model has nothing to learn from.
- Can the business live with being wrong some of the time?
- Does the pattern shift? Then you need a way to keep the model current.
The misconception is that machine learning is a smarter kind of rule. It is an estimate that will be wrong on some fraction of cases. Often the two sit together: rules as guardrails around a model.
- The railway changes its refund policy next month. What happens to a model that learned the old refunds from history?
- You have rules today and a model that beats them offline. How would you combine the two instead of replacing one with the other?
- What would make you abandon a machine learning project in its first week?