ML Lab Manual VI Sem
ML Lab Manual VI Sem
Lab Program 1: Install and set up Python and essential libraries like
Installation of Python
Type “Python download” in the Google search bar and press Enter key. In
the list of links shown, select the very link or click on the official website
link: https://www.python.org/downloads/
Choose the correct link for your device from the options provided: either
Windows installer (64-bit) or Windows installer (32-bit) and proceed to
download the executable file.
Once you have downloaded the installer, open the .exe file, such as
python-3.11.5- amd64.exe, by double-clicking it to launch the Python installer.
Choose the option to install the launcher for all users by checking the
corresponding checkbox, so that all users of the computer can access the Python
|1
CA-C29L: Machine Learning BCA VI
Lab Sem
launcher application. Enable users to run Python from the
|2
CA-C29L: Machine Learning BCA VI
Lab Sem
command line by checking the Add python.exe to PATH checkbox. After Clicking the
Install Now Button the setup will start installing Python on your Windows
system.
After successful installation of Python, close the installation window. You can check
if the installation of Python was successful by using either the command line
or the Integrated Development Environment (IDLE), which you may have
installed. To access the command line, click on the Start menu and type “cmd” in
the search bar.
Then click on Command Prompt, type the command “python –V” or “python –
version”.
You can see installed version of Python on your system.
|3
CA-C29L: Machine Learning BCA VI
Lab Sem
install numpy
|4
CA-C29L: Machine Learning BCA VI
Lab Sem
Step 4: On the successful installation, you can type following two commands at
command
prompt. If python prompt “>>>” appears then package is successfully installed.
1. C:\Users\DELL>python
2. >>>import numpy
Pandas is a very popular library for working with data (its goal is to be the most
powerful and flexible open-source tool, and in our opinion, it has reached that
goal). Data Frames are at the center of pandas. A DataFrame is structured like a
table or spreadsheet. The rows and the columns both have indexes, and you can
perform operations on rows or columns separately. It can perform five significant
steps required for processing and analysis of data irrespective of the origin of the
data, i.e., load, manipulate, prepare, model, and analyze. Steps to install pandas
is,
install pandas
|5
CA-C29L: Machine Learning BCA VI
Lab Sem
1. C:\Users\DELL>python
2. >>>import pandas
import numpy
import pandas
print("numpy library version is: ")
print(numpy. version ) #please type two underscore symbols.
print("numpy library is successfully installed")
print(" ")
Program Output:
|6
NEP- BCA Sixth Semester LAB- (CA-C29L)
(NEP Scheme) 2023-2024
Scikit-learn (Sklearn) is the most useful and robust library or tool for data
analysis and statistical modeling in Python. It provides a wide range of
efficient tools such as classification, regression, and clustering and
dimensionality reduction via a consistence interface in Python. This library,
which is largely written in Python, is built upon means requires, NumPy,
Pandas, SciPy and Matplotlib libraries. Before installing scikit-learn, ensure
that you have NumPy and SciPy installed. The latest version of Scikit-learn
is 1.1 and it requires Python 3.8 or newer version of pythonX. Features of
Scikit-learn
• Simple and efficient tools for data mining and data analysis. It
features various classification, regression, and clustering algorithms
including support vector machines, random forests, gradient boosting, k-
means, etc.
• Accessible to everybody and reusable in various contexts.
• Built on the top of NumPy, Pandas, SciPy, and matplotlib (or seaborn).
Hence they are the essential libraries and tools required for Scikit-learn
Library.
NumPy Library:
|2
CA-C29L: Machine Learning BCA VI
Lab Sem
Pandas Library:
Pandas is a very popular library for working with data for data manipulation
and analysis. DataFrames and Series are at the center of pandas. A Series
is a 1D labelled array data structure and a DataFrame is a 2D labelled
structured like a table or spreadsheet. The rows and the columns both have
indexes, and you can perform operations on rows or columns separately. It can
perform five significant steps required for processing and analysis of data
irrespective of the origin (CSV, Excel, etc.,) of the data, i.e., loading,
manipulate, prepare, model and analyze.
Pandas integrates well with data visualization libraries like Matplotlib and
Seaborn, allowing you to create informative visualizations of your data.
These visualizations can be instrumental in understanding data patterns,
identifying trends, and uncovering potential issues.
Mathplotlib Library:
Matplotlib is a very popular Python library for data visualization and Plots.
Like Pandas, it is not directly related to Machine Learning. It particularly
comes in handy when a programmer wants to visualize the patterns in the
data. It is a 2D plotting library used for creating 2D graphs and plots. A
module named pyplot makes it easy for programmers for plotting as it
provides features to control line styles, font properties, formatting axes,
etc. It provides various kinds of graphs and plots for data visualization, viz.,
histogram, error charts, bar chats, etc.,
Scipy Library:
|3
CA-C29L: Machine Learning BCA VI
Lab Sem
SciPy is also very useful for image manipulation. Remember, we also come
across Scipy stack which is different from the SciPy library (used to extend the
capabilities of Scipy). The SciPy is one of the core packages that make up the
SciPy stack.
|4
NEP- BCA Sixth Semester LAB- (CA-C29L)
(NEP Scheme) 2023-2024
Lab Program 3: Install and set up scikit-learn and other necessary tools.
PIP is a package manager for Python, which means it allows you to install
and manage libraries and dependencies that are supplemental to the
standard library. (A package contains all the files you need for a module, and
modules are Python code libraries that you can include in your projects.)
Scikit-learn is the most useful machine learning library. It provides modules for
data analysis and statistical modelling. It provides a wide range of efficient
tools such as classification, regression, and clustering and dimensionality
reduction via a consistence interface in Python. This library, which is
largely written in Python, is built upon following essential libraries: NumPy,
Pandas, SciPy and Matplotlib libraries.
command, C:\Users\DELL> py –m
Step 4: On the successful installation, you can type following two commands at
command
prompt. If python prompt “>>>” appears then package is successfully installed.
1. C:\Users\DELL>python
|1
CA-C29L: Machine Learning BCA VI
Lab Sem
2. >>>import numpy
command, C:\Users\DELL> py –m
Step 4: On the successful installation, you can type following two commands at
command
prompt. If python prompt “>>>” appears then package is successfully installed.
1. C:\Users\DELL>python
2. >>>import pandas
|2
CA-C29L: Machine Learning BCA VI
Lab Sem
command, C:\Users\DELL> py –m
Step 4: On the successful installation, you can type following two commands at
command
prompt. If python prompt “>>>” appears then package is successfully installed.
1. C:\Users\DELL>python
2. >>>import scipy
Or
|3
CA-C29L: Machine Learning BCA VI
Lab Sem
Step 4: On the successful installation, you can type following two commands at
command
prompt. If python prompt “>>>” appears then package is successfully installed.
1. C:\Users\DELL>python
2. >>>import matplotlib
Or
Step 4: On the successful installation, you can type following two commands at
command
prompt. If python prompt “>>>” appears then package is successfully installed.
|4
CA-C29L: Machine Learning BCA VI
Lab Sem
1. C:\Users\DELL>python
2. >>>import sklearn
|5
CA-C29L: Machine Learning BCA VI
Lab Sem
import numpy
import pandas
import scipy
import matplotlib
import sklearn
|6
CA-C29L: Machine Learning BCA VI
Lab Sem
Program Output:
|7
CA-C29L: Machine Learning BCA VI
Lab Sem
Lab Program 4: Write a program to Load and explore the dataset of .CVS
and excel files using pandas.
Note: Before execution of this program, please check pandas and openpyxl
libraries are installed. The “openpyxl” library is used to load the excel files.
|8
CA-C29L: Machine Learning BCA VI
Lab Sem
|9
CA-C29L: Machine Learning BCA VI
Lab Sem
Note: Before execution of this program, please check pandas, mathplotlib and
seaborn libraries are installed. The “seaborn” library is used for barchart, a
data visualization. And “mathplotlib” library is used for scattered plot, a data
visualization. The “pandas” library is essential for data visualization libraries for
its successful implementation.
|
10
CA-C29L: Machine Learning BCA VI
Lab Sem
Output:
|
11
CA-C29L: Machine Learning BCA VI
Lab Sem
|
12
CA-C29L: Machine Learning BCA VI
Lab Sem
|
13
CA-C29L: Machine Learning BCA VI
Lab Sem
Output
|
14
CA-C29L: Machine Learning BCA VI
Lab Sem
|
15
CA-C29L: Machine Learning BCA VI
Lab Sem
|
16
CA-C29L: Machine Learning BCA VI
Lab Sem
|
17
CA-C29L: Machine Learning BCA VI
Lab Sem
|
18
CA-C29L: Machine Learning BCA VI
Lab Sem
|
19
CA-C29L: Machine Learning BCA VI
Lab Sem
|
20
CA-C29L: Machine Learning BCA VI
Lab Sem
|
21