On this concept: Formula

Not sure which lesson to do first? Find your level and get a plan →

CS Thinking · Systems, Networks & Impact · Grade 9-12

Artificial Intelligence

Artificial intelligence is the field of building systems that perform tasks normally requiring human-like perception, pattern detection, prediction, or decision making, with many such systems learning patterns from large sets of data instead of following only hand-written rules.

y^=fθ(x)

Quick Answer

Artificial intelligence is the field of building systems that perform tasks normally requiring human-like perception, pattern detection, prediction, or decision making, with many such systems learning patterns from large sets of data instead of following only hand-written rules. You use it for jobs where writing every rule by hand is hopeless: telling cats from dogs in photos, turning speech into text, catching spam. The system is shown many labeled examples, adjusts its internal settings θ until its predictions y^=fθ(x) match the labels, and then predicts for new inputs. Its answers are only as good as the data it learned from.

Why This Matters

Knowing that a model is a pattern fitted to data tells you what to ask about it: what data trained it, who is missing from that data, and how it did on examples it never saw. Without that, a 95% accuracy figure looks like a guarantee, and a system that works for most users but fails a smaller group goes unnoticed until it hurts someone.

Intuitive Explanation

Suppose you want a program that sorts email into spam and not spam. You could write rules by hand, such as "if it says FREE MONEY, it's spam", but spammers change their wording faster than anyone can write rules. Machine learning works the other way round. Collect 10,000 emails that people have already labeled, and let the program search for the setting that separates them best. If "4 or more links" splits the labeled emails with the fewest errors, the program adopts 4 as its threshold. Nobody typed 4; the data chose it.

That threshold is a parameter, one entry of θ in y^=fθ(x). Here x is the input (an email), f is the form of the rule (count links, compare with a threshold), and y^ is the predicted label. A photo classifier has millions of parameters instead of one, but training follows the same idea: nudge the parameters to reduce errors on the examples, then test on examples kept aside to see whether the pattern holds for cases the model has never met.

A thermostat that switches the heater on below 19 °C also takes an input and makes a decision, and it can seem clever. But a person chose 19, and it stays 19 however many winters the thermostat runs, so it is an ordinary program, not a learning system. Ask where the rule came from: typed in by a programmer, or fitted to examples. That also explains how AI typically fails: if the examples are skewed, the learned rule is skewed in the same way.

Think of it like this. Training a model is like learning to read a friend's handwriting. After enough notes, you can read a word you have never seen them write, and nobody handed you a rulebook. If every note you saw was in neat capitals, though, their messy cursive will trip you up. Unlike you, the model has no idea what the words mean.

Core idea. AI depends on data, models, and evaluation, not just on bigger computers.


When to Use

Use it when a problem describes a system built from training data or labeled examples that then predicts, classifies or recommends for inputs it has not seen: a spam filter, face unlock, a video recommendation feed, a translator. If a person wrote every rule (a thermostat, a calculator, a sorting program), it is an ordinary Algorithm. If the task is spotting a regularity yourself, use Pattern Recognition; if it is whether the system is fair or should be used at all, use Ethics of Computing.

Tip. Ask: Does the program get its behavior from patterns learned in example data, instead of only from rules a person wrote?

How to Recognize It

Before you call a program artificial intelligence, find out where its behavior came from and what it is predicting.

  1. Was the model trained on many examples, such as labeled photos or past messages, before it was used?

    Yes is machine learning, the most common kind of AI today. If a programmer wrote every step by hand for a simple task, such as sorting names, it is an ordinary Algorithm.

  2. Does it make a guess about new inputs it has never seen, like a new photo or sentence?

    Yes fits AI, which generalizes from training data and can be wrong. If it runs a fixed, human-built model of a real process to test what-ifs, that is Simulation.

  3. Is the question about a person spotting a repeating pattern by thinking it through?

    Yes points to Pattern Recognition, the human problem-solving skill. AI is a machine finding patterns automatically, often ones no one wrote down.

  4. Does the problem ask how well the model works for different groups of people, or on data it was not trained on?

    Yes is AI evaluation: test on held-out examples, group by group. If it asks whether the tool should be used at all, it points to Ethics of Computing.

Artificial Intelligence vs Algorithm vs Pattern Recognition vs Simulation

AI is built from algorithms, finds patterns and runs models, so it borrows words from all three. Ask where the behavior came from: learned from data, written as steps, spotted by a person, or set by a model's rules.

Artificial Intelligence

Meaning
Artificial intelligence builds programs that perceive, predict or decide, often by learning patterns from large sets of examples.
Key test
Its behavior was learned from data, and it predicts for new inputs.
Formula
y^=fθ(x)
Example
A phone keyboard suggests your next word after learning from millions of typed sentences.

Algorithm

Meaning
An algorithm is a fixed list of steps that a person designed to solve a problem.
Key test
Every rule was written by someone; nothing was learned from examples.
Example
A program that sorts test scores from highest to lowest.

Pattern Recognition

Meaning
Pattern recognition is noticing similarities or regularities across examples, a skill people use to solve problems.
Key test
A person spots the pattern and can explain it.
Example
Seeing that 3, 6, 12, 24 doubles each time and predicting 48 next.

Simulation

Meaning
A simulation is a program that models a real system with rules people chose, so they can test what-if questions.
Key test
The rules come from people's model of the world, not from training on labeled data.
Example
A traffic program that shows how one extra lane would change rush-hour delays.

Formula & Notation

y^=fθ(x)
Many AI systems approximate a function fθ that maps input data x to a predicted output y^ using parameters θ learned from training data.

Worked Examples

Example 1 — Train a one-number spam filter

Easy

A filter predicts "spam" when an email has at least θ links. Seven labeled training emails have these link counts: not spam 0, 1, 2, 3; spam 4, 5, 7. Find the θ that makes the fewest errors on the training emails, then classify two new emails with 6 links and 2 links.
Show the steps and the answer
  1. Try θ=3: it labels the emails with 3, 4, 5 and 7 links as spam, so the 3-link email is wrong. 1 error.

    Training means testing settings against labeled examples and counting the mistakes each one makes.

  2. Try θ=4: spam for 4, 5 and 7; not spam for 0, 1, 2 and 3. 0 errors.

    Every labeled email lands on the correct side of the threshold.

  3. Try θ=5: the 4-link spam email is labeled not spam. 1 error.

    Raising the threshold past 4 starts letting spam through, so 4 is the best fit.

  4. Predict: 6≥4, so the 6-link email is spam; 2<4, so the 2-link email is not spam.

    The learned θ now handles emails that were never in the training set, which is the reason for training at all.

Answer: θ=4. The 6-link email is predicted spam; the 2-link email is predicted not spam.

Takeaway: The program, not a programmer, picked the 4. Different training emails could give a different θ, so the data shapes the rule.

Example 2 — Same rule, learned or hand-written?

Standard

Filter A: a programmer types "mark as spam if more than 3 links" and never changes it. Filter B: uses the same kind of rule, but every week it re-picks the link threshold that makes the fewest errors on the 10,000 emails users marked that week. A thermostat turns the heater on below 19 °C. Which of the three is machine learning?
Show the steps and the answer
  1. Ask where Filter A's 3 came from: a person typed it.

    The rule never responds to data. If spammers switch to 2-link emails, Filter A misses them forever. It is an ordinary program.

  2. Ask where Filter B's threshold comes from: it is fitted each week to emails people labeled.

    If spammers switch to 2-link emails and users mark them, next week's fit lowers the threshold. Changing its parameter to match new data is what makes it learning.

  3. Ask the same of the thermostat: one hand-set number, 19 °C, and a decision.

    Taking an input and choosing an action can look smart, but nothing is learned from examples.

Answer: Only Filter B is machine learning; Filter A and the thermostat follow fixed hand-written rules.

Takeaway: Two systems can apply the very same rule; what makes one of them AI is that its parameters come from data.

Example 3 — Find the mistake: trusting training accuracy

Application

Priya trains an image classifier on 40 photos: 20 wolves, all standing on snow, and 20 huskies, 2 of them on snow. It labels all 40 training photos correctly. She writes: "It's 100% accurate, so it can tell wolves from huskies." Then it labels a photo of her neighbor's husky in the snow as a wolf. Find the mistake and correct it.
Show the steps and the answer
  1. Look for an easier pattern in the training photos: snow appears in 20 of 20 wolf photos but only 2 of 20 husky photos.

    A model learns whatever separates the labels most easily. Here the background is a strong clue, so the animal may not be what it learned.

  2. Test the shortcut "snow means wolf" on the training set: it gets the 20 wolves and the 18 huskies without snow right, 38 of 40.

    The model could reach 95% with no knowledge of animals at all; one small extra cue covers the last 2 photos.

  3. Name the error: 100% on the training photos measures how well the model fits those photos, not how it does on new ones.

    Accuracy only counts on photos the model never saw, chosen to break the shortcut, such as huskies on snow and wolves on grass.

  4. Fix the data: add wolves on grass and huskies on snow, retrain, and judge the model on a separate set of held-out photos.

    When the background no longer predicts the label, the model has to use features of the animal itself.

Answer: The classifier may have learned "snow means wolf", which is right for 38 of the 40 training photos. Retrain with mixed backgrounds and judge it on held-out photos, not on training accuracy.

Takeaway: High accuracy on training data proves little. A model learns any shortcut its data allows, so test it on new, varied examples.

Where You'll See It

  • Your video app recommending the next clip

    The app learned patterns from millions of viewers' watch histories to predict what you'll likely watch next — a model making a prediction on new input, not a person picking for you.

  • A photo app sorting pictures of your dog

    The AI was trained on labeled images to recognize patterns of 'dog,' so it can group new photos — but it can misfire on a fluffy pillow, showing it predicts rather than truly 'knows.'

  • A chatbot answering homework questions

    It generates likely-sounding answers from patterns in its training data, which is why it can be confidently wrong — the output reflects the data and model, not guaranteed truth.

Common Mistakes

  1. The slip: AI outputs are objective and always correct.

    Why it's tempting: A computer feels neutral and precise, so its answers seem more trustworthy than a person's.

    Instead: AI learns from data that can be incomplete or biased, so its outputs can be wrong or unfair and must be checked against evidence.

  2. The slip: Better AI just means a bigger or faster computer.

    Why it's tempting: We associate 'powerful computer' with 'powerful AI,' so hardware feels like the whole story.

    Instead: AI quality depends on the data, the model design, and careful evaluation — not just raw computing power.

  3. The slip: AI is one single technology.

    Why it's tempting: The label 'AI' is used for everything from chatbots to self-driving cars, so it feels like one thing.

    Instead: AI is an umbrella for many different methods and systems (rule-based, machine learning, neural networks), each with different strengths and limits.


Mini Practice

Try these on your own. Tap Reveal when you want to check.

  1. A spam filter is tested on 200 emails and labels 184 of them correctly. What is its accuracy, and how many emails does it get wrong?

    Hint: Accuracy is correct answers divided by the total.

  2. In a test set, 95 of 100 scans show no disease. A model always answers "no disease". What is its accuracy, and why is it still useless?

    Hint: Count how many of the sick patients it finds.

  3. A simple AI guesses a fruit from its weight by picking the closest known example: apple 150 g, orange 200 g, melon 1,000 g. What does it predict for a 180 g fruit and for a 650 g fruit?

    Hint: Find the distance from each new weight to each known example.

  4. A face-unlock model was trained on 9,000 photos of adults and 1,000 photos of children. What percent of the training photos show children, and what problem might children have?

    Hint: Divide the number of child photos by the total number of photos.

  5. Question A: how does a model learn to flag loan applications that may not be repaid? Question B: should a bank let that model reject people with no human review? Which is about how AI works, and which is ethics of computing?

    Hint: One question is about learning from data; the other weighs fairness and harm.

  6. Raj says: "The chatbot told me the Great Wall of China is easy to see from space with the naked eye. AI learns from huge amounts of data, so it must be true." What is wrong?

    Hint: Where does a model's knowledge come from, and can that source contain myths?

Want the full set?

50 practice questions for this concept — free to try, every one with a complete worked solution showing the why, not just the answer.

Frequently Asked Questions

Does a chatbot understand what it says?

Not in the way people do. A large language model is trained to predict the next small piece of text, called a token, from patterns in an enormous amount of writing. That makes it fluent and often useful, but it has no built-in check against the real world, so it can state false things confidently. Treat its answers as a draft to verify, especially facts, numbers and quotations.

What is the difference between training and using an AI model?

Training is when the model adjusts its parameters θ\theta over many examples until its predictions match the labels well, which can take weeks on thousands of chips for a large model. Using the trained model, called inference, is just computing fθ(x)f_\theta(x) for a new input, often in a fraction of a second. Most deployed models do not learn from each new input; they change only when their makers retrain them.

How can an AI be biased if it is just math?

The math copies whatever patterns are in the data. In a 2018 study, Joy Buolamwini and Timnit Gebru found that commercial systems guessing gender from face photos made far more mistakes on darker-skinned women than on lighter-skinned men. Nothing in the code said to treat groups differently; the training data did it. Fixing it starts with measuring accuracy group by group and widening the data.

What is overfitting?

Overfitting is when a model memorizes its training examples, including their quirks and noise, instead of learning the general pattern. It scores almost perfectly on data it has seen and badly on new data, like a student who memorizes last year's answer key and fails when the questions change. That is why data scientists hold back a test set that the model never sees during training.

Learning Path

Artificial Intelligence

You are here

You need Pattern Recognition (finding a regularity in examples) and Data Representation (how photos, sounds and text become numbers) first. AI adds a machine that finds the pattern itself, by adjusting parameters to fit labeled data, and then predicts on new inputs. Next, Ethics of Computing takes up the questions these systems raise: whose data trained them, who gets misjudged, and who is responsible when they are wrong.

See Also