- Foundation
- About 14 min
- 5 practice questions
What machine learning is: learning from examples instead of rules
Understand what machine learning means, how it differs from ordinary programming, and the basic vocabulary of data, features, labels, training sets and test sets.
If something looks wrong, please tell us.
Machine learning (ML) is the part of Artificial Intelligence that lets a computer improve at a task by studying examples, instead of following rules a programmer wrote by hand. It powers spam filters, voice typing, product suggestions and fraud alerts on bank cards. Competitive exams now ask what ML is, how it learns and which words describe its parts. This lesson gives you that foundation in plain language.
Rules versus examples
In ordinary programming, a person writes the rules and the computer applies them. Suppose you want to sort emails into spam and not spam. You could write rules such as 'if the subject contains lottery, mark it spam'. This works for a while, but spammers change their words, and you would need thousands of rules that keep going out of date.
In machine learning, you give the computer many emails that people have already marked as spam or not spam. A learning program studies these examples and finds the patterns by itself. The result is called a model: a set of learned patterns that can judge new emails it has never seen.
How machine learning builds a model
- Labelled examples Emails people have already marked as spam or not spam.
- Learning program Studies the examples and finds the patterns by itself.
- Model A set of learned patterns.
- Prediction The model judges new emails it has never seen.
| Item | Ordinary programming | Machine learning |
|---|---|---|
| Input | Data + hand-written rules | Data + correct answers (examples) |
| Output | Answers | A model (learned rules) that can give answers |
| When the world changes | A person rewrites the rules | Retrain the model on new examples |
| Good for | Clear, fixed logic (tax slabs, interest formulas) | Patterns too complex to write down (faces, speech, spam) |
Ordinary programming: data + rules give answers. Machine learning: data + answers give the rules (the model).
The basic vocabulary
- Data: the collection of examples the computer learns from, such as rows in a spreadsheet, photos or sound clips.
- Example (or record): one item in the data, such as one email or one house.
- Feature: a measurable property of an example that the model uses as input, such as the number of rooms in a house or the words in an email.
- Label (or target): the correct answer we want the model to predict for an example, such as 'spam' or the selling price.
- Model: what the learning program produces after studying the data; it maps features to a prediction.
- Training: the process of letting the program learn patterns from examples.
- Prediction (inference): using the trained model on a new example.
Worked example 1: features and labels
A fruit seller in Nashik wants a model that tells whether a mango is ripe. For each mango she records its weight in grams, its skin colour score from 1 to 10 and how soft it feels from 1 to 5, and then writes whether it was actually ripe. Here the features are weight, colour score and softness. The label is 'ripe' or 'not ripe'. One row such as (250 g, colour 8, softness 4, ripe) is one example. After training on a few hundred rows, the model can look at a new mango's three features and predict the label.
Training set and test set
If you test a student with the exact questions they practised, a high score proves little: they may simply have memorised the answers. ML has the same problem. So the labelled data is split into two parts before training. The training set is used to learn. The test set is kept hidden during training and used only at the end to check how well the model handles examples it has never seen. A common split is about 80% for training and 20% for testing, though the exact share can vary.
Splitting labelled data before training
- Labelled data Split into two parts before training.
- Training set Used to learn; commonly about 80%.
- Test set Kept hidden during training; commonly about 20%.
- Final check Shows how well the model handles examples it has never seen.
Worked example 2: a train-test split
A bank has 1,000 past loan applications, each labelled 'repaid' or 'defaulted'. It keeps 80% for training and 20% for testing. Working: training set = 80% of 1,000 = 800 applications; test set = 1,000 − 800 = 200 applications. After training, the model is given the 200 test applications without their labels. It predicts 180 of them correctly. Test accuracy = 180 ÷ 200 × 100 = 90%. This 90% is an honest estimate of how the model may perform on new applicants, because the model never saw these 200 during training.
Key takeaways
- Machine learning means learning patterns from examples rather than following hand-written rules.
- Features are the inputs; the label is the answer to be predicted; the model links them.
- Keep a test set aside and judge the model only on data it has not seen.
Check your understanding
-
1. What is the main difference between ordinary programming and machine learning?
- Machine learning needs no data at all
- In machine learning the computer learns the rules from examples, instead of a person writing them
- Ordinary programming can only be used on mobile phones
- Machine learning always gives perfect answers
Show answer
Answer: B. In ordinary programming a person writes the rules. In machine learning the program is given examples with correct answers and works out the patterns (the model) itself. ML needs data, runs on many devices and makes mistakes like any method.
-
2. A model predicts the selling price of used cars from their age, kilometres driven and engine size. What is the selling price here?
- A feature
- The test set
- The label
- The training algorithm
Show answer
Answer: C. The selling price is the answer the model must predict, so it is the label (target). Age, kilometres driven and engine size are the features used as inputs.
-
3. A school has 500 labelled answer sheets and keeps 20% aside as a test set. How many sheets are used for training?
- 100
- 250
- 480
- 400
Show answer
Answer: D. Test set = 20% of 500 = 100 sheets. Training set = 500 − 100 = 400 sheets.
-
4. Why is a model checked on a test set instead of on its training data?
- To see how it performs on examples it has never seen
- Because the training data is always wrong
- Because the test set is always larger
- To make the model train faster
Show answer
Answer: A. A model can memorise its training examples, so a score on them can look better than real performance. The test set is kept hidden during training, so it gives an honest estimate of how the model handles new data.
-
5. A model is shown 300 test examples and gets 255 right. What is its test accuracy?
- 75%
- 80%
- 85%
- 90%
Show answer
Answer: C. Accuracy = correct ÷ total × 100 = 255 ÷ 300 × 100 = 85%.
Sign in to keep track of the lessons you finish.