1. Introduction
In this session, we’ll walk through everything you need to set up your machine learning environment from scratch. This includes installing essential tools like Anaconda, working with Jupyter Notebook, and setting up a virtual environment to keep your project organized and dependency-free.
2.Tools Needed for Machine Learning Projects
Before diving into coding, there are a few important tools we need to install:
a. Anaconda
Anaconda is a distribution of Python and R for scientific computing. It comes preloaded with libraries like NumPy, Pandas, Matplotlib, and more — all of which are widely used in machine learning and data science.
b. Jupyter Notebook
Jupyter Notebook is a web-based interactive development environment. It allows you to write code in blocks (cells), run each block individually, and visualize data using graphs or tables in the same interface.
c. Python Virtual Environment
Creating a virtual environment helps you manage dependencies specific to a project. This avoids conflicts between libraries and ensures your project is portable and reproducible.
3. Installing Anaconda
Follow these steps to install Anaconda:
- Visit the official website
Go to: https://www.anaconda.com - Download the installer
Choose the version suitable for your operating system (Windows, macOS, or Linux). Make sure to select the Python 3.x version. - Install Anaconda
- Run the downloaded installer.
- Follow the instructions (you can keep most options as default).
- Let the installation complete.
To check if Anaconda was installed successfully:
conda --version
You should see the installed version number if it’s installed properly.
4. Launching Jupyter Notebook
After installing Anaconda:
- Open Anaconda Navigator or Anaconda Prompt.
- Run the following command to start Jupyter Notebook:
jupyter notebook
Your browser will open with the Jupyter interface at:
https://localhost:8888/tree
Here you can create new notebooks (.ipynb
files), write and execute Python code, visualize data, and much more.
5. Creating a Virtual Environment (Using Anaconda Prompt)
To isolate your project and manage dependencies separately, create a virtual environment like this:
Step 1: Create the environment
conda create --name ml-env python=3.10
This creates a new environment named ml-env
with Python version 3.10.
Step 2: Activate the environment
conda activate ml-env
Now, any libraries you install will be confined to this environment.
Step 3: Install libraries
For example:
pip install numpy pandas matplotlib seaborn scikit-learn
You can install any machine learning libraries you need here.
Step 4: Use the environment in Jupyter Notebook
To make this environment available in Jupyter:
pip install ipykernel python -m ipykernel install --user --name=ml-env
Now when you open Jupyter Notebook, you’ll see ml-env
as an option under “Kernel”.