Why Your Environment Matters
Before writing a single line of ML code, you need a reproducible, isolated workspace. Dependency hell — where two projects need incompatible library versions — kills productivity fast. Setting up properly once saves dozens of hours later.
Python for ML
Python dominates ML because of its ecosystem, not its speed. The heavy computation in NumPy, PyTorch, and TensorFlow runs in optimised C/Fortran under the hood — Python is just the glue. Stick to Python 3.10+.
Conda: Environment & Package Manager
Conda manages both Python versions and non-Python dependencies (like CUDA for GPU support). Each project gets its own isolated environment.
# Install Miniconda (lightweight Conda) from https://docs.conda.io
# Create a dedicated ML environment
conda create -n zerotoml python=3.11 -y
conda activate zerotoml
# Install the core ML stack
conda install numpy pandas matplotlib seaborn scikit-learn jupyter -y
pip install xgboost lightgbm catboost plotly
# Save your environment so teammates can replicate it exactly
conda env export > environment.yml
# Anyone can recreate it with:
conda env create -f environment.yml
Pip: When to Use It
Pip is Python's built-in package manager. Use Conda for environment management and Pip for packages not in the Conda channel. Always activate your Conda environment first.
# Check installed packages
pip list
# Install a specific version
pip install scikit-learn==1.4.0
# Install from a requirements file
pip install -r requirements.txt
# Freeze current environment (pip only)
pip freeze > requirements.txt
Jupyter Notebooks & JupyterLab
Jupyter notebooks (.ipynb) interleave code, outputs, markdown, and plots in one document.
They're the standard tool for exploration, experimentation, and teaching ML.
# Launch classic Notebook
jupyter notebook
# Launch JupyterLab (modern, recommended)
jupyter lab
# Register your Conda env as a Jupyter kernel
pip install ipykernel
python -m ipykernel install --user --name zerotoml --display-name "ZeroToML"
Project Structure
A clean folder layout prevents chaos on longer projects:
my-ml-project/
├── data/
│ ├── raw/ # original, never-modified data
│ └── processed/ # cleaned, feature-engineered data
├── notebooks/ # exploration & EDA notebooks
├── src/ # reusable Python modules
│ ├── features.py
│ └── models.py
├── models/ # saved model artefacts (.pkl, .joblib)
├── reports/ # generated figures, reports
├── environment.yml
└── README.md
data/processed/. This way you can always re-run the pipeline from scratch.VS Code as a Jupyter IDE
VS Code with the Jupyter and Python extensions gives you the best of both
worlds: notebook interactivity with full IDE features (intellisense, debugging, git). Install the extensions
and open any .ipynb file directly.
Summary
- Use Conda to create isolated environments per project. Export with
conda env export. - Use Pip inside Conda for packages not on the Conda channel.
- JupyterLab is the recommended interface for exploration and prototyping.
- Keep raw data read-only. Structure projects consistently from day one.