No rules are written. It guesses a price, measures the error and nudges two numbers 2,000 times, ending at price = 3.33 × size + 2.44, and then prices a house it has never seen.
python3 --version.pip install "numpy>=1.26"git clone https://github.com/DayanEbrar0X/data-anatomy.ai.git cd data-anatomy.ai
python3 -m venv .venv source .venv/bin/activate
pip install -r requirements.txt # or just this lesson: pip install "numpy>=1.26"
cd machine-learning/00-what-is-machine-learning python3 src/learn.py
import numpy as np
from houses import x, y # 40 examples
w, b = 0.0, 0.0 # the model
for epoch in range(2000):
err = w * x + b - y # how wrong
w -= 0.01 * (err * x).mean() # nudge w
b -= 0.01 * err.mean() # nudge b
print(f"price = {w:.2f} * size + {b:.2f}")Nobody told this line where to go. It figured that out by itself. That's machine learning. You don't write rules.
You show it examples. Like these forty houses. Bigger house, bigger price. The model starts as a flat, clueless line.
Just two numbers. It guesses a price, checks how wrong it was, and nudges both numbers a tiny bit. Do that two thousand times, and now it can price a house it's never seen. No rules.
Just examples. That's machine learning.
Read the lesson on GitHub →