What Is AI

Layer 3 · Code

What Is AI

A tiny end-to-end example contrasting a hand-coded rule with a trained statistical model on the same task.

12 min read110 XP

rules.py

  • if 'free' in text: spam
  • if 'win money' in text: spam
  • else: not spam

learned.py

  • fit weights on labeled examples
  • score = sigmoid(w·x + b)
  • generalizes to unseen wording
Same task, two philosophies — we'll implement both.

To make the symbolic-vs-statistical distinction concrete, let's build a minimal spam classifier both ways on the same toy dataset.