AI Computer Institute
Expert-curated CS & AI curriculum aligned to CBSE standards. A bharath.ai initiative. About Us

What is Machine Learning? Teaching Computers to Learn

📚 Introduction to Machine Learning⏱️ 24 min read🎓 Grade 9
✍️ AI Computer Institute Editorial Team Updated: August 2026 CBSE-aligned · Peer-reviewed · 24 min read
Content curated by subject matter experts with IIT/NIT backgrounds. All chapters are fact-checked against official CBSE/NCERT syllabi.

Suppose your cousin wants to sell her three-year-old bicycle on OLX. She has no idea what price to list. So she does something very natural: she looks up five other bicycles that recently sold in her area, notes their age and selling price, and tries to spot a pattern. A brand-new-looking bicycle sold for more, an older one sold for less. From those five examples, she guesses a fair price for her own bicycle. She never wrote down an exact formula before looking at the data — the data itself taught her the pattern.

That is, in miniature, exactly what machine learning is. This chapter builds the idea from that one bicycle-pricing problem, turns it into a real (if tiny) working algorithm you could type into Python, and only then gives you the formal definition — because the definition means nothing until you have built the thing it describes.

Two Ways to Solve the Same Problem

Imagine you are asked to write a program that prices a used bicycle. There are two completely different ways to approach this.

Approach 1: Traditional programming. You, the programmer, sit down and think hard about bicycles. You write explicit rules: "if the bicycle is less than 1 year old, price it at Rs 9,000. If it is between 1 and 2 years old, subtract Rs 900. If the gear system is missing, subtract another Rs 500." You are supplying both the rules and the data (well, no data at all, actually — just your own assumptions), and the computer blindly executes your rules.

This works, until it doesn't. What if bicycles in Mumbai depreciate faster than bicycles in Shillong because of monsoon rust? What if the real relationship between age and price isn't a straight subtraction at all? You would have to notice this yourself, then go back and rewrite your rules. The computer never learns anything; you do all the learning, then encode your conclusions as fixed instructions.

Approach 2: Machine learning. Instead of writing rules yourself, you show the computer examples — real bicycles with their real ages and real selling prices — and you write a program that searches for a rule that fits those examples well. The computer is not told "subtract Rs 900 per year." It is told "here are five bicycles and what they actually sold for; find numbers that make good predictions." The rule is discovered from data, not dictated by the programmer.

This distinction is the entire chapter in one paragraph: in traditional programming, a human supplies the rules and the computer applies them to data; in machine learning, a human supplies data (and a way to measure "good"), and the computer searches for the rules. Everything else in this chapter is working out, concretely, what "search for the rules" actually means in code.

A Formal Definition, Now That You've Seen the Idea

The term "machine learning" was coined in 1959 by Arthur Samuel, an IBM researcher who built a checkers-playing program that improved by playing games against itself and adjusting its strategy based on which moves led to wins. Samuel described machine learning as giving computers "the ability to learn without being explicitly programmed" — which is exactly the Approach 2 idea above: no one hand-coded the winning checkers strategy; the program discovered it from experience.

A more precise, textbook-standard definition, due to the computer scientist Tom Mitchell, is worth memorising for CBSE exam purposes because it names three separate ingredients:

"A computer program is said to learn from experience E, with respect to some task T and performance measure P, if its performance at task T, as measured by P, improves with experience E."

Mapped onto the bicycle example: the task T is "predict a bicycle's fair price from its age." The experience E is the five (age, price) examples you collected. The performance measure P is how close the predictions come to the real prices — and, crucially, the program's predictions get better (P improves) as you let it work with more of that experience E. If any one of these three pieces is missing — no task, no data to learn from, or no way to measure whether it's improving — you don't have machine learning. You may still have a useful computer program, but it isn't one that learns.

Building Your First Model, By Hand

Let's make this concrete with real numbers. Here are five bicycles your cousin found listed on OLX, along with their age and actual selling price:

BicycleAge (years)Sold for (Rs)
A18,200
B27,300
C36,100
D45,400
E54,300

Looking at this table, prices clearly fall as age increases, and roughly by a similar amount each year. So it's reasonable to guess that the relationship is close to a straight line: a brand-new bicycle (age 0) is worth some starting price, and every year of age subtracts a roughly fixed amount. In algebra, that's:

predicted_price = b - m × age

Here, b is the price of a brand-new bicycle (age 0) and m is how many rupees the price drops per year of age. This equation is called the model — a compact mathematical description of the pattern we believe connects age to price. Notice it has exactly two unknown numbers, b and m. Machine learning, at its core, is a search for the values of numbers like these that make the model's predictions match reality as closely as possible.

Let's fix b = 9,000 (a fair guess for a new bicycle's price in this data set) and try two candidate values for m: 900 and 700. Which is the better choice?

Measuring How Wrong a Guess Is: The Loss

To compare m = 900 against m = 700, we need a precise, numerical way to say "this guess is better than that guess." The natural first step is to compute, for each bicycle, the error: actual price minus predicted price.

With m = 900, b = 9,000:

AgeActualPredicted (9000 − 900×age)Error
18,2008,100+100
27,3007,200+100
36,1006,300−200
45,4005,4000
54,3004,500−200

With m = 700, b = 9,000:

AgeActualPredicted (9000 − 700×age)Error
18,2008,300−100
27,3007,600−300
36,1006,900−800
45,4006,200−800
54,3005,500−1,200

Just glancing at these two tables, m = 700 is clearly worse — its errors are bigger. But we want a single number that summarises "how wrong overall," not five separate errors, so we can compare any two candidate models at a glance. Simply adding up the errors is a bad idea: in the m = 900 table, the errors are +100, +100, −200, 0, −200, and these add up to 0 — the positive and negative errors cancel out, making a genuinely imperfect model look perfect. To stop errors from cancelling, we square each error before adding (squaring always produces a positive number, and it also punishes large mistakes much more heavily than small ones, which is usually what you want). This sum of squared errors is called the loss — a single score where lower always means a better-fitting model.

For m = 900: 100² + 100² + (−200)² + 0² + (−200)² = 10,000 + 10,000 + 40,000 + 0 + 40,000 = 100,000.

For m = 700: (−100)² + (−300)² + (−800)² + (−800)² + (−1,200)² = 10,000 + 90,000 + 640,000 + 640,000 + 1,440,000 = 2,820,000.

One important thing to notice: these two numbers, 100,000 and 2,820,000, are not rupee amounts, even though every number that went into them was in rupees. Because we squared a rupee difference, the result is technically in "rupees squared" — a unit with no everyday meaning. Don't read 100,000 as "one lakh rupees of error"; the loss is only ever useful for comparison, not as a real-world quantity. All that matters is that 100,000 is much smaller than 2,820,000, so m = 900 is the far better slope of the two.

Letting the Computer Search: A Brute-Force Learning Algorithm

Trying two candidate values of m by hand told us 900 beats 700, but is 900 actually the best possible slope? Maybe 850 is even better, or 950. Checking every possibility by hand would take forever — but a computer can check hundreds of candidates in a fraction of a second. This is the moment where "learning" stops being something a human does with a pencil and becomes something a program does automatically. Here is the simplest possible learning algorithm: try every candidate slope in a range, compute its loss, and remember whichever one produced the lowest loss.

data = [(1, 8200), (2, 7300), (3, 6100), (4, 5400), (5, 4300)]
b = 9000

best_m = None
best_loss = None

for m in range(700, 1101, 50):        # try 700, 750, 800, ..., 1100
    total_loss = 0
    for age, actual_price in data:
        predicted = b - m * age
        error = actual_price - predicted
        total_loss += error ** 2
    if best_loss is None or total_loss < best_loss:
        best_m = m
        best_loss = total_loss

print(best_m, best_loss)

Trace this by hand for a few values of m, exactly as the computer would: at m = 800, the predictions are 8,200 / 7,400 / 6,600 / 5,800 / 5,000, giving errors of 0 / −100 / −500 / −400 / −700, whose squares sum to 0 + 10,000 + 250,000 + 160,000 + 490,000 = 910,000. At m = 950, the loss works out to 107,500 — already slightly worse than at m = 900. As m sweeps from 700 up to 1,100 in steps of 50, the loss falls, hits its lowest point, and then rises again:

m = 700  -> loss = 2,820,000
m = 800  -> loss =   910,000
m = 850  -> loss =   367,500
m = 900  -> loss =   100,000   <- lowest
m = 950  -> loss =   107,500
m = 1000 -> loss =   390,000
m = 1100 -> loss = 1,780,000

Every time the loop finds a new total_loss smaller than best_loss, it updates best_m and best_loss. By the time the loop finishes checking all nine candidates, best_m holds 900 and best_loss holds 100,000 — exactly the slope we found by hand, but now discovered automatically, by search, without a human ever declaring "900 is the right answer." That search — adjusting numbers inside a model to minimise a loss, computed over real examples — is what training a machine learning model means. (Professional ML systems don't check every candidate one by one like this; they use faster search techniques, such as gradient descent, covered in later chapters. But brute-force search finds exactly the same idea, just less efficiently, which is why it's the right place to start.)

Seeing the Fit

The diagram below plots all five bicycles as points, with age along the horizontal axis and price along the vertical axis. The solid green line is the model with m = 900 (the winner of the search); the dashed red line is m = 700 (the loser). Notice how much closer the solid line passes to the actual data points — that visual closeness is exactly what the loss number was measuring.

0 3000 6000 9000 Price (Rs) 0 1 2 3 4 5 6 Age (years) Training bicycles (5) Best fit: m = 900 (loss 100,000) Worse fit: m = 700 (loss 2,820,000) Held-out test bicycle (age 6)

Does It Work on a Bicycle It Has Never Seen? Generalisation

All five bicycles used so far were used to choose the model — that's called the training data. But the real test of whether the computer has learned something useful is whether the model works on a bicycle it never saw during training. Suppose a sixth bicycle, 6 years old, actually sold for Rs 3,800. Was this bicycle part of training? No — we only trained on ages 1 through 5. Using our learned model, predicted_price = 9000 − 900 × 6 = 3,600.

The model predicts Rs 3,600; the bicycle actually sold for Rs 3,800 — an error of just Rs 200 on data it had never encountered. That's a strong result: it tells us the pattern the computer found (roughly Rs 900 drop per year, starting near Rs 9,000) isn't a coincidence specific to the five training bicycles; it's a genuine relationship that carries over to a new, unseen case. This ability to perform well on new data is called generalisation, and it is arguably the entire point of machine learning. A model that only predicts training examples correctly but fails badly on new ones has not really learned the underlying pattern — it has essentially memorised the answer key.

Two Misconceptions, Corrected

Misconception 1: "Machine learning is just a lookup table — the computer memorises each example's exact answer." This is false, and the age-6 test above is the proof. Bicycle age 6 was never in the training table at all, yet the model still produced a sensible price. A lookup table can only answer questions about entries it has literally stored; it produces nothing for unseen inputs. What the model actually stores is not the five original prices — it's just two numbers, m = 900 and b = 9,000, which compress the pattern across all five examples into a compact rule that extends to new cases. This compression is precisely what separates learning from memorising.

Misconception 2: "The computer understands why older bicycles are cheaper, the way a human would." Also false. The computer has no notion of rust, wear, worn brake pads, or outdated gear systems — concepts a human would use to reason about depreciation. All it did was mechanically search for two numbers that minimise a sum-of-squared-errors formula over a table of numbers. It would search for m and b in exactly the same mechanical way if the two columns were age and price, or, say, monsoon rainfall and umbrella sales, or completely meaningless random numbers with no real relationship at all — it has no way to know or care whether the pattern it finds is meaningful. Interpreting why a pattern exists, and checking whether it's sensible, remains the job of the human who set up the problem.

The Bigger Picture: Kinds of Machine Learning

The bicycle example belongs to a broad category called supervised learning, because every training example came with the "correct answer" attached (we knew each bicycle's actual selling price) and the model was rewarded for matching it. Within supervised learning, predicting a number (like a price) is called regression — which is exactly what we just built. A close cousin is classification, where instead of predicting a number, the model predicts a category: for example, reading an email's text and predicting "spam" or "not spam." The core idea is identical — a computer searches for parameters that minimise errors over labelled examples — only the type of output changes.

There is also unsupervised learning, where the training data has no correct answers attached at all. Imagine handing a computer thousands of OLX bicycle listings with no prices, only descriptions and photos, and asking it to group similar bicycles together (mountain bikes here, kids' bicycles there) purely by noticing which listings resemble each other. No one tells the computer what the groups should be called or how many groups to find; it discovers structure on its own. This chapter has deliberately focused on supervised regression because it's the clearest place to see loss, search, and generalisation all at once — later chapters build classification and unsupervised methods on this same foundation.

Where This Fits in Your CBSE Syllabus

CBSE's Artificial Intelligence curriculum treats machine learning as one of AI's core building blocks, alongside areas like natural language processing and computer vision. When your textbook or exam refers to a machine learning "model" being "trained" on a "dataset" to minimise "error," it is describing exactly the process you just carried out by hand and in code with five bicycles: collect labelled examples, define a loss that scores how wrong a guess is, and search for parameters that make that loss as small as possible. Every more advanced technique you'll meet later — decision trees, neural networks, and beyond — is a variation on this same loop, using cleverer models and faster search strategies, but never abandoning the loop itself.

Check Yourself

Attempt each question fully before opening its answer.

  1. Using the model predicted_price = 9000 − 900 × age, what price would it predict for a bicycle that is 7 years old?

    Show answer

    9000 − 900 × 7 = 9000 − 6300 = Rs 2,300.

  2. A candidate model has errors of +50, −50, +50, −50 on four training examples. If you summed these errors directly (without squaring), what total would you get, and why is that total misleading as a measure of the model's quality?

    Show answer

    The sum is 50 − 50 + 50 − 50 = 0. This is misleading because it makes the model look perfect (zero total error) even though every single prediction was actually off by 50 — the positive and negative errors cancelled out. This is exactly why loss functions square the errors before summing.

  3. For the model m = 1000, b = 9000, compute the predicted price and the error for bicycle A (age 1, actual price Rs 8,200).

    Show answer

    Predicted = 9000 − 1000 × 1 = 8000. Error = actual − predicted = 8200 − 8000 = +200.

  4. In the brute-force search code, what does the line if best_loss is None or total_loss < best_loss: accomplish, and what would go wrong if best_loss started at 0 instead of None?

    Show answer

    It updates best_m and best_loss only when the current candidate's loss beats the best one found so far, so after the loop finishes, best_m holds the single lowest-loss slope out of every candidate tried. If best_loss started at 0, the condition total_loss < best_loss would be False for every candidate (since a sum of squares can never be negative), so best_m would never get set at all — the search would silently fail.

  5. Why does a low training loss alone not guarantee that a model has "learned" something useful? Refer to the idea of generalisation in your answer.

    Show answer

    A model could achieve a very low (even zero) loss on its training examples simply by memorising them — effectively building a lookup table — without capturing any real underlying pattern. The real test is whether the model performs well on new, unseen data (generalisation), as we checked with the held-out age-6 bicycle. A model can have excellent training loss and still generalise poorly.

  6. Explain, in your own words, why the checkers program built by Arthur Samuel counts as "machine learning" under Tom Mitchell's definition (name the task T, experience E, and performance measure P).

    Show answer

    Task T: choosing which move to play in a game of checkers. Experience E: playing many games (including against itself) and observing the outcomes. Performance measure P: how often the program's chosen moves led to winning games. Because the program's move-choices improved (P increased) as it accumulated more games played (E), it satisfies Mitchell's definition of learning from experience.

Summary

  • Machine learning differs from traditional programming in where the "rules" come from: traditional programs run rules a human wrote; machine learning programs search for rules from labelled example data.
  • A model is a mathematical rule with adjustable numbers (like m and b in price = b − m × age); training means searching for the values of those numbers that fit the data best.
  • The loss (here, the sum of squared errors) is a single number that scores how wrong a model's predictions are on the training data; squaring prevents positive and negative errors from cancelling and penalises large mistakes more. Loss values are comparison scores, not real-world quantities.
  • A brute-force search — trying many candidate values and keeping the one with lowest loss — is a genuine, working learning algorithm, even though real systems use faster search methods like gradient descent.
  • Generalisation — performing well on data the model never trained on — is the real measure of whether learning happened. Low error on training data alone can be achieved by memorising, which is not learning.
  • Supervised learning (regression for numbers, classification for categories) trains on labelled examples; unsupervised learning finds structure in data that has no attached correct answers.

Practice Exercises

Now it is time to practice! Complete these challenges to solidify your understanding:

  • Exercise 1: Write a short program that demonstrates the core concept from this chapter. Test it with at least 3 different inputs.
  • Exercise 2: Find a real-world example where what is machine learning? teaching computers to learn is used in an Indian company (like TCS, Infosys, Flipkart, or ISRO). Write a paragraph explaining the connection.
  • Exercise 3: Create a mind-map connecting what is machine learning? teaching computers to learn to at least 3 other topics you have studied.
← Competitive Programming: Think Fast, Code FasterSupervised vs Unsupervised Learning: Two Approaches →

Found this useful? Share it!

📱 WhatsApp 🐦 Twitter 💼 LinkedIn