devnotes.

Setting Up Your ML Environment

The standard Python machine learning stack builds directly on the data analysis libraries from the previous notebook, adding scikit-learn for modeling.

python3 -m venv venv
source venv/bin/activate

pip install numpy pandas scikit-learn matplotlib seaborn jupyterlab

jupyter lab
import sklearn
print(sklearn.__version__)

from sklearn.datasets import load_iris   # small built-in datasets, great for practicing
iris = load_iris(as_frame=True)
df = iris.frame
print(df.head())

scikit-learn includes several small, clean, built-in datasets (load_iris, load_diabetes, fetch_california_housing, and others) specifically for learning and quick experimentation — no external download or cleaning needed, which is why they appear throughout tutorials and this notebook. as_frame=True returns the data directly as a Pandas DataFrame, integrating immediately with everything covered in the previous notebook.

Real ML projects typically also involve heavier libraries not covered in depth here — tensorflow or pytorch for deep learning (introduced briefly in the Neural Networks chapter), xgboost/lightgbm for high-performance gradient boosting — but scikit-learn alone covers the large majority of everyday classical machine learning tasks, and is the right starting point before reaching for anything more specialized.

Setting Up a Python Machine Learning Environment | DevNotes