Development Environments
The development environment for ML will largely depend on what technologies we choose (or are chosen for us, e.g., by the company we work for).
Let’s have a look at what a typical development environment might look like.
This Lesson Will Cover
- 💻 Terminal usage for ML development tasks
- 🛠️ IDEs with a focus on VS Code
- 📓 Jupyter Notebooks for interactive development
- ☁️ Cloud-based notebook solutions
- 🐳 Docker for ML environment management
Terminal
There’s a whole category of things that can (or at least, should) only be done in the terminal.
Stuff like:
- Setting up Python environments (e.g.,
virtualenv, Conda) and installing dependencies - Running scripts and executing tests while developing
- Using Cloud Platform CLIs (e.g., AWS CLI, Azure CLI, or Google Cloud CLI) for managing resources
- Executing Git commands for version control and collaboration
IDEs
VS Code
Visual Studio Code (VS Code) is a popular, lightweight IDE offering robust features for machine learning development:
- Extensions for Python, Jupyter, and Git integration
- Linting and debugging tools to catch errors early
- AI tools like Copilot for faster coding
It’s really easy to get up and running with VS Code:
- Install VS Code.
- Add the Python and Jupyter extensions.
- Open a folder for our ML project and start coding.
When I’m using VS Code, I’ll create a project folder using the terminal, then cd into it and run code . to open the IDE.
Of course, my preferred IDE is Neovim[1], but that’s a whole course in itself ;)
Cursor
Cursor is a AI Code Editor that was forked from VS Code, meaning it’s a drop-in replacement but with excellent AI features.
I strongly encourage you to give Cursor a try[2]. For me, it’s almost completely replaced VS Code in my development workflow.
Jupyter Notebooks
Jupyter Notebooks are interactive coding environments, ideal for data analysis, visualization, and prototyping machine learning models (or just testing anything out—I use them all the time for testing code as I built applications).
They allow us to write and execute Python code in blocks, mixing it with Markdown documentation.
Why use Jupyter for ML/AI?
- Exploration: Ideal for prototyping new ideas, analyzing data, testing models, experimenting with APIs, etc.
- Visualization: Seamlessly integrates with libraries like Matplotlib, Seaborn, Altair, etc.
- Documentation: Combine code and Markdown to track our thoughts and log information for later reference.
To start with Jupyter:
pip install notebook
jupyter notebook
Jupyter Notebooks also work really well in VS Code, if we have the Jupyter extension added:
- Open VS Code
- Ensure that we have the Jupyter extension installed
- Create a new file with an
.ipynbextension - Open the file and select a Python kernel (e.g., a virtual environment) to use for our Jupyter Notebook
VS Code is my preferred way of using Notebooks because I can use Vim keybindings[3].
Cloud Notebooks (Google Colab, AWS SageMaker)
Cloud notebooks provide the flexibility to run experiments without worrying about local resource limitations.
Google Colab
Google Colab is a free, cloud-based notebook platform that allows us to access cloud GPUs. It’s perfect for quick experiments and collaboration.
Key features:
- Free access to GPUs/TPUs
- Built-in libraries for ML (e.g., TensorFlow, PyTorch)
- Easy sharing via Google Drive
AWS SageMaker Notebooks
Amazon SageMaker provides managed Jupyter notebooks for large-scale machine learning projects. It integrates nicely with other AWS services.
Benefits:
- Scalability: Spin up high-powered instances for resource-heavy tasks.
- Integration: Access data directly from S3 or train models with SageMaker’s built-in algorithms.
Example: Launching a SageMaker notebook instance:
- Go to the SageMaker console on AWS.
- Create a notebook instance and configure its environment.
- Start coding in the cloud!
Docker
Docker is a containerization tool for creating reproducible development environments. It’s extremely useful for application development, including ML projects. It allows us to package code, dependencies, and runtime instructions. An image can also include operating-system user-space libraries and utilities. Containers share the host kernel; the image does not supply a separate running kernel. This extends dependency control beyond a Python virtual environment.
Why Docker for ML?
- Reproducibility: Ensures models work the same way across different environments
- Dependency Management: Isolates project dependencies to avoid conflicts
- Scalability: Easy to deploy models from development to production
- Version Control: Track different versions of our ML environment
Example Dockerfile for an ML project:
FROM python:3.12-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["python", "train.py"]
To get started:
- Install Docker on your machine
- Create a Dockerfile in your project
- Build and run your container:
docker build -t ml-project .
docker run ml-project
Example train.py
import numpy as np
from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score
# Generate sample data
X, y = make_classification(n_samples=1000, n_features=20, n_classes=2, random_state=42)
print(X.shape, y.shape)
# Split data
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# Train model
model = LogisticRegression()
print(model)
model.fit(X_train, y_train)
# Make predictions
y_pred = model.predict(X_test)
# Calculate accuracy
accuracy = accuracy_score(y_test, y_pred)
print(f"Model accuracy: {accuracy:.2f}")
Example requirements.txt
numpy==2.2.0
scikit-learn==1.6.0
Conclusion
I love dev tools! Shout out to all the open-source maintainers out there who choose to spend their time building these things for us.
Of course, not everything we looked at above is open source, but everything (in fact, everything in this entire course) is only possible because of open-source tools and technologies! Woah…
Key Takeaways
💻 Terminal usage is essential for ML development tasks like environment management, running scripts, and using cloud CLIs.
🖥️ VS Code provides a robust IDE environment with extensions for Python, Jupyter, and Git integration.
📓 Jupyter Notebooks enable interactive development with code execution, visualization, and documentation capabilities.
☁️ Cloud notebooks like Google Colab and AWS SageMaker provide scalable compute resources for ML projects.
📦 Docker containers ensure reproducible ML environments and simplify deployment across different systems.
Next: Machine Learning Libraries
And speaking of open source, let’s continue with the next lesson, where we’ll be looking at some of the most popular ML libraries for Python.
Footnotes
Neovim Lazy Lua IDE—my simple but powerful setup is one of my top YouTube videos, sitting at 66k views with 1.4k likes and 2 dislikes. It would probably be a good place to start if you want to setup Neovim. ↩︎
In my Neovim + Cursor—The Dual Workflow video, I share more thoughts on Cursor and why you should consider using it. ↩︎
Using vim keybindings in VS Code requires zero setup. Just click “Install” on the extension. It’s a good way to get started learning vim. ↩︎
Comments (0)
No comments yet.