Setup
This guide helps you set up your environment for the AI/ML tutorials.
We support two paths:
- Rust for performance and safety.
- Python for ecosystem richness and beginner-friendliness.
Choose the language you prefer (or follow both for cross-learning).
Both setups include installing the language, libraries, IDE, and verifying with a simple program.
Setup with Rust
Section titled “Setup with Rust”Step 1: Install Rust
Section titled “Step 1: Install Rust”- Visit rust-lang.org.
- Install rustup:
On Unix-like systems (macOS/Linux):On Windows, follow the instructions on the website.Terminal window curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh - Update Rust:
Terminal window rustup update - Verify installation:
Terminal window rustc --versioncargo --version
Step 2: IDE Setup
Section titled “Step 2: IDE Setup”Use Visual Studio Code (VS Code):
- Install VS Code.
- Add the
rust-analyzerextension.
Step 3: Create a Rust Project
Section titled “Step 3: Create a Rust Project”cargo new rust_ml_tutorialcd rust_ml_tutorialcargo runExpect “Hello, world!” output.
Step 4: Install ML Libraries
Section titled “Step 4: Install ML Libraries”Add dependencies in Cargo.toml:
[dependencies]linfa = "0.7"nalgebra = "0.32"tch = "0.13"polars = "0.32"rust-bert = "0.24"actix-web = "4"plotters = "0.3"ndarray = "0.15"rand = "0.8"statrs = "0.16"Run:
cargo buildStep 5: Verify Rust Setup
Section titled “Step 5: Verify Rust Setup”Test with a matrix:
use nalgebra::Matrix2;
fn main() { let matrix = Matrix2::new(1.0, 2.0, 3.0, 4.0); println!("Matrix:\n{}", matrix);}cargo runSetup with Python
Section titled “Setup with Python”Step 1: Install Python
Section titled “Step 1: Install Python”- Install Python 3.11+ from python.org or use Anaconda.
- Verify installation:
Terminal window python --versionpip --version
Step 2: Create a Virtual Environment
Section titled “Step 2: Create a Virtual Environment”python -m venv venvsource venv/bin/activate # macOS/Linuxvenv\Scripts\activate # WindowsStep 3: Install ML Libraries
Section titled “Step 3: Install ML Libraries”pip install numpy pandas scikit-learn torch tensorflow matplotlib seaborn jupyterStep 4: IDE Setup
Section titled “Step 4: IDE Setup”Use VS Code or Jupyter Notebook:
- Install VS Code.
- Add the Python extension.
- Or, run notebooks:
Terminal window jupyter notebook
Step 5: Verify Python Setup
Section titled “Step 5: Verify Python Setup”import numpy as np
matrix = np.array([[1, 2], [3, 4]])print("Matrix:\n", matrix)Run:
python main.pyTroubleshooting
Section titled “Troubleshooting”- Rust issues: reinstall via rust-lang.org.
- Python issues: ensure pip is updated (
pip install --upgrade pip). - Library conflicts: use
cargo clean(Rust) orpip uninstall/pip freeze(Python). - IDE issues: check extensions (
rust-analyzer, Python).
Next Steps
Section titled “Next Steps”- For Rust: continue to Rust Basics.
- For Python: continue to Python Basics.
Further Reading
Section titled “Further Reading”- Rust: nalgebra.org, Hands-On Machine Learning (Ch. 2)
- Python: scikit-learn docs, Deep Learning with Python by Chollet