Rules or machine learning?
Rules apply instructions that people define. Machine learning fits a model to examples so it can make predictions about new cases. Choosing between them starts with the problem you need to solve.
The café discount: use a rule
A café gives every customer a 10% discount. For a bill of ₹200, the discount is ₹20 and the final price is ₹180. The calculation is known in advance: multiply the bill by 0.10, then subtract the result.
You do not need past receipts to learn this policy. A written rule is easier to check and gives the same result for the same inputs. If the café changes its policy, you update the rule.
The photo sorter: learn from examples
Now imagine sorting photos into cats and dogs. The animals appear at different angles, under different lighting, and against different backgrounds. Writing a complete set of reliable visual rules by hand is much harder.
A machine learning approach uses labeled examples during training. The model learns patterns associated with the labels, then estimates a label for a new photo. Good performance on the training photos is only a starting point: you also need to test photos the model did not train on.
| Question | Written rules | Machine learning |
|---|---|---|
| Where does the behavior come from? | Instructions defined by people | Patterns fitted from training data |
| A good example | Apply a fixed discount | Recognize an object in a photo |
| How do you improve it? | Revise the logic and test cases | Improve data, model choices, and evaluation |
| What can go wrong? | A missing case or incorrect rule | Unrepresentative data, overfitting, or changed conditions |
When is a rule a better starting point?
Use a rule when the policy or calculation is explicit, when you can enumerate the relevant cases, or when a requirement must be enforced exactly. A minimum-age restriction, for example, should be applied as a policy rather than guessed from previous decisions.
Rules can still be complex, and they can contain mistakes. Their advantage is that the intended logic can be written down and tested directly. Begin with the simplest approach that meets the requirement.
When does machine learning help?
Consider a learned model when the task involves patterns that are difficult to specify, suitable data is available, and you can measure the cost of errors. Predicting demand or categorizing varied documents may be candidates. A model is useful only if its results improve the real task enough to justify its costs and limitations.
“We have lots of data” is not a complete reason to use machine learning. Ask whether the data represents the cases you expect, whether the target is meaningful, and whether you can compare the model against a straightforward baseline.
Can you combine both?
Yes. A system might use a model to identify potentially suspicious transactions and written rules to enforce spending limits. The learned component estimates a pattern; the rule enforces a policy. Clear boundaries make the system easier to evaluate.
A fixed 10% discount needs a calculation. Recognizing varied photos may benefit from learning. Choose the method that fits the task.
Your next decision
Before reaching for an AI tool, write one sentence describing the outcome you need. Can an explicit instruction produce it reliably? If not, what examples would help a model learn—and how would you check its results?
Turn the idea into understanding.
Try short interactive challenges with hints, then revisit the essentials in notes and cue cards.
Try an AI lesson