Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

9 Commits

Folders and files

Repository files navigation

Algorithms for Data Science Base Environment Setup Guide

Note: If you need further explanations and instructions on how to use this repo for submitting assignments please see Student Workflow Guide

This guide will help you set up a Python development environment for this course using modern Python tools. All of our homework and programming assignments were created and completed using this environment. You may add to the environment if you so choose, we are just providing a base environment to help start you on the right foot. We will update this repository as Python changes but it works as of 1/19/2026.

Claude Code wrote the instructions on how to do this for Windows as I have never used pyenv with Windows so mileage may vary. I would suggest using your WSL2 Linux environment to do your work for this course if you are using a Windows machine.

Prerequisites

You'll need to install two tools:

  1. pyenv - to manage Python versions
  2. uv - to manage virtual environments and dependencies (faster alternative to pip/venv)

Step 1: Install pyenv

On macOS/Linux:

# Install pyenv
curl https://pyenv.run | bash

# Add to your shell configuration (~/.bashrc, ~/.zshrc, or ~/.bash_profile)
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc

# Reload your shell
source ~/.bashrc

On Windows:

Use pyenv-win:

# In PowerShell
Invoke-WebRequest -UseBasicParsing -Uri "https://raw.githubusercontent.com/pyenv-win/pyenv-win/master/pyenv-win/install-pyenv-win.ps1" -OutFile "./install-pyenv-win.ps1"; &"./install-pyenv-win.ps1"

Then restart your terminal.

Step 2: Install Python 3.13 with pyenv

# Install Python 3.13 (latest version)
pyenv install 3.13

# Set it as your global Python version (optional)
pyenv global 3.13

# Verify installation
python --version
# Should show: Python 3.13.x

Step 3: Install uv

On macOS/Linux:

curl -LsSf https://astral.sh/uv/install.sh | sh

On Windows:

powershell -c "irm https://astral.sh/uv/install.ps1 | iex"

Alternative (using pip):

pip install uv

Step 4: Set Up This Project

  1. Navigate to the project directory:
cd path/to/base-environment
  1. Create and sync the virtual environment:
uv sync

This command will:

  • Create a .venv directory with a virtual environment
  • Install all required dependencies listed in pyproject.toml
  • Create/update a uv.lock file to ensure reproducible installs
  1. Activate the virtual environment:

On macOS/Linux:

source .venv/bin/activate

On Windows (PowerShell):

.venv\Scripts\Activate.ps1

On Windows (Command Prompt):

.venv\Scripts\activate.bat

You should see (base-environment) appear in your terminal prompt.

Step 5: Test Your Installation

Run the test script to verify everything is working:

python main.py

If all dependencies are installed correctly, the script will confirm your setup is complete.

Daily Workflow

When you start working on this project:

  1. Activate the virtual environment:

    source .venv/bin/activate  # macOS/Linux
    .venv\Scripts\Activate.ps1  # Windows PowerShell
  2. Work on your code - all packages will be available

  3. Deactivate when done:

    deactivate

Managing Dependencies

Adding a new package:

uv add package-name

Removing a package:

uv remove package-name

Updating all packages:

uv sync --upgrade

Installed Packages

This environment includes the following packages for algorithms and machine learning coursework:

  • Data Processing: numpy, pandas, scipy
  • Visualization: matplotlib, seaborn, plotly
  • Machine Learning: scikit-learn, tensorflow, torch (PyTorch), transformers
  • Statistical Analysis: statsmodels, lifelines
  • Optimization: cvxopt
  • Probabilistic Models: pgmpy
  • Datasets: datasets (Hugging Face)
  • Notebooks: jupyter, ipykernel

Troubleshooting

Python version mismatch

If uv sync fails due to Python version, ensure you're using Python 3.13:

python --version
pyenv local 3.13  # Set Python 3.13 for this directory

uv command not found

Restart your terminal after installing uv, or add it to your PATH manually.

Virtual environment activation issues (Windows)

If you get a script execution error on Windows, run:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Why uv?

uv is a modern Python package manager written in Rust that is:

  • 10-100x faster than pip
  • More reliable with better dependency resolution
  • Compatible with existing Python tools and workflows
  • Simpler with commands like uv add and uv sync

Included Reference Codebase

Once you have the environment set up, this repository also includes Python implementations from a well-known AI algorithms textbook:

  • aima/ — Implementations from Artificial Intelligence: A Modern Approach (AIMA), with interactive Jupyter notebooks

This is an excellent resource for understanding how the algorithms we cover in class actually work. When you're stuck on an algorithm, look at the reference implementation first — reading real code is often more helpful than asking ChatGPT or Claude, which can hallucinate details or give you subtly incorrect explanations. The textbook code is vetted, matches the pseudocode you'll see in lectures, and will build stronger intuition than an AI-generated summary.

How to use the AIMA code

Browse the notebooks — open any .ipynb file inside aima/ with Jupyter to see worked examples and visualizations:

jupyter notebook aima/search.ipynb

Import modules directly in your own notebooks or scripts:

from aima.search import astar_search, breadth_first_graph_search
from aima.mdp import value_iteration
from aima.csp import backtracking_search

Note: Because aima/ lives at the root of this repo (not installed as a package), you need to run your code from the repo root so Python can find it. If you activate the virtual environment and launch Jupyter from the repo root, imports will work automatically.

Run the AIMA test suite to verify your understanding of how the algorithms behave:

python -m pytest aima/tests/

See the aima/README.md for a full index of every implemented algorithm and which file it lives in.


Troubleshooting

pyenv install 3.13 fails with a build error (common on WSL2/Ubuntu):

If this is your first time setting up Python on the machine, you may be missing build prerequisites that pyenv needs to compile Python from source. Install the suggested dependencies for Ubuntu/Debian (from pyenv's build environment guide):

sudo apt update
sudo apt install make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev curl git \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev

Then retry:

pyenv install 3.13

pyenv not found after installation:

  • Make sure you added pyenv to your shell configuration and restarted your terminal

uv command not found:

  • Restart your terminal after installing uv

Python version mismatch:

  • Run pyenv local 3.13 in the project directory

Package import errors:

  • Make sure your virtual environment is activated: source .venv/bin/activate
  • Run uv sync to ensure all packages are installed

Questions?

If you have questions about the environment setup, please ask during office hours or post on the question and answer discussion board.

Additional Resources

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages