Introduction to
Machine Learning Lab
Lab 1
Machine Learning
A. S. M. Sanwar Hosen
Email: [email protected]
Date: 10 Sept. 2025
Introduction to Machine Learning Lab
❑ Programming Languages in ML Applications
Several programming languages are commonly used for developing ML models, data
preprocessing, and building ML applications. The choice of programming language often depends
on factors such as the specific ML framework you are using, your project requirements, and your
personal preferences. Here are some of the most popular programming languages for ML:
✓ Python
✓ R
✓ Julia
✓ Java
✓ C++
✓ JavaScript
✓ Scala
✓ Lua
✓ Go
✓ Swift 2
Introduction to Machine Learning Lab
❑ Python Libraries for ML
Python libraries encompass collections of modules housing valuable code snippets and functions,
sparing you the effort of crafting them anew. Below are the most used python libraries to kickstart
your expedition into the realm of ML:
✓ NumPy: It stands as a widely acclaimed python library, revered for its prowess in handling multi-
dimensional arrays and matrices, enabling an extensive range of mathematical operations.
✓ Scikit-learn: This is a highly renowned ML library, built upon the foundations of NumPy and SciPy, boasts
comprehensive support for a multitude of classic supervised and unsupervised learning algorithms.
Beyond that, it serves as a versatile tool for tasks encompassing data mining, modeling, and in-depth
analysis.
✓ Pandas: It is an another python library, built atop NumPy, plays a pivotal role in shaping high-level
datasets for machine learning endeavors. It hinges on two primary data structures: one-dimensional
(Series) and two-dimensional (DataFrame).
✓ TensorFlow: It is an open-source python library, excels in a field known as differentiable programming.
This capability allows it to autonomously calculate the derivatives of functions within a high-level
language. With TensorFlow’s adaptable architecture and framework, crafting and assessing both ML and
deep learning models becomes a straightforward endeavor.
3
Introduction to Machine Learning Lab
❑ Python Libraries for ML (cont..)
✓ Seaborn: Seaborn is another open-source python library, one that is based on Matplotlib (which focuses
on plotting and data visualization) but features Pandas’ data structures. Seaborn is often used in ML
projects because it can generate plots of learning data.
✓ Theano: Theano is a python library that focuses on numerical computation and is specifically made for
ML. It is able to optimize and evaluate mathematical models and matrix calculations that use multi-
dimensional arrays to create ML models.
✓ Keras: It is a python library that is designed specifically for developing the neural networks for ML
models. It can run on top of Theano and TensorFlow to train neural networks. Keras is flexible, portable,
and user-friendly, and easily integrated with multiple functions.
✓ PyTorch: PyTorch is an open-source ML python library based on the C programming language framework,
Torch. It is mainly used in ML applications that involve natural language processing or computer vision.
✓ Matplotlib: It is a python library focused on data visualization and primarily used for creating beautiful
graphs, plots, histograms, and bar charts. It is compatible for plotting data from SciPy, NumPy, and
Pandas.
4
Introduction to Machine Learning Lab
❑ Python IDE (Integrated Development Environment) for ML
An IDE is a software application or platform that provides a comprehensive set of tools and
features to streamline the development, debugging, and deployment of ML models and
applications. Here’s a list of the best python IDEs for data science and ML:
✓ Jupyter Notebook
✓ PyCharm
✓ Google Colaboratory
✓ Visual Studio Code
✓ Spyder
✓ Atom
✓ Thonny
5
Introduction to Machine Learning Lab
❑ Python Platforms for ML
In the context of ML, the term “python platform” refers to the combination of python
programming language and the associated libraries, frameworks, and tools that are commonly
used for ML development and research. Here are some of the python platforms:
✓ Anaconda
✓ Jupyter Notebook
✓ Google Colab
✓ Miniconda
✓ Virtual Environment (Python venv)
✓ MLflow
✓ Kubeflow
✓ RapidMiner
✓ KNIME
6
Introduction to Machine Learning Lab
❑ Python Platform, Libraries, and Packages Setup for ML
✓ Step 1: (Install anaconda): download and install from the following link
https://www.anaconda.com/
✓ Step 2: Open jupyter notebook (anaconda3).
✓ Step 3: Create a new notebook with python 3.
Click
✓ Step 4: Save a copy of the notebook’s content.
Click
7
Introduction to Machine Learning Lab
❑ Python Platform, Libraries, and Packages Setup for ML (cont..)
✓ Step 5: Install libraries (NumPy, TensorFlow, Keras, Pandas, Matplotlib, Seaborn): Write the code in the
jupyter notebook cell as follows:
8
Introduction to Machine Learning Lab
❑ Errors Handling during Installing Python Libraries and Packages for ML
✓ Step 6: Handling errors during installation, especially for version compatibility in the context of ML:
1) Check Python Version
2) Use Virtual Environments
3) Install Specific Version
4) Check Dependencies
5) Upgrade or Downgrade
9
Introduction to Machine Learning Lab
❑ Upload a Dataset
✓ In the jupyter notebook, navigate to the directory where you want to upload the dataset.
✓ Click the “Upload” button, usually located near the top-right corner of the dashboard. This will open a file
dialog.
✓ Select the dataset file you want to upload from your local computer and click “Open” (or equivalent) in
the file dialog.
✓ The dataset file will be uploaded to the current directory in your jupyter notebook workspace.
❑ Confirm the Upload
After uploading, you should see the dataset file listed in the jupyter notebook directory. You can click on the
file to open and work with it in your notebook.
10
Introduction to Machine Learning Lab
❑ Upload a Dataset
An Example:
1. Click
2. Select your
dataset stored
3. Click
11
Introduction to Machine Learning Lab
❑ Upload a Dataset (cont..)
An Example:
4. Click
12
Introduction to Machine Learning Lab
❑ How to Create Own Dataset in Python?
Dictionary: Dictionaries are generally defined in python by a list of comma-separated key-value pairs
wrapped around curly braces ({ }) . Each key is separated from its associated value by a colon (:). You can
also define a dictionary by using its constructor, 𝑑𝑖𝑐𝑡() . It can accept a collection of key-value pairs.
13
Introduction to Machine Learning Lab
❑ How to Create Own Dataset using CSV in Excel (cont..)?
CSV File: A CSV file, which stands for “Comma-Separated Values,” is a plain text file format commonly used
for storing and exchanging tabular data. CSV files are a simple and widely supported way to represent
structured data, making them a popular choice for data storage and data exchange between different
software applications and platforms.
1. Click
2. Click
14
Introduction to Machine Learning Lab
❑ How to Load/Read a Dataset into Jupyter Notebook?
An Example of loading ‘iris.csv’ dataset:
Input feature
Output feature
15
Introduction to Machine Learning Lab
❑ How to See the Information of a Dataset?
An Example showing samples of the ‘iris.csv’ dataset:
16
Introduction to Machine Learning Lab
❑ How to See the Information of a Dataset (cont..)?
An Example of showing information (size, shape and data types) of a dataset ‘iris.csv’:
17