PYTHON
Libraries
Demystifying the World of Artificial
Intelligence and Exploring Its Potential
1
Artificial Intelligence
Modules VS Packages VS Libraries
• Modules : help in organizing
related functions and classes into a Functions Functions Functions
single file, making code more
manageable and reusable.
2
Artificial Intelligence
Modules VS Packages VS Libraries
• Modules : help in organizing
related functions and classes into a
single file, making code more
manageable and reusable. Module
Functions
Functions
Functions
File.py
3
Artificial Intelligence
Modules VS Packages VS Libraries
• Modules : help in organizing related functions
and classes into a single file, making code
more manageable and reusable.
Package
• Packages : allow for a hierarchical
__init__.py
structuring of the module namespace
using dot notation, making it easier to
Module Module Module
organize and manage large codebases.
Functions Functions Functions
Functions Functions Functions
Functions Functions Functions
File.py File.py File.py
4
Artificial Intelligence
Modules VS Packages VS Libraries
• Modules : help in organizing related functions
and classes into a single file, making code
more manageable and reusable.
Library
• Packages : allow for a hierarchical structuring of Package Package
the module namespace using dot notation, __init__.py
__init__.py
making it easier to organize and manage large Module Module Module Module Module Module
codebases. Functions Functions Functions Functions Functions Functions
Functions Functions Functions Functions
Functions Functions
Functions Functions Functions
Functions Functions Functions
File.py File.py File.py File.py
File.py File.py
• Libraries: extend Python's capabilities by
providing additional tools and utilities for Package Package
various tasks, such as numerical
__init__.py __init__.py
Module Module Module Module Module Module
computations, data analysis, web Functions Functions Functions Functions Functions Functions
development, and more.
Functions Functions Functions Functions Functions Functions
Functions Functions Functions Functions Functions Functions
File.py File.py File.py File.py File.py File.py
5
Artificial Intelligence
WHAT ARE Python Libraries?
6
Artificial Intelligence
WHAT ARE Python Libraries?
• Python libraries are collections of pre-written
code and functions that extend the capabilities of
the Python programming language.
• They provide a wide range of tools and modules
for various tasks, making it easier for
developers to work on specific tasks without
reinventing the wheel.
7
Artificial Intelligence
WHAT ARE Python Libraries?
➢ Python Libraries Types:
• ex:
1. Standard libraries : Python comes with a
• OS
standard libraries that include many modules
for preforming common Tasks. • Sys
• Standard libraries : Available by default but need to be imported.
• Math
• datetime
8
Artificial Intelligence
WHAT ARE Python Libraries?
➢ Python Libraries Types:
1. Standard libraries : Python comes with a standard libraries
that include many modules for preforming common Tasks..
❑ Builtins libraries : Special subset of the
Standard libraries , that are automatically loaded
into python.
• Builtins : Always available without importing
• Standard libraries :
Available by default but
need to be imported.
9
Artificial Intelligence
WHAT ARE Python Libraries?
➢ Python Libraries Types:
• ex:
2. Third-party libraries : These are created by the
• Numpy
community and can be installed using package
manager like ‘pip’. • Pandas
• Matplotlib
• Third-party libraries : Need to be installed first, • Scikit-learn
then importing.
• Standard libraries :
Available by default but • Builtins : Always available
need to be imported. without importing
10
Artificial Intelligence
WHAT ARE Python Libraries?
➢ Python Libraries Types:
• Builtins : Always • Standard libraries : • Third-party libraries :
available without Available by default but Need to be installed
importing need to be imported. first, then importing.
11
Artificial Intelligence
A blue and black logo
Description automatically generated
12
Artificial Intelligence
What is NumPy?
NumPy: is a Python Third-Party Module To Deal With Arrays & Matrices
• Stand for Numerical Python
• Open Source
• Support dealing with Large Multidimensional Arrays.
• Has many Mathematical Functions to deal with these elements
13
Artificial Intelligence
What is NumPy? NumPy: is a Python Third-Party Module To Deal With Arrays & Matrices
Why we use NumPy Arrays?
• Consume Less Memory
• Very Fast Compared To Python List
• Easy To Use
• Support Element Wise Operation
• Elements are stored Contiguous
14
Artificial Intelligence
Python List VS Numpy Array
15
Artificial Intelligence
Python List VS Numpy Array
Python Lists
• Homogeneous => Can Contains The Same Type of Objects
• Heterogeneous => Can Contains Different Types of Objects.
Numpy Array
• The Items in the Array have to be of the Same Type.
• You can be sure what is the Storage Size needed for the array.
• NumPy Arrays are indexed From 0
16
Artificial Intelligence
17
Artificial Intelligence
Square Matrix
3 columns
• A square matrix is a matrix that has an
equal number of rows and columns. 3 rows
18
Artificial Intelligence
Identity Matrix
19
Artificial Intelligence
Identity Matrix
• An identity matrix is a special kind of square matrix in which all the elements of the
principal diagonal are ones, and all other elements are zeros.
• The identity matrix plays a crucial role in linear algebra, especially in matrix multiplication,
where it acts as the multiplicative identity element.
• This means that multiplying any matrix by an identity matrix of compatible dimensions
leaves the original matrix unchanged.
20
Artificial Intelligence
Mean – Mode – Median
21
Artificial Intelligence
Mean – Mode – Median
Mon Tue Wed Thu Fri Sat Sun
5 3 8 3 15 45 9
22
Artificial Intelligence
Mode – Median
Mon Tue Wed Thu Fri Sat Sun
5 3 8 3 15 45 9
Mean – The mean (or average) is the sum of all the values in a data set
divided by the number of values.
5 + 3 + 8 + 3 + 15 + 45 + 9
𝑀𝑒𝑎𝑛 = = 12.5
7
23
Artificial Intelligence
Mean – Median
Mon Tue Wed Thu Fri Sat Sun
5 3 8 3 15 45 9
5 + 3 + 8 + 3 + 15 + 45 + 9
𝑀𝑒𝑎𝑛 = = 𝟏𝟐. 𝟓
7
Mode –
The mode is the value that appears most frequently in a data set.
A data set may have one mode, more than one mode, or no mode
at all.
Mode = 3
5 3 8 3 15 45 9
24
Artificial Intelligence
Mean – Mode –
Mon Tue Wed Thu Fri Sat Sun
5 3 8 3 15 45 9
Median 𝑀𝑒𝑎𝑛 =
5 + 3 + 8 + 3 + 15 + 45 + 9
7
= 𝟏𝟐. 𝟓
Mode =3
The median is the middle value in a data set when the values are
arranged in ascending order.
If the number of values is even, the median is the average of the
two middle values.
3 3 5 8 9 15 45
Median = 8
25
Artificial Intelligence
26
Artificial Intelligence
27
Artificial Intelligence
THANK
YOU!
Any Question!
28