This is a textbook repository for the ETHZ Machine Learning for Mechanical Engineering course.
This guide provides step-by-step instructions to set up the machine learning environment required for this course. No prior Python experience is required.
For students who prefer a cloud-based environment without local installation:
- Go to colab.research.google.com
- Sign in with your Google account
- Click "New Notebook"
- Upload any
.ipynb
file from this book (from thenotebooks
folder) - Install required packages by running this in the first cell:
!pip install torch torchvision torchaudio !pip install numpy matplotlib seaborn scikit-learn pandas scipy
- Enable GPU (optional): Runtime β Change runtime type β GPU β Save
Benefits:
- No local installation required
- Free GPU access (CUDA automatically configured)
- Runs entirely in your browser
- All packages pre-installed except ML libraries
Note: You will need to reinstall packages each time you start a new Colab session.
You need these 2 things:
-
Miniforge (Python package manager)
- Download from the official conda-forge website
- Choose the appropriate installer for your operating system
- Windows: Double-click the
.exe
file and follow the installer - Mac/Linux: After downloading, run these commands in Terminal:
# For Mac (choose the right one for your chip): chmod +x Miniforge3-latest-MacOSX-arm64.sh # Apple Silicon (M1/M2/M3) # or chmod +x Miniforge3-latest-MacOSX-x86_64.sh # Intel Mac # or chmod +x Miniforge3-latest-Linux-x86_64.sh # Linux # Then run the appropriate installer: ./Miniforge3-latest-MacOSX-arm64.sh # Apple Silicon # or ./Miniforge3-latest-MacOSX-x86_64.sh # Intel Mac # or ./Miniforge3-latest-Linux-x86_64.sh # Linux
-
VS Code (code editor)
- Download from code.visualstudio.com
- Install it (just click through the installer)
Copy this book to your computer (choose one method):
Method A: VS Code Git Clone (Recommended)
- Open VS Code
- Press
Ctrl+Shift+P
(Windows/Linux) orCmd+Shift+P
(Mac) - Type "Git: Clone" and press Enter
- Paste this URL:
https://github.com/IDEALLab/ML4ME_Textbook.git
- Choose a folder (like Desktop or Documents)
- Wait for it to download
Method B: Direct Download (Easiest)
- Go to github.com/IDEALLab/ML4ME_Textbook
- Click "Code" β "Download ZIP"
- Extract the ZIP file to your desired folder
- Open the folder in VS Code
This installs everything automatically:
-
Open Terminal/Command Prompt:
- Windows: Open "Miniforge Prompt" from Start Menu (NOT regular Command Prompt!)
- Mac: Press
Cmd+Space
, type "Terminal", press Enter - Linux: Press
Ctrl+Alt+T
-
Navigate to the book folder:
cd ML4ME_Textbook
-
Run the setup script:
- Windows: Type
python bootstrap_env.py
in Miniforge Prompt - Mac/Linux: Type
python bootstrap_env.py
in terminal
- Windows: Type
-
Wait 5-10 minutes (the script downloads and installs required software)
-
Setup complete
You only need a GitHub account if you want to:
- Contribute to the course materials
- Create your own repositories
- Use advanced Git features
To create a free account:
- Go to github.com
- Click "Sign up"
- Create your account (use your ETH email if you have one)
- Verify your email
Note: This is completely optional for just using the course materials.
The setup script automatically:
- β
Created a Python environment called
ml4me-student
- β Installed PyTorch (for deep learning) with proper CUDA support
- β Installed all ML libraries from the project dependencies (NumPy, Matplotlib, Pandas, Scikit-learn, Jupyter, etc.)
- β Set up everything needed to run the interactive notebooks
The complete textbook is available online at: https://ideal.umd.edu/ML4ME_Textbook/
VS Code provides an integrated development environment with excellent Jupyter support and is the recommended approach for this course.
- Open VS Code
- Open the book folder
- Click on any
.ipynb
file in thenotebooks
folder - VS Code will ask you to select a kernel - choose "ml4me-student"
- Start coding! The notebook will run directly in VS Code
Advantages of VS Code for ML development:
- Integrated experience - no switching between browser and terminal
- Smart autocomplete and IntelliSense for Python
- Built-in debugging tools for troubleshooting
- Git integration for version control
- Extension ecosystem for ML/AI development
- Integrated terminal for running commands
Every time you want to work on this book:
- Open VS Code
- Open the book folder (File β Open Folder)
- Click on any
.ipynb
file in thenotebooks
folder - Select "ml4me-student" kernel when prompted
- Start coding! Everything runs in VS Code
When you're done:
- Just close VS Code or the notebook file - that's it!
- Solution: Install Miniforge from conda-forge.org/download
- Restart your terminal after installing
- Solution: Make sure you have Python installed and accessible in your terminal
- Solution: Make sure you activated the environment:
conda activate ml4me-student
- Solution:
- Press
Ctrl+Shift+P
(orCmd+Shift+P
on Mac) - Type "Python: Select Interpreter"
- Choose the one with
ml4me-student
- Press
- Solution:
- Open a
.ipynb
file in VS Code - Method 1: Click on the kernel name in the top-right corner of the notebook
- Method 2: Press
Ctrl+Shift+P
(orCmd+Shift+P
on Mac), type "Notebook: Select Notebook Kernel" - Select "ml4me-student" from the list
- If not listed, select "Select Another Kernel" β "Python Environments" β "ml4me-student"
- Open a
- Solution: Always use "Miniforge Prompt" from Start Menu, NOT regular Command Prompt
- Solution: Use Method B (Direct Download) instead, or create a free GitHub account if you want to use Git features
- Solution: Run the package installation cell first:
!pip install torch torchvision torchaudio !pip install numpy matplotlib seaborn scikit-learn pandas scipy
- Solution:
- Runtime β Restart runtime
- Or use CPU: Runtime β Change runtime type β CPU β Save
- Solution: This is normal - just reconnect and re-run the package installation cell
What you want to do | Command |
---|---|
Activate environment | conda activate ml4me-student |
Deactivate environment | conda deactivate |
Check Python version | python --version |
List installed packages | pip list |
Update a package | pip install --upgrade package_name |
- Check this guide first - most common problems are covered here
- Ask your classmates - they may have encountered the same issue
- Contact your instructor for additional support
- "Module not found" β Make sure you selected the "ml4me-student" kernel in VS Code
- CUDA/NVIDIA messages when activating environment β This is normal on Windows/Linux with NVIDIA GPUs; macOS doesn't show these because CUDA packages aren't present there
I am using Quarto for this book, and you can render the book using the following steps:
- Install Quarto.
- Clone this repository.
- Preview the book via the command line (allows you to edit the book and see changes live):
quarto preview
- Render the book via the command line (allows you to compile the book into HTML in
_book
):
quarto render
- If you want to render the book into PDF (will be placed in the
_book
folder), you can use:
quarto render --to pdf
You now have a complete machine learning environment set up. You can:
- Read the interactive textbook
- Run all the example notebooks
- Complete the problem sets
- Start your own ML projects
This setup guide was created to make machine learning accessible to everyone, regardless of their programming background. If you have suggestions for improvements, please let us know!