Setup Project 1

Python & Data Science Environment Setup

Install and configure the Anaconda python distribution, VS Code with Python/Jupyter extensions, manage conda virtual environments, and verify the numerical toolchain inside a VirtualBox Linux VM.

Environment
VirtualBox / Linux (Ubuntu)
Difficulty
Beginner (1/5)
Course Module
Introduction to AI & ML
Deliverables
Imports & Version Verification Plot
1. System Architecture & Process Workflow

The diagram below outlines the virtualized sandbox runtime stack. It illustrates how the host computer runs VirtualBox to manage a Linux VM container, which in turn manages isolated Conda environments housing our Python packages, rendering interfaces locally via VS Code and Jupyter Notebook.

VIRTUALIZATION HIERARCHY Physical Host Machine (Windows OS) Hypervisor (Oracle VM VirtualBox) Guest VM (Ubuntu Linux Desktop OS) Python Conda Env (ds_ai_ml) DATA SCIENCE ENVIRONMENT STACK Developer Interfaces: VS Code / Jupyter Conda Environment: ds_ai_ml NumPy Pandas Matplotlib
2. Part 1: Step-by-Step Action Items & Key Execution Steps
STEP 1

Boot Ubuntu Virtual Machine inside VirtualBox

Launch your guest operating system environment in Oracle VM VirtualBox and access the user desktop shell.

Launch Oracle VM VirtualBox -> Click Ubuntu VM -> Click Green "Start" Arrow -> Enter Credentials
This action initializes the hardware hypervisor, spins up the virtual hard disk, boots Ubuntu Linux Kernel, and presents the graphical login session.
STEP 2

Open the Ubuntu Linux Shell Terminal

Trigger the command-line interface to begin configuring system dependencies and software installers.

Click bottom-left Application Menu -> Search "terminal" -> Click "Terminal" Icon (or press Ctrl + Alt + T)
This action opens the bash command console emulator, providing root administrative command control over the Linux guest system.
STEP 3

Update Local Linux Repositories and Utilities

Download refreshed package indexes from Ubuntu servers to ensure secure and compatible tool installations.

$ sudo apt update && sudo apt install -y curl wget gpg
This command refreshes the local cache of available packages and installs core web retrieval tools needed for Anaconda and VS Code binaries.
STEP 4

Download the Anaconda Distribution Installation Script

Fetch the official Bash installer file for Anaconda from the public repository servers using wget.

$ wget https://repo.anaconda.com/archive/Anaconda3-2024.06-1-Linux-x86_64.sh -O ~/anaconda-installer.sh
This command retrieves the Anaconda installer shell script via HTTP and saves it locally in the home folder as an executable utility.
STEP 5

Execute Anaconda Installation and Initialize Conda

Run the downloaded installer script, accept the license agreements, specify directories, and bootstrap the shell profile.

$ bash ~/anaconda-installer.sh
This command invokes the installer shell script. Follow these prompt steps to complete the installation:
1. Press Enter: When the terminal shows "Welcome to Anaconda3", press the **Enter** key to start reading the terms.
2. Press Spacebar: Tap the **Spacebar** repeatedly to page down through the End User License Agreement (EULA).
3. Type "yes": Once the terms are fully displayed, type **yes** and press **Enter** to accept.
4. Press Enter for Location: Press **Enter** to confirm the default folder path (`/home/your_user/anaconda3`).
5. Type "yes" for Init: When asked if you want to run `conda init` to update your shell startup scripts, type **yes** and press **Enter**.
STEP 6

Refresh the Active Shell Environment

Reload bash configuration properties so the terminal session recognizes the new conda executable paths immediately.

$ source ~/.bashrc
This command parses and updates the environmental parameters of the current session, enabling command auto-completion and access to the conda package manager.
STEP 7

Install Visual Studio Code Editor via Snap

Install VS Code in Ubuntu utilizing snap containers to handle desktop integrations automatically.

$ sudo snap install --classic code
This command downloads and configures Visual Studio Code with classic confinement permissions, ensuring full file access inside the desktop shell.
STEP 8

Configure VS Code Python & Jupyter Extensions

Open the editor, navigate the marketplace interface, and enable python/notebook debugging features.

Launch VS Code -> Click Extensions Icon in Left Sidebar -> Search "Python" -> Click "Install" -> Search "Jupyter" -> Click "Install"
This GUI sequence installs language engines and notebook parsers inside VS Code, allowing interactive block-by-block coding.
STEP 9

Create the Dedicated ds_ai_ml Virtual Environment

Instantiate an isolated workspace directory with a custom Python version to protect the course tools from system configuration shifts.

$ conda create -n ds_ai_ml python=3.10 -y
This command instructs conda to create a new sandbox environment named `ds_ai_ml` running Python version 3.10 without waiting for a confirmation prompt.
STEP 10

Activate Workspace and Install Target Data Libraries

Move the shell pointer into the new virtual sandbox and install numpy, pandas, matplotlib, and jupyter.

$ conda activate ds_ai_ml && conda install -y numpy pandas matplotlib jupyter
This command points the terminal session to the new environment and pulls stable package binary files into the isolated local library cache.
STEP 11

Launch and Verify Jupyter Notebook in Firefox

Start the notebook web server container, open Firefox, launch a notebook, and test software imports.

$ jupyter notebook --no-browser
This command starts the local web server hosting Jupyter. Follow these steps to verify:
1. Copy Server Token: Locate the terminal lines containing `http://localhost:8888/?token=...`. Highlight and copy this address.
2. Open Firefox: Click the Firefox web browser icon in the Ubuntu dock.
3. Access Dashboard: Paste the copied link in the URL address bar and press **Enter**.
4. Create Notebook: Click the **New** dropdown button in the upper right, and choose **Python 3 (ipykernel)**.
5. Enter & Execute Test: Paste the verification script inside the first cell and press **Shift + Enter** to execute.
STEP 12

Connect VS Code to the Conda Python Kernel

Load the project directory in VS Code, create a jupyter file, select the active sandbox engine, and run test cells.

Click File -> Open Folder -> Create "verify.ipynb" -> Click "Select Kernel" in Top-Right -> Choose "Python Environments" -> Select "ds_ai_ml"
This configuration binds VS Code to our isolated conda python engine, allowing notebook execution directly from the IDE window.
3. Operational Pipeline Architecture

The flow chart below traces the automated installation sequence, demonstrating transitions from updating local OS repositories to installing Anaconda, setting up the isolated environment, and executing code verification.

1. OS Update Refresh apt caches and install curl sudo apt update 2. Anaconda Run installer shell script & accept init bash installer.sh 3. VS Code Install code and Python extensions snap install code 4. Create Env Setup ds_ai_ml with dependencies conda create 5. Verification Run python test and check graph verify_env.py
4. Part 2: Complete Deliverable Assets & Production Templates

To verify that all libraries (NumPy, Pandas, Matplotlib) are installed correctly, we will build a Python verification script. Below is a line-by-line explanation of the code, followed by the combined script.

Step-by-Step Code Construction

Lines 1 - 2

Import Core System Libraries

Include system diagnostics library to print version information.

import sys import os
These imports check system paths, fetch directory configurations, and output the exact active Python interpreter details.
Lines 3 - 5

Import Data Science Libraries

Import NumPy, Pandas, and Matplotlib to confirm they reside in our conda path.

import numpy as np import pandas as pd import matplotlib import matplotlib.pyplot as plt
These commands verify packages are correctly loaded from active environment paths, throwing errors if any library is missing.
Lines 6 - 9

Print Environment Diagnostic Versions

Print the active runtime compiler build and version string details of all modules.

print(f"Python Version: {sys.version}") print(f"NumPy Version: {np.__version__}") print(f"Pandas Version: {pd.__version__}") print(f"Matplotlib Version: {matplotlib.__version__}")
This diagnostic outputs active library build versions, helping identify setup mismatches.
Lines 10 - 12

Generate Mathematical Arrays

Use NumPy to build 100 values to represent input measurements.

x_values = np.linspace(0, 10, 100) y_values = np.sin(x_values)
These statements instantiate a 1D vector of elements, calculating matching values to verify core CPU math capabilities.
Lines 13 - 15

Assemble DataFrames

Load vectors into a tabular DataFrame to test dataset configurations.

data_dict = {"X": x_values, "Y": y_values} data_frame = pd.DataFrame(data_dict) print("\nFirst 5 Rows of Verification Data:") print(data_frame.head())
This binds variables into column-oriented structures, displaying raw rows to verify memory allocations.
Lines 16 - 24

Generate Verification Image

Assemble a styled plot and save it to disk to verify graphics libraries work.

plt.figure(figsize=(8, 4)) plt.plot(data_frame["X"], data_frame["Y"], label="Sine Wave", color="#38bdf8", linewidth=2) plt.title("Environment Verification Plot", color="#f8fafc", fontsize=12) plt.xlabel("X Index", color="#94a3b8") plt.ylabel("sin(X)", color="#94a3b8") plt.grid(True, linestyle="--", alpha=0.5, color="#334155") plt.legend() plt.savefig("verification_plot.png", facecolor="#0f172a", edgecolor="none") print("\nTest plot saved successfully as 'verification_plot.png'!")
This calls plotting routines to render labels, grids, and boundaries, saving the plot as a PNG image inside the working folder.

Combined Verification Script

Save the consolidated blocks above as ~/verify_env.py and execute it inside your active ds_ai_ml environment:

# verify_env.py - Data Science Environment Verification Engine import sys import os import numpy as np import pandas as pd import matplotlib import matplotlib.pyplot as plt def main(): print("=== Python & Data Science Environment Diagnostics ===") print(f"Python Version: {sys.version}") print(f"NumPy Version: {np.__version__}") print(f"Pandas Version: {pd.__version__}") print(f"Matplotlib Version: {matplotlib.__version__}") # Mathematical computation verification x_values = np.linspace(0, 10, 100) y_values = np.sin(x_values) # Tabular data manipulation verification data_dict = {"X": x_values, "Y": y_values} data_frame = pd.DataFrame(data_dict) print("\nFirst 5 Rows of Verification Data:") print(data_frame.head()) # Graphical rendering verification plt.figure(figsize=(8, 4)) plt.plot(data_frame["X"], data_frame["Y"], label="Sine Wave", color="#38bdf8", linewidth=2) plt.title("Environment Verification Plot", color="#f8fafc", fontsize=12) plt.xlabel("X Index", color="#94a3b8") plt.ylabel("sin(X)", color="#94a3b8") plt.grid(True, linestyle="--", alpha=0.5, color="#334155") plt.legend() # Save under current directory plot_filename = "verification_plot.png" plt.savefig(plot_filename, facecolor="#0f172a", edgecolor="none") print(f"\nTest plot saved successfully as '{plot_filename}'!") print("=== Environment Setup Successfully Verified! ===") if __name__ == "__main__": main()
5. Deliverables Summary

Ensure the following assets are present on your virtual system before marking the project as complete.

Created Files / Templates

  • ~/verify_env.py - Verification python script file.
  • ~/verification_plot.png - Plot file output validating matplotlib dependencies.

Verification Artifacts / Execution Proof

  • Terminal output detailing success lines from verify_env.py execution.
  • Jupyter notebook showing importing blocks and inline plots running inside the browser.
  • VS Code window demonstrating active ds_ai_ml interpreter status.
6. Closing Explanation: Why We Did This & What It Accomplishes

Architectural Intent & Operational Impact

Why We Did This

What This Accomplishes