2. CONTENTS TO BE STUDIED
• Introduction to Python Programming
• Python for Machine Learning
• Python Libraries used in Machine Learning
• NumPy
• NumPy Questions
• References
3. PYTHON FOR MACHINE
LEARNING (ML)
• A Python framework is an interface or tool that allows developers to
build ML models easily.
• without getting into the depth of the underlying algorithms.
• Python libraries are specific files containing pre-written code that can be
imported into your code base by using Python’s import feature.
• This increases your code reusability.
3
4. PYTHON FOR MACHINE
LEARNING (ML)
• A Python framework can be a collection of libraries intended to build a
model (e.g., machine learning) easily,
• without having to know the details of the underlying algorithms.
• An ML developer, however, must at least know how the algorithms work in
order to know what results to expect, as well as how to validate them.
4
5. FEATURES OF PYTHON
PROGRAMMING
• Used in Various Domains ( Artificial Intelligence, Machine Learning, Deep
Learning )
• Python is Object Oriented
• Python is Open source
• Shift from one system to another
5
6. INSTALLATION OF ANACONDA
• Visit Anaconda.com/downloads
• Select Windows
• Download the .exe installer
• Open and run the .exe installer
• Open the Anaconda Prompt and run some Python code
6
Figure- 1 Anaconda Distribution [1]
8. NUMPY
• NumPy is a well known general-purpose array-processing package.
• An extensive collection of high complexity mathematical functions make
NumPy powerful to process large multi-dimensional arrays and matrices.
• NumPy is very useful for handling linear algebra, Fourier transforms, and
random numbers.
• Define arbitrary data types and easily integrate with most databases.
• NumPy can also serve as an efficient multi-dimensional container for any
generic data that is in any datatype.
8
9. OPERATIONS USING NUMPY
9
Using NumPy, a developer can perform the following operations −
Mathematical and logical operations on arrays.
Fourier transforms and routines for shape manipulation.
Developer can perform Operations related to linear algebra.
NumPy has in-built functions for linear algebra and random number generation.
Installation of NumPy
pip install numpy
10. 10
• Object defined in NumPy is an N-dimensional array type called ndarray.
• It describes the collection of items of the same type.
• Items in the collection can be accessed using a zero-based index.
• Every item in an ndarray takes the same size of block in the memory.
• Each element in ndarray is an object of data-type object (called dtype).
• Any item extracted from ndarray object (by slicing) is represented by a Python object of one of
array scalar types.
Figure-1.2 Relationship between ndarray, data type object (dtype) and array scalar type [6]
11. PROGRAM TO PRINT FIRST 25
PRIME NUMBER
11
• def isPrime(num):
for i in range(2,num):
if (num % i) == 0:
return False
else:
return True
print("prime numbers")
count, num=0, 2
while count<25:
if isPrime(num):
print(num)
count+=1
num+=1
• Output-Prime Numbers
• 2
• 3
• 5
• 7
• 11
• 13
• 17
• 19
• 23
• 29
• 31
• 37
• 41
• 47
• 53
• 59
12. NUMPY(ONE DIMENSIONAL) 12
# this is one dimensional array
import numpy as np
a = np.arange(24)
#Function return the number of
dimensions of an array.
a.ndim
# now reshape it
b = a.reshape(2,4,3)
b #print b
# b is having three dimensions
Result-
$python main.py
[[[ 0 1 2]
[ 3 4 5]
[ 6 7 8]
[ 9 10 11]]
[[12 13 14]
[15 16 17]
[18 19 20]
[21 22 23]]]
13. NUMPY-QUESTIONS
13
• Write a Python program to print Factorial of given numbers.
• Write a Python program to print all Prime numbers in an Interval.
• Write a python program to sort the elements of an Array in Ascending order.
• Write a python program to print the Fibonacci series.
• Write a Python program to copy all elements of one array into another array.
• Write a Python program to print the elements of an array present on even position
14. PYTHON PROGRAMMING-
ANACONDA
14
• Anaconda is a free and open source distribution of the Python and R programming
languages for large-scale data processing, predictive analytics, and scientific
computing.
• The advantage of Anaconda is that you have access to over 720 packages that can
easily be installed with Anaconda's Conda, a package, dependency, and
environment manager.
• Anaconda distribution is available for installation
at https://www.anaconda.com/download/. For installation on Windows, 32 and 64
bit binaries are available −