…
…
AI Fundamentals · Lesson 1 / 31 · A look at artificial intelligence
PreviewIn this lesson you will
You can read the explanation without an account. The exercises and quiz at the end of the lesson are for members.
The Northbridge University Student Services help desk gets hundreds of questions every day: enrollment, scholarships, dorms, course selection, password problems. Elena, who works at the desk, reads each question and routes it to the right unit by hand, and she wants to hand this job over to a program. Throughout this course you are Elena's intern, and first you will work out whether this job is really an AI job, and when a program can decide on its own.
By the end of this lesson you will be able to read a table like the one below and fill in the last column yourself. The table has six questions that came to the help desk, the unit a program predicted for each, and how much the program trusts that prediction. The last column says whether the question is sent to the unit automatically or left for Elena.
| Question | Predicted unit | Confidence | Decision (threshold 0.90) |
|---|---|---|---|
| When does the scholarship application close? | Aid | 0.97 | Send automatically |
| I forgot my password, how do I reset it? | IT | 0.92 | Send automatically |
| Where do I pay the dorm fee? | Residence | 0.90 | Send automatically |
| Does my course registration need approval? | Enrollment | 0.75 | Leave for Elena |
| Did my grant payment arrive? | Aid | 0.62 | Leave for Elena |
| When is the graduation ceremony? | Courses | 0.40 | Leave for Elena |
To understand this table you will learn three things: what AI is, what a model does and does not do, and how the "confidence" number is used. You do not need to know Python. The code pieces in the lesson come ready to run; we explain each one line by line, and you only read the result and change a few values to see what happens.
In this lesson you will:
"Artificial intelligence" shows up everywhere today: your phone sorts photos by faces, your mailbox filters unwanted messages, a map tells you your arrival time. The words are big, but the idea behind them is simple. To understand it, let's first look at how an ordinary program works.
In an ordinary program, the programmer writes the rules. The first rule that comes to mind for Elena's desk might be: "If the question contains the word *scholarship*, send it to the aid unit; if not, leave it for Elena." The code below does exactly this. The first line puts the question in a box, the second line checks whether the question contains "scholarship", and the following lines print one of two answers.
Example 1 (case): A program that works with a rule
question = "When does the scholarship application close?" if "scholarship" in question.lower(): print("Send to the aid unit") else: print("Leave for Elena")
OutputSend to the aid unitThe rule worked for this question. But what if we apply the same rule to a question that is about scholarships but does not contain the word "scholarship"? Students write questions in their own words; some say "scholarship", some say "grant", some say "financial aid".
Example 2 (case): A question the rule missed
question = "Did my grant payment arrive?" if "scholarship" in question.lower(): print("Send to the aid unit") else: print("Leave for Elena")
OutputLeave for ElenaThe rule missed it. To fix this you can add the word "payment" too, but then every question about a dorm deposit payment goes to the aid unit. Every new exception needs a new rule, and after a while the rules start to break each other. In lesson 3 we will hit this wall on purpose.
In the AI approach, a person does not write the rules one by one. The program is shown thousands of old questions and the unit each one went to; the program works out for itself which words and patterns point to which unit. In this course, artificial intelligence means this: a program that finds patterns in examples with known outcomes and makes a prediction in a new situation. This learning process has another name (machine learning), but we will mostly just say "learning".
Every AI system has three parts. The first is data: past examples with known outcomes. On Elena's desk, this is the archive of old questions and the unit each one went to. The second is learning: the program looks at these examples and adjusts which clue leads to which result. The third is prediction: when a new question arrives that the program has never seen, it uses what it learned to suggest a unit.
The prediction tool you get at the end of learning is called a model. You can think of a model as the apprentice's notebook: the apprentice has looked at hundreds of examples and made notes; when a new job comes in, the apprentice checks the notebook and acts like the closest matching example. What is written in the notebook is decided by the examples, not by what a master said one by one.
If one of these three parts is missing, there is no AI. If a person wrote all the rules, the program has not learned anything, no matter how smart it looks. On the other hand, even a very simple-looking program fits this lesson's definition if it works out its own settings from examples. So the test is this: whether an app is AI depends not on how it looks but on how it decides. Try this test on the six apps below.
Pick the right description for each app.
For each row, pick its match from the list, then check.
When a product's ad says "AI-powered", that does not show it is AI in the sense of this lesson. The phrase is attractive, so it can be stuck onto ordinary rule-based programs too. That is why you should make it a habit to look at how a program decides, not at the ad.
Example 3 (outside the case): Two step counter apps
Say there are two step counter apps on the same phone. App A's ad says "AI coach", but all it does is congratulate you when your daily steps pass 10,000. App B's ad makes no such claim; it looks at how many steps you took on the same day in past weeks and predicts how many steps you will take tomorrow.
# App A: a fixed rule written by a person steps = 11250 if steps >= 10000: print("A: Congratulations, you passed the goal!") else: print("A: Walk a little more.") # App B: predicts tomorrow from the steps of the past four Tuesdays past_tuesdays = [8200, 9100, 8700, 9400] prediction = sum(past_tuesdays) / len(past_tuesdays) print(f"B: Tomorrow you will take about {prediction:.0f} steps.")
OutputA: Congratulations, you passed the goal!
B: Tomorrow you will take about 8850 steps.The 10,000 in A was written by a person and stays the same for whoever uses the app. B's prediction comes from the person's own history; if the history changes, the prediction changes. B's method is very simple (it only takes an average), but what determines the result is not a rule someone wrote, it is data. Now decide.
Which of apps A and B fits this lesson's definition of AI?
Knowing what AI is not matters as much as knowing what it is. A model does not think, does not understand, and has no intentions. When we say "the model understood the question", we really mean this: the model matched this question to the questions it saw in training and named the unit it matched most closely. Like the apprentice's notebook, all the model has is the notes it drew from the examples it saw.
So a model has two strong sides and two weak sides. Its strengths: it can catch patterns that a person could not describe with rules (a face, a voice, the topic of a sentence), and it works very fast; it sorts in seconds the questions Elena reads in a day. Its weaknesses: it is only as good as its data, and it can be wrong while looking sure. If the old labels contain mistakes, you train the model to make the same mistakes. When it meets a situation it has never seen in its examples, it does not say "I don't know"; it still gives the closest-matching answer.
Elena's model was trained on 10,000 old questions, and none of them contained "graduation ceremony". When the question "When is the graduation ceremony?" arrives, what is most likely to happen?
A model is never one hundred percent right. That is why a good model does not only name a unit; it also gives, as a number, how much it trusts that prediction. Confidence is between 0 and 1. "Aid, confidence 0.92" means roughly this: if the model is well tuned, about 92 out of 100 questions like this really are aid questions, and 8 are not. So high confidence means "probably right", not "certainly right".
Elena's problem is this: which predictions do we trust enough to send the question automatically, and which do we still leave for a person? For this, a threshold is chosen. If the confidence is equal to or greater than the threshold, the question goes automatically; if it is smaller, it is left for Elena. The most important point: the person chooses the threshold, not the model. The model only reports its confidence; "this much confidence is enough for us" is Elena's decision.
Example 4 (case): The fate of six questions, threshold 0.90
The code below compares the six confidence values from the table at the start with the threshold, one by one, and prints the decision for each. At the end it counts how many questions went automatically and how many were left for Elena.
confidences = [0.97, 0.92, 0.90, 0.75, 0.62, 0.40] threshold = 0.90 automatic = 0 for confidence in confidences: if confidence >= threshold: print(confidence, "send automatically") automatic = automatic + 1 else: print(confidence, "leave for Elena") print("Automatic:", automatic, "| Elena:", len(confidences) - automatic)
Output0.97 send automatically
0.92 send automatically
0.9 send automatically
0.75 leave for Elena
0.62 leave for Elena
0.4 leave for Elena
Automatic: 3 | Elena: 3Python prints 0.90 as 0.9; they are the same number. The dorm question with a confidence of exactly 0.90 went automatically, because the rule is "equal to or greater than the threshold". Now take a single question and change two things: the model's confidence and Elena's threshold. See how the same confidence turns into a different decision when the threshold changes.
Change the confidence and the threshold: does the question go automatically, or is it left for Elena?
Pick a value; predict the output first, then look.
1confidence = 0.922threshold = 0.903if confidence >= threshold:4 print("Send to the aid unit automatically")5else:6 print("Leave for Elena")
Send to the aid unit automatically
Faded lines didn't run with this value. A question with confidence 0.75 is left for Elena when the threshold is 0.90, and goes automatically when the threshold is 0.70. The question is the same and the model is the same; the only change is the threshold the person chose. A confidence of 0.40 is left for Elena at both thresholds.
Lowering the threshold has a cost. With a threshold of 0.70, fewer questions reach Elena, but the questions that go automatically now include those with confidence 0.75, and some of them go to the wrong unit. Raising the threshold works the other way: fewer wrong sends, more work for Elena. The right threshold is not the "highest" or the "lowest"; it is the point where wrong sends and Elena's workload are acceptable together.
One of the long-time staff at the desk smiles: "We tried this twenty years ago, we wrote hundreds of rules, and it did not work." True; AI is not an invention of the last few years. What is different today is not the idea itself, but that the material to run it exists.
Put these developments in order, from oldest to newest.
Click the lines in order; to undo one you placed wrong, click it in the list below.
Shuffled lines
Your order
The old attempt at Elena's desk looked just like the expert system era: there were only a few hundred questions, and the only way was to write rules. Today the archive holds tens of thousands of questions collected over the years, with the units they went to.
Twenty years ago Elena's archive had 300 questions; today it has 60,000. What is the main change that makes learning from examples more sensible today than writing rules?
If a person chooses the threshold, the responsibility is the person's too. When the model says "aid" with 0.55 confidence, sending that question automatically means sending about one in two such questions to the wrong unit; that student may wait days for an answer. "The model said so" is not a reason. Decide for yourself in the situation below.
The model said "Aid" for a new question with 0.55 confidence. Elena's threshold is 0.90. What do you do?
Pick an option and see what happens. There are no points; you can try the other options too.
In this course we will go in the same order: first you will see in what forms AI shows up around you, then you will write rules for Elena and run into their limits, and then you will build the first model that learns from examples and measure how good it is. At the end we will talk about the language models behind chat assistants, using them with verification, and the rules of responsible use.
The six confidence values from Example 4 are the same; only the threshold is 0.70. The number of questions that go automatically rose from 3 to 4: the course registration question with confidence 0.75 now goes without stopping at Elena.
confidences = [0.97, 0.92, 0.90, 0.75, 0.62, 0.40] threshold = 0.70 automatic = 0 for confidence in confidences: if confidence >= threshold: automatic = automatic + 1 print("Automatic:", automatic, "| Elena:", len(confidences) - automatic)
OutputAutomatic: 4 | Elena: 2When you judge an app as AI, answer four questions. For a map to say "24 minutes to school", the answers are:
OutputData : Past trips; at what time, on which road, how many minutes it took
Learning : Working out from these records how time of day, day of week, and road conditions affect the duration
Prediction: In how many minutes you will arrive if you leave now (24 minutes)
If wrong : You are late; an unexpected accident or road work does not look like the examples in the dataTaking a confident-looking output as correct. A model produces a sure-looking answer like "Send to the aid unit" even for a question that has nothing like it in its examples; no sign of hesitation appears on the screen. A firm tone or a high confidence number does not prove the prediction is right: out of 100 predictions given with 0.92 confidence, a few are still wrong. The right approach is to compare the prediction with the threshold and leave what falls below it for a person. In lesson 4 you will see the same trap in a chat assistant that speaks with great confidence.
Next lesson: AI is not one single kind; you will go through a day on your phone and tell apart the systems that predict, recommend, and generate.
Exercises and quiz are for members
This lesson has 6 coding exercises and a 10-question quiz. Sign up free to solve them, save your progress and move on to the next lesson.