0% found this document useful (0 votes)
40 views36 pages

Data Sets

Uploaded by

voicemint311
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views36 pages

Data Sets

Uploaded by

voicemint311
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 36

Machine Learning With Python

By: Ms.Sehrish Shafiq


Objective
• Setup Python environment for ML
• Tools you need to run Python Code
• Help on getting started with Python
What is Python for Machine Learning?
• Python is an open-source, general-purpose programming language first
developed in 1991. Because Python is open-source, it is free and publicly
available for anyone to use. Python can be used to build websites, develop
software, conduct data analysis, and automate tasks using artificial
intelligence (AI) and machine learning.

• Python is a general purpose programming language


• with the following nice features:
• – An object-based high-level programming language
• – A free software released under an open-source license
• – Cross-platform: Windows, Linux/Unix, MaxOS X etc
• – A very readable and concise language with clear non-verbose
• syntax
• – A large variety of high-quality packages are available for
• various applications online and free to use
Commonly-used Python editors
What Can You Do with Python for Machine Learning?

• Python has a crucial role in Machine • Python for machine learning is used to
Learning because Python provides personalize and improve user experiences.
libraries like NumPy, Pandas, Scikit-learn, Machine learning can automate customer
TensorFlow, and Keras. These libraries support, detect fraudulent transactions,
offer tools and functions essential for data recommend products, refine search
manipulation, analysis, and building engine results, automate translation,
machine learning models. It is well-known recommend music, and predict the
for its readability and offers platform effectiveness of drug treatments. There
independence. These all things make it are countless uses for machine learning
the perfect language of choice for and demand is only increasing, making
Machine Learning. now an opportune time to learn Python
for machine learning.
Python
Environment
Setup for
Machine Learning
Python Environment Setup for Machine Learning

Install Python for Windows

Anaconda distribution is a free and open-source platform for Python/R


programming languages. It can be easily installed on any OS such as
Windows, Linux, and MAC OS. It provides more than 1500 Python/R
data science packages which are suitable for developing machine
learning and deep learning models.

Anaconda distribution provides installation of Python with various


IDE's such as Jupyter Notebook, Spyder, Anaconda prompt, etc. Hence
it is a very convenient packaged solution which you can easily
download and install in your computer. It will automatically install
Python and some basic IDEs and libraries with it.
Python Environment Setup for Machine Learning

Install Python for Windows


Best Python IDEs
• PyCharm: easy to
work with when
working on a large
project containing
different Python
files
• Can see
intermediate results
in debugging mode
Google Colab
Python libraries used for Machine Learning:

Python libraries used for Machine Learning: For developing machine


learning models, following Python libraries are needed to be
installed:
✓ NumPy: It facilitates the data representation in the form of one-
dimensional NumPy arrays and also contains functionality for
multidimensional arrays, high-level mathematical functions such as
linear algebra operations, Fourier transform, pseudorandom number
generators etc

pip install numpy


Python libraries used for Machine Learning:

✓ Pandas: It represents the tabular data as DataFrame similar to R


Dataframe and Excel spreadsheet. The input data file of various
formats like SQL, CSV, Excel etc. can be loaded to the Python
programme using Pandas. It also facilitates easy data manipulation, SQL
like queries and joins of tables.
Python libraries used for Machine Learning:

✓ Scikit-Learn: Most important Python library for data science


and machine learning. It contains a wide range of machine
learning algorithms like data preprocessing, classification,
clustering, regression, dimensionality reduction, model
selection, model evaluation etc

pip install scikit-learn


Python libraries used for Machine Learning:

✓ Matplotlib: This library is useful for making publication-


quality visualizations such as line charts, histograms, scatter
plots, and so on. Installation of these Python libraries can be
done using the following code:

C:\>pip install <library_name>


Some types of Matplotlib
Data Structures in Python
Lists, Tuple, Set, Dictionary

Attention: Python index begins with 0 !!!


Use NumPy for Array/Matrix Oriented Computing
NumPy Overview
Control Structures (Selection and Loop)
The Nearest Rule (if else ambiguity)
The else/elif clause matches the nearest preceding if/elif clause in the
same
block.
Iteration/Loop Structure
Iteration/Loop Structure
Python Functions
Python Classes
Python Classes

Matlab is a function-based programming language.


• Differently, Python is a object-based language. We can define objects
under classes. Then and the properties and methods (functions) can be
easily called.
• Also, for Python, many packages online well-written by others are free
to download and be installed
Python Class Definition
Python Class Definition

• The __init__() function is called automatically every time the class is being
used to create a new object.
• The self parameter is a reference to the current instance of the class, and
is used to access variables that belongs to the class.
• It does not have to be named self , you can call it whatever you like, but it
has to be the first parameter of any function in the class.
• There are other properties of Python class such as inheritance, which will
not be covered in detail here.
RF Library in Python

• Found a library in Python called skrf, which is free to


• install and use.
(https://scikit-rf.readthedocs.io/en/latest/tutorials/Networks.html#Introduction )
• ● This library can handle S-parameters and Z-parameters.
Supervised Machine Learning using Python

K-Nearest Neighbour (KNN)


It is a non-parametric, lazy learning algorithm which doesn’t consider any
assumption about the underlying data. It uses ‘feature similarity’ to assess the
distance between a new data point and data present in the training set. Training
data points closest to the new data point are called as its “Nearest Neighbours”.
The most frequent class to which most of the top K nearest neighbours belong is
assigned to the new data as its predicted class. KNeighborsClassifier class of
sklearn library is used for developing KNN classifier in Python. Steps of
developing a KNN classifier for Iris dataset are given below:
Iris Dataset :
It is one of the sklearn datasets consisting of 4 different
measurements, viz., sepal length, sepal width, petal length and petal
width for 3 types of Iris flowers, viz., Setosa, Versicolour and Virginica
stored as a 150  4 NumPy array. Each class, i.e., flower type consists
of 50 samples. Iris dataset has been used for the demonstration of
supervised and unsupervised machine learning algorithms in the
following section

You might also like