Giving Computers the Ability to Learn from Data¶
Package version checks¶
Add folder to path in order to load from the check_packages.py script:
import sys
sys.path.insert(0, '..')Check recommended package versions:
# Package version check (Colab-safe: no external script required)
import importlib
def check_packages(d):
for pkg_name, min_version in d.items():
try:
imported = importlib.import_module(pkg_name)
version = getattr(imported, '__version__', 'unknown')
print(f'[OK] {pkg_name} {version}')
except ImportError:
print(f'[MISSING] {pkg_name} is not installed')
d = {
'numpy': '1.21.2',
'scipy': '1.7.0',
'matplotlib': '3.4.3',
'sklearn': '1.0',
'pandas': '1.3.2'
}
check_packages(d)
[OK] numpy 2.0.2
[OK] scipy 1.16.3
[OK] matplotlib 3.10.0
[OK] sklearn 1.6.1
[OK] pandas 2.2.2
Chapter 1 - Giving Computers the Ability to Learn from Data¶
Overview¶
from IPython.display import ImageBuilding intelligent machines to transform data into knowledge¶
...
The three different types of machine learning¶
import os, urllib.request
os.makedirs('figures', exist_ok=True)
fig_path = 'figures/01_01.png'
if not os.path.exists(fig_path):
url = 'https://raw.githubusercontent.com/rasbt/machine-learning-book/main/ch01/figures/01_01.png'
try:
urllib.request.urlretrieve(url, fig_path)
except Exception as e:
print(f'Could not download figure: {e}')
if os.path.exists(fig_path):
display(Image(filename=fig_path, width=500))

Making predictions about the future with supervised learning¶
import os, urllib.request
os.makedirs('figures', exist_ok=True)
fig_path = 'figures/01_02.png'
if not os.path.exists(fig_path):
url = 'https://raw.githubusercontent.com/rasbt/machine-learning-book/main/ch01/figures/01_02.png'
try:
urllib.request.urlretrieve(url, fig_path)
except Exception as e:
print(f'Could not download figure: {e}')
if os.path.exists(fig_path):
display(Image(filename=fig_path, width=500))

Classification for predicting class labels¶
import os, urllib.request
os.makedirs('figures', exist_ok=True)
fig_path = 'figures/01_03.png'
if not os.path.exists(fig_path):
url = 'https://raw.githubusercontent.com/rasbt/machine-learning-book/main/ch01/figures/01_03.png'
try:
urllib.request.urlretrieve(url, fig_path)
except Exception as e:
print(f'Could not download figure: {e}')
if os.path.exists(fig_path):
display(Image(filename=fig_path, width=300))

Regression for predicting continuous outcomes¶
import os, urllib.request
os.makedirs('figures', exist_ok=True)
fig_path = 'figures/01_04.png'
if not os.path.exists(fig_path):
url = 'https://raw.githubusercontent.com/rasbt/machine-learning-book/main/ch01/figures/01_04.png'
try:
urllib.request.urlretrieve(url, fig_path)
except Exception as e:
print(f'Could not download figure: {e}')
if os.path.exists(fig_path):
display(Image(filename=fig_path, width=300))

Solving interactive problems with reinforcement learning¶
import os, urllib.request
os.makedirs('figures', exist_ok=True)
fig_path = 'figures/01_05.png'
if not os.path.exists(fig_path):
url = 'https://raw.githubusercontent.com/rasbt/machine-learning-book/main/ch01/figures/01_05.png'
try:
urllib.request.urlretrieve(url, fig_path)
except Exception as e:
print(f'Could not download figure: {e}')
if os.path.exists(fig_path):
display(Image(filename=fig_path, width=300))

Discovering hidden structures with unsupervised learning¶
...
Finding subgroups with clustering¶
import os, urllib.request
os.makedirs('figures', exist_ok=True)
fig_path = 'figures/01_06.png'
if not os.path.exists(fig_path):
url = 'https://raw.githubusercontent.com/rasbt/machine-learning-book/main/ch01/figures/01_06.png'
try:
urllib.request.urlretrieve(url, fig_path)
except Exception as e:
print(f'Could not download figure: {e}')
if os.path.exists(fig_path):
display(Image(filename=fig_path, width=300))

Dimensionality reduction for data compression¶
import os, urllib.request
os.makedirs('figures', exist_ok=True)
fig_path = 'figures/01_07.png'
if not os.path.exists(fig_path):
url = 'https://raw.githubusercontent.com/rasbt/machine-learning-book/main/ch01/figures/01_07.png'
try:
urllib.request.urlretrieve(url, fig_path)
except Exception as e:
print(f'Could not download figure: {e}')
if os.path.exists(fig_path):
display(Image(filename=fig_path, width=500))

An introduction to the basic terminology and notations¶
import os, urllib.request
os.makedirs('figures', exist_ok=True)
fig_path = 'figures/01_08.png'
if not os.path.exists(fig_path):
url = 'https://raw.githubusercontent.com/rasbt/machine-learning-book/main/ch01/figures/01_08.png'
try:
urllib.request.urlretrieve(url, fig_path)
except Exception as e:
print(f'Could not download figure: {e}')
if os.path.exists(fig_path):
display(Image(filename=fig_path, width=500))

A roadmap for building machine learning systems¶
import os, urllib.request
os.makedirs('figures', exist_ok=True)
fig_path = 'figures/01_09.png'
if not os.path.exists(fig_path):
url = 'https://raw.githubusercontent.com/rasbt/machine-learning-book/main/ch01/figures/01_09.png'
try:
urllib.request.urlretrieve(url, fig_path)
except Exception as e:
print(f'Could not download figure: {e}')
if os.path.exists(fig_path):
display(Image(filename=fig_path, width=700))

Preprocessing - getting data into shape¶
...
Training and selecting a predictive model¶
...
Evaluating models and predicting unseen data instances¶
...
Using Python for machine learning¶
...
Installing Python packages¶
...
Summary¶
...