SecAI+
AI Foundations

What Is AI, and How Does It Learn?

Start at the beginning—learn how machines use examples to find patterns, how a trained model handles new input, and why an AI prediction is not a guaranteed fact.

YOUR MISSION

Understand what happens before an AI gives an answer.

Check each one off when you can do it without looking at your notes. Saved in this browser.

TRY IT IN YOUR BROWSER

Become the spam classifier.

No model yet—just you, six examples, and the patterns you notice.

YOUR LABELING SCORE0 of 6 labeled

Label all six messages. In machine learning, these known answers are called labels.

RULES CAN BE BRITTLE

Can one rule solve spam?

Choose a rule and test it. Exact rules are useful, but attackers can evade them and normal messages can accidentally match them.

Select a rule to see where it succeeds and fails.

CLASSIFY OR GENERATE?

“Write a short incident summary from these alerts.”

What kind of AI task is this?

01UNDERSTAND

Begin with a familiar decision

You open your inbox and see two messages:

  1. “Your fall registration is confirmed.” It comes from the college registrar and directs you to the normal student portal.
  2. “URGENT: Your mailbox closes today.” It comes from micr0soft-help.com and asks you to confirm your password immediately.

Most people recognize the second message as suspicious without consulting a written rulebook. You notice several clues at once: an imitation domain, artificial urgency, a credential request, and language that does not fit the situation.

That ability to learn from examples and recognize a similar pattern in something new is the central idea behind machine learning.

Certification lens: CompTIA SecAI+ Objective 1.1 begins with the ability to compare AI types and techniques. Before memorizing those types, build one dependable mental model of how learning from data differs from following programmed instructions.

Traditional programs follow instructions

A traditional program is given rules written by a programmer.

IF a login password is incorrect five times
THEN lock the account for fifteen minutes

The computer applies the rule exactly. It does not decide that four attempts are “close enough,” and it does not independently learn that a particular user normally mistypes a password on Monday mornings.

This approach is valuable because it is predictable and easy to explain. However, the program can only handle situations covered by its rules.

Example: a brittle spam rule

Suppose we write this rule:

IF an email contains the word “urgent”
THEN classify it as spam

The rule catches “URGENT: Verify your account,” but it also blocks “Urgent weather closure notice” from the college. An attacker can evade it by writing “Action required” instead.

The rule did exactly what it was told. The problem was that one simple instruction could not represent every legitimate or malicious email.

Machine learning finds patterns in examples

Artificial intelligence (AI) is a broad field concerned with machines performing tasks that normally require capabilities such as perception, prediction, language, planning, or decision support.

Machine learning (ML) is an approach within AI. Instead of programming every decision rule, people provide data and a learning process. The system searches the examples for patterns that help it perform a task.

For a spam detector, the examples might include:

Example information Possible pattern
Sender domain Does it imitate a familiar organization?
Language Does it create unusual urgency or fear?
Request Does it ask for credentials, money, or sensitive data?
Links Does the displayed destination differ from the real destination?
Message history Is this behavior normal for this sender?

The machine is not “thinking like a person.” It is calculating relationships learned from the data. With enough relevant examples, it may identify combinations that a single hand-written rule would miss.

Four words that explain the process

1. Data

Data is the collection of examples available to the learning process. In our spam example, the data contains emails and their known categories.

Data is not automatically good. If the examples are inaccurate, unrepresentative, or manipulated, the resulting system learns unreliable patterns.

2. Training

Training is the process that adjusts the system using those examples. The learning algorithm repeatedly compares predictions with known outcomes and changes internal values to reduce error.

You do not need the mathematics yet. The important point is that training is when the system learns from historical examples.

3. Model

The result of training is a model: a learned mathematical representation that can map input to an output.

For the spam detector:

email → trained model → probability of spam

The model is not the dataset, and it is not the training process. It is the learned result that training produced.

4. Inference

Inference occurs when the trained model receives new input and produces a prediction or generated output.

Training might happen occasionally using millions of historical messages. Inference happens each time a new message arrives.

Training Inference
Learns from examples Uses what was learned
Produces or updates a model Produces a prediction or output
Usually resource intensive Usually designed to be fast
Historical spam dataset One newly received email

Put the pipeline together

The foundation for the entire course is:

examples and labels → training → model → new input → inference → output

Consider a phishing classifier:

  1. Security analysts collect emails.
  2. They label each email phishing or legitimate.
  3. Training searches for patterns associated with those labels.
  4. Training produces a model.
  5. A new email arrives.
  6. The model performs inference and reports, for example, 82% probability of phishing.
  7. A person or security system decides what to do with that prediction.

Notice the final step. The model produces information; it does not automatically possess authority or perfect judgment.

Classification and generation solve different tasks

Two AI systems may use related technology while doing fundamentally different jobs.

Classification chooses a category

A classification system selects from defined categories.

Cybersecurity examples include:

  • phishing or legitimate;
  • malware or benign software;
  • approved or suspicious login;
  • known threat family A, B, or C.

The output might be a category plus a confidence score:

Prediction: phishing
Confidence: 82%

Generative AI creates new content

Generative AI produces new text, code, images, audio, or other content based on patterns learned during training.

Cybersecurity examples include:

  • writing a first draft of an incident summary;
  • explaining a security alert in plain language;
  • suggesting detection-rule code;
  • creating simulated phishing messages for authorized training.

Classification answers, “Which category fits?” Generation answers, “What new content should be produced?”

One incident, two different tasks

Input: twelve authentication failures followed by a successful login from an unfamiliar country.

System Output
Classifier Suspicious login: 91%
Generative system “The account experienced repeated failures followed by a geographically unusual successful login. Verify the user and review the source address.”

The classifier selects a category. The generative system constructs new language. Neither output proves that an account was compromised.

AI outputs are predictions, not guarantees

A model learns statistical patterns. That gives it useful flexibility, but it also creates uncertainty.

An output can be wrong because:

  • the training examples were incomplete or inaccurate;
  • the real world changed after training;
  • the new input is ambiguous;
  • the model learned an irrelevant shortcut;
  • the requested generative answer was not supported by reliable information.

Confidence does not mean correctness

A system reporting “96% confident” is describing its own calculated certainty under its model. It is not providing proof.

Imagine a model trained mostly on messages from large corporations. It may confidently flag a legitimate message from a small local vendor because that sender looks unfamiliar compared with its training data.

Security professionals therefore ask:

  • What data shaped this result?
  • What task was the model trained to perform?
  • Is this new input similar to its training examples?
  • What happens if the prediction is wrong?
  • Should a person verify the result before action?

What to carry forward

AI is not magic and it is not automatically autonomous. A useful first description is:

An AI system uses learned or designed techniques to produce predictions, decisions, or content. Machine learning specifically learns patterns from data so a trained model can handle new input during inference.

Later topics will add deep learning, transformers, natural language processing, large language models, prompt engineering, retrieval-augmented generation, and security controls. Every one of those topics builds on the same pipeline you learned here.

02PRACTICE

Rules versus learned patterns

Complete this activity in the browser using the email examples above. Work with a partner for the explanation portion.

Part 1: Label the examples

Classify all six messages as spam or legitimate. Do not merely guess. For each decision, identify at least one signal you used.

Possible signals include:

  • sender identity and domain;
  • urgency or emotional pressure;
  • requests for passwords, payment, or sensitive information;
  • whether the request fits the sender's normal purpose; and
  • whether the link or action uses a trusted channel.

Part 2: Test a hand-written rule

Choose each rule in the browser activity and examine what it catches, misses, and incorrectly blocks.

Discuss:

  1. Why can an exact rule work well for one example but fail on another?
  2. How could an attacker change a message to evade the rule?
  3. What legitimate message could accidentally match the rule?
  4. What combination of patterns did you use that the single rule ignored?

Part 3: Build the AI pipeline

Place these stages in order:

  • a new email arrives;
  • analysts label historical emails;
  • the system trains on the examples;
  • training produces a model;
  • the model predicts whether the new email is spam.

Then explain where training ends and inference begins.

Part 4: Classification or generation?

Identify each task as classification or generation.

  1. Decide whether a URL is malicious or benign.
  2. Draft a plain-language explanation of a firewall alert.
  3. Assign an executable file to a known malware family.
  4. Write a first draft of an incident-response ticket.
  5. Decide whether a login is normal or suspicious.

For each answer, use this test:

  • Is the system choosing a category?
  • Is the system creating new content?

One-minute explanation

Without reading the lesson, explain this chain to your partner:

data → training → model → inference → output

Your explanation must use the spam-filter example and include one reason the output could be wrong.

03REVIEW

Certification review

The five terms to know cold

Term Plain-language meaning Spam-filter example
Artificial intelligence Broad field of machines performing tasks associated with perception, prediction, language, planning, or decision support Software helps identify suspicious messages
Machine learning An AI approach that learns patterns from data rather than relying only on explicitly written decision rules The system learns from labeled email examples
Training The process of learning from examples and adjusting the model Historical emails are used to reduce classification error
Model The learned mathematical representation produced by training The trained spam classifier
Inference Applying the trained model to new input Scoring a newly received email

Fast comparisons

If the question says… Think…
“The programmer wrote an exact condition” Rule-based program
“The system learned from examples” Machine learning
“The trained system receives a new input” Inference
“Choose phishing or legitimate” Classification
“Write an incident summary” Generative AI
“96% confidence” A prediction—not proof

Common first-topic mistakes

  • Training and inference are not the same phase.
  • The training data, training process, and trained model are different things.
  • AI is the broad field; machine learning is one approach within it.
  • Classification selects a category; generation creates new content.
  • A high confidence score does not guarantee a correct answer.
  • An unusual event is not automatically a malicious event.

Check yourself

  1. A developer writes IF failed_logins >= 5 THEN lock_account. Is this an example of a learned model or an explicit rule?
  2. Analysts provide 50,000 emails already labeled phishing or legitimate. What role do those emails play?
  3. Training finishes and produces something that can score new emails. What was produced?
  4. The trained system scores a newly received email. Is this training or inference?
  5. A system assigns a file to “malware” or “benign.” Is it classifying or generating?
  6. A system writes a paragraph summarizing an alert. Is it classifying or generating?
  7. Give two reasons a confident prediction could still be wrong.

Explain it aloud

You are ready to move on when you can say, without notes:

Historical examples are the data. Training uses those examples to produce a model. Inference is when the model handles new input. The result is a prediction or generated output, not a guaranteed fact.

KEEP LEARNING

Explain it without the jargon.

If you can explain data, training, a model, and inference using the spam example, you have the foundation for the next topic.