Skip to main content

Section 3.3 How AI ’Thinks’

AI systems do not think like humans, but they can learn useful patterns from data and make predictions at scale. This section contrasts traditional rule-based programming with machine learning and introduces the key components that make modern AI possible.

Subsection 3.3.1 Traditional Programming vs. Machine Learning

We will begin our investigation with a simple problem that you already know how to solve using traditional programming. Suppose that you want to classify an object based on its characteristics, such as determining whether a piece of fruit is an Apple or an Orange. An explicit, iterative function that computes a classification like this is shown in the Runestone workspace below.
This traditional function uses human-defined conditions, checking explicit weight thresholds and texture metrics, to return a result.
Pretend for a minute that you do not know the exact physical traits that separate an apple from an orange. How would you write a computer program to tell them apart?
If you were writing a traditional program, you would have to spend hours measuring thousands of fruits, calculating averages, and hardcoding dozens of nested if/else statements. In Traditional Software, a human developer must hand-craft the exact computational rules to process data and yield answers:
Explicit Rules + Data = Answers
But what happens when the rules become too complex for a human to write down? For instance, how would you write explicit rules to recognize a handwritten digit, or translate an entire paragraph from English to Spanish?
Shifting the Paradigm
How can we take this dilemma and turn it into a Machine Learning (ML) solution? Instead of writing the rules ourselves, we feed the computer historical examples where the answers are already known (labeled data). The computer then uses an optimization algorithm to discover the underlying mathematical formulas on its own.
In a machine learning workflow, the inputs and outputs are flipped:
Data + Answers = Explicit Rules (Patterns)
There are a few key ideas in this new paradigm to examine. First, our software acts less like a strict calculator and more like a predictive system. Second, because the machine deduces its own parameters, we must establish a way to ensure it actually understands the concept rather than just memorizing our examples.
Here is an example of a classification ML algorithm from the scikit-learn library that predicts whether a fruit is an Apple or an Orange.
from sklearn.tree import DecisionTreeClassifier

# X = [weight_grams, texture_code]
# texture_code: 1 = smooth, 2 = bumpy
X = [
    [130, 1],
    [140, 1],
    [150, 1],
    [160, 2],
    [170, 2],
    [180, 2],
]

y = [
    "Apple",
    "Apple",
    "Apple",
    "Orange",
    "Orange",
    "Orange",
]

model = DecisionTreeClassifier(random_state=42)
model.fit(X, y)

# Change this line for each test case.
test_fruit = [[165, 1]]

prediction = model.predict(test_fruit)
print("Prediction:", prediction[0])
It is important to recognize that it is up to future programmers to know the hidden or abstracted logic represented by the methods, classes, and objects in this program.
Check your understanding
Using a table, spreadsheet, or a piece of scratch paper, create a matrix for the following three mystery fruits. Based strictly on the data rows provided in X and labels y in the code above, mathematically reason out what the Decision Tree will classify each fruit as, and write down why. Then execute the script three times, changing test_fruit for each test to verify your predictions.
  • Test Case A: The Heavy Smooth Fruit [[165, 1]]
    Deeper Thinking Hook: This fruit matches the weight of an orange but has the smooth texture of an apple. It forces you to deduce which feature (weight or texture) the tree values more heavily based on training balance.
  • Test Case B: The Miniature Bumpy Fruit [[110, 2]]
    Deeper Thinking Hook: This fruit is lighter than any apple in the dataset but has a bumpy orange texture. Will the model classify by weight threshold or texture boundaries?
  • Test Case C: The Exact Threshold Borderline [[155, 1.5]]
    Deeper Thinking Hook: Passing a float value like 1.5 for texture (midway between smooth and bumpy) tests how the algorithm handles continuous mathematical splits on features we conceptualize as discrete.

Subsection 3.3.2 The AI Triad: Data, Algorithms, and Compute

Why is AI booming now? The mathematical concepts behind machine learning are not new. Many regression techniques and neural network ideas were developed decades ago. However, the modern explosion of AI systems is driven by the simultaneous convergence of three critical components known as the AI Triad.
  • Data (The Fuel): The rise of the internet, smartphones, and global digital networks has generated a massive ocean of data. Algorithms require millions of examples to discover reliable patterns, and the modern digital landscape provides this scale.
  • Algorithms (The Engine): Refinements in multi-layered neural networks (deep learning) and modern architectures like transformers have drastically improved how systems handle complex sequences like language and pixels.
  • Compute (The Horsepower): Training an algorithm requires trillions of mathematical matrix multiplications. The adoption of specialized hardware, specifically GPUs (Graphics Processing Units), allows systems to process thousands of calculations simultaneously, turning weeks of computational training into hours.

Checkpoint 3.3.1.

Interactive Element (Parson’s Problem): The ML Workflow
A machine learning engineer does not just throw data straight into an algorithm. There is a precise operational pipeline required to successfully build an AI system. Drag the blocks below into the correct top-to-bottom order for a standard ML workflow.
You have attempted of activities on this page.