Skip to content

Intermediate: machine learning · The ML workflow, regression and classification · topic 22 of 62 · 25 min

What machine learning is

Explanation

Machine learning (ML) is a way to make a computer learn a pattern from examples instead of writing every rule by hand. You give it features (the inputs) and, for supervised learning, labels (the right answers), and it learns to predict the label for new cases. Use ML when the pattern is real but too complex to write as rules.

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.

Think of it like this: Teaching a child to recognise mangoes does not start with a rulebook ("oval, yellow-green, 8 to 12 cm"). You show many mangoes and many other fruits, and the child learns. ML learns from examples in the same way, and like a child, it learns the wrong lesson if the examples are poor.

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

KindWhat it learns fromTypical tasks
Supervised learningExamples with the right answers (labels)Regression: predict a number (house price, delivery minutes). Classification: predict a category (spam or not, which disease)
Unsupervised learningExamples without labelsClustering customers into groups, finding unusual records, reducing many columns to a few
Reinforcement learningRewards and penalties from trying actionsGame 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

Machine learning

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.

python
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))
Shows 18 30. Any ML model must beat a rule like this to be worth building.

Practice (0/3 done)

Task 1 · Question

Which of these is a CLASSIFICATION problem?

Task 2 · Code · Python

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.

Task 3 · Practice

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

Question 1

1.In a house-price model, what is the label?

Question 2

2.Grouping shoppers into similar groups without any labels is…

Question 3

3.What is inference?

Question 4

4.When is ML a poor choice?

Question 5

5.To predict delivery time at order time, which feature must NOT be used?

Read more (free)

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

Answer: fit

fit(X, y) trains the model; predict uses it.

From The ML workflow end to end

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.

From Portfolio, projects and interviews

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

  1. 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.
  2. Module 5 exam: The ML workflow, regression and classification · 12 questions · 25 min, without help. 5 topics of this module still to finish first.
  3. Then the next module, Evaluating models. 62 topics left in the course before the final exam.

← Previous: Visualising data honestly