Intermediate: machine learning · The ML workflow, regression and classification · topic 22 of 62 · 25 min
What machine learning is
Explanation
Rules versus learning
Normal programming means writing rules: "if the amount is above ₹50,000 and the device is new, flag the payment". That works until there are thousands of cases the rules miss. Machine learning flips the job. You show the computer many past examples with the right answers, and an algorithm finds the rules, often patterns no human would write down.
The words you will use every day
- Example (or row, or sample): one case, such as one house or one payment.
- Features: the inputs that describe an example, such as area, city and age of the house. Often called X.
- Label (or target): the answer you want to predict, such as the price. Often called y.
- Model: the learned function that maps features to a prediction.
- Training: the step where the algorithm learns from labelled examples.
- Inference (or prediction): using the trained model on new examples.
The three main kinds
| Kind | What it learns from | Typical tasks |
|---|---|---|
| Supervised learning | Examples with the right answers (labels) | Regression: predict a number (house price, delivery minutes). Classification: predict a category (spam or not, which disease) |
| Unsupervised learning | Examples without labels | Clustering customers into groups, finding unusual records, reducing many columns to a few |
| Reinforcement learning | Rewards and penalties from trying actions | Game playing, robot control, some recommendation and ad systems |
Regression predicts a number on a scale. Classification predicts a label from a fixed set. "How many minutes will this order take?" is regression. "Will this order be late, yes or no?" is classification. The same business problem can often be framed either way.
Where ML is used in India today
- Payments: scoring UPI and card transactions for fraud risk in milliseconds.
- Lending: credit-risk models for small loans, using repayment history and other permitted data.
- Delivery and travel apps: estimating arrival times and demand by area and hour.
- Agriculture: estimating crop health from satellite images.
- Customer support: routing tickets in English, Hindi and other languages to the right team.
When NOT to use ML
Do not use ML when a simple rule works well, when you have very little data, when mistakes are dangerous and cannot be explained, or when nobody will maintain the model. A GST calculation should be a formula, not a model. Always ask: "What would a simple rule achieve?" If ML cannot clearly beat it, use the rule.
Common mistakes
- Starting with an algorithm instead of a clear question and a way to measure success. Fix: write the question and the metric first.
- Using features that will not exist at prediction time (for example, "delivered_at" to predict delivery time). Fix: for every feature, ask "will I know this when I predict?"
- Believing ML is magic. A model only finds patterns that are present in the data it was given.
Need help?
Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.
Try:
Watch the lesson
What machine learning is · 1/7
Welcome to machine learning. In this lesson: what it is, and when to use it.
Prefer a video by a teacher? Find free videos on “what is machine learning supervised unsupervised regression classification beginners” on YouTube ↗
In real life: Estimating delivery time
A grocery-delivery app shows "arriving in 18 minutes" when you order. Behind it is a regression model trained on lakhs of past orders. Its features include distance, time of day, number of items, the store's current load and the weather; its label is the actual minutes taken. A separate classification model may predict whether an order is likely to be late, so support staff can act early.
def simple_rule(distance_km):
"""A rule-based baseline: 10 minutes to pack + 4 minutes per km."""
return 10 + 4 * distance_km
print(simple_rule(2), simple_rule(5))Practice (0/3 done)
Which of these is a CLASSIFICATION problem?
Before any ML, build a rule-based baseline. Write flag_payment(amount, new_device, hour) that returns True when the payment looks risky: the amount is above 50000, OR it is from a new device between midnight and 5 a.m. (hour 0, 1, 2, 3 or 4). Otherwise return False.
Pick one task at a place you know (a hospital, a school, a shop, a bank). Describe it as an ML problem: the question, regression or classification, three features you would know at prediction time, the label, and a simple rule-based baseline.
Quick quiz
Read more (free)
Related help
Before this, learn
This topic builds on these. If something here feels new, open them first.
Related topics
- The ML workflow end to endThe ML workflow, regression and classification · same module
- Linear regression and least squaresThe ML workflow, regression and classification · same module
- Gradient descent: learning step by stepThe ML workflow, regression and classification · same module
- MLOps: from notebook to productionBuilding with generative AI, and MLOps
- Career paths: analyst, scientist, ML engineer, AI engineerEthics, privacy and careers
- k-nearest neighboursk-NN, decision trees and ensembles
Questions people ask about this
Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.
In a house-price model, what is the label?
Answer: The price
The label is the answer we want to predict.
Grouping shoppers into similar groups without any labels is…
Answer: Unsupervised learning (clustering)
No labels means unsupervised; grouping is clustering.
What is inference?
Answer: Using a trained model to predict on new examples
Training learns; inference applies what was learned.
When is ML a poor choice?
Answer: When a simple exact formula already solves the problem
A formula like GST needs no model; ML adds cost and risk for no gain.
To predict delivery time at order time, which feature must NOT be used?
Answer: The time the rider actually reached the door
That is only known after delivery, so it leaks the answer.
In scikit-learn, which method learns from training data?Related
Who mainly builds RAG and LLM-based product features?Related
Answer: AI engineer
AI engineers build on pre-trained models and APIs.
From Career paths: analyst, scientist, ML engineer, AI engineer
Features are salary in rupees and age in years, unscaled. What goes wrong in k-NN?Related
Answer: Distance is dominated by salary, so age is almost ignored
Large-valued features swamp the distance. Scale first.
From k-nearest neighbours
In a case-study round, what should you do first?Related
Answer: Clarify the business question and how success will be measured
Framing comes before methods.
Pass the quiz (60% or more) or mark this topic as done when you are ready.
Your progress is saved on this device only.
Next steps
- 4 more topics in “The ML workflow, regression and classification” before its exam: The ML workflow end to end, Linear regression and least squares, Gradient descent: learning step by step, Logistic regression and classification.
- Module 5 exam: The ML workflow, regression and classification · 12 questions · 25 min, without help. 5 topics of this module still to finish first.
- Then the next module, Evaluating models. 62 topics left in the course before the final exam.