Setting up the ML Environment (Scikit-Learn, TensorFlow, PyTorch)
The goal
You want an environment that:
- is reproducible (same versions)
- works for both notebooks and scripts
- supports classical ML, plus deep learning later
Recommended baseline stack
Core
numpynumpy,pandaspandas(arrays + dataframes)matplotlibmatplotlib,seabornseaborn(visualization)scikit-learnscikit-learn(classic ML: regression, classification, clustering)
Deep learning
Pick at least one:
torchtorch(PyTorch)tensorflowtensorflow(TensorFlow / Keras)
Optional but helpful
jupyterlabjupyterlab(notebooks)ipykernelipykernel(bind env to Jupyter)joblibjoblib(save models)
Environment options
Option A — venv (simple)
- good for most projects
- built into Python
Option B — conda (popular for ML)
- excellent for scientific stacks
- can manage non-Python dependencies
Either is fine. The key is: don’t install everything globally.
Versioning and reproducibility
In real ML work, reproducibility matters.
- pin versions (
requirements.txtrequirements.txtorpyproject.tomlpyproject.toml) - record random seeds where needed
- log dataset versions
CPU vs GPU (what to know)
- Scikit-learn is mostly CPU-based.
- Deep learning frameworks can use GPU.
If you don’t have a GPU, you can still learn everything.
Quick sanity check script
Use this tiny script to confirm the stack imports.
ml_env_check.py
import numpy as np
import pandas as pd
import sklearn
print("numpy:", np.__version__)
print("pandas:", pd.__version__)
print("sklearn:", sklearn.__version__)
try:
import torch
print("torch:", torch.__version__)
except Exception as e:
print("torch: not installed", e)
try:
import tensorflow as tf
print("tensorflow:", tf.__version__)
except Exception as e:
print("tensorflow: not installed", e)ml_env_check.py
import numpy as np
import pandas as pd
import sklearn
print("numpy:", np.__version__)
print("pandas:", pd.__version__)
print("sklearn:", sklearn.__version__)
try:
import torch
print("torch:", torch.__version__)
except Exception as e:
print("torch: not installed", e)
try:
import tensorflow as tf
print("tensorflow:", tf.__version__)
except Exception as e:
print("tensorflow: not installed", e)Common pitfalls
- Installing both TensorFlow and PyTorch in the same environment can be heavy.
- GPU installs can be OS/driver-specific.
If you want a minimal setup to start Phase 1–7, you can do scikit-learn only and add deep learning libraries later.
If this helped you, consider buying me a coffee ☕
Buy me a coffeeWas this page helpful?
Let us know how we did
