0% found this document useful (0 votes)
2 views3 pages

NumPy Lab1 Assignment

The document explores the NumPy library, focusing on its functions for numerical computation, including array creation, mathematical operations, and statistical functions. It highlights the advantages of NumPy over Python lists, such as speed and support for vectorization, and its applications in machine learning. The document includes code examples and concludes that NumPy is essential for efficient numerical computation.

Uploaded by

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

NumPy Lab1 Assignment

The document explores the NumPy library, focusing on its functions for numerical computation, including array creation, mathematical operations, and statistical functions. It highlights the advantages of NumPy over Python lists, such as speed and support for vectorization, and its applications in machine learning. The document includes code examples and concludes that NumPy is essential for efficient numerical computation.

Uploaded by

kunalpatil29th
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Experiment No.

1: NumPy Library
PART A

A.1 Aim
To explore various functions of NumPy library and understand their logic for numerical
computation.

A.2 Prerequisite
Python basics
Arrays and matrices
Basic mathematical operations

A.3 Outcome
Students will be able to:
- Create NumPy arrays
- Use array creation functions
- Perform mathematical operations
- Apply statistical functions
- Use reshaping and indexing
- Understand vectorized computation
- Use NumPy in Machine Learning preprocessing

A.4 Theory
NumPy is a powerful Python library used for numerical computations. It provides support
for multidimensional arrays and mathematical functions.

NumPy is faster than Python lists because:


- Implemented in C
- Uses contiguous memory
- Supports vectorization
- Avoids loops

Used in ML for preprocessing, matrix operations, feature scaling, and statistical analysis.

PART B

B.1 Code
import numpy as np

a = [Link]([1,2,3,4])
b = [Link]([[1,2],[3,4]])

print("1D Array:",a)
print("2D Array:",b)

print([Link]((2,2)))
print([Link]((2,2)))

print([Link](0,10,2))
print([Link](0,1,5))

x = [Link]([10,20,30])
y = [Link]([1,2,3])

print("Addition:",x+y)
print("Multiplication:",x*y)

data = [Link]([10,20,30,40,50])

print("Mean:",[Link](data))
print("Std:",[Link](data))

r = [Link](6).reshape(2,3)
print(r)

B.2 Observations
NumPy arrays are faster.
Vectorized operations improve performance.
Statistical functions are useful in ML.

B.3 Conclusion
NumPy helps in efficient numerical computation and is widely used in ML.

B.4 Questions
1. What is NumPy?
NumPy is a Python library for numerical computing using arrays.

2. Why is NumPy faster?


Because it uses C backend and vectorized operations.

3. What is vectorization?
Performing operations without loops.
4. What is reshape?
Changing array shape without changing data.

5. Why NumPy used in ML?


For fast computation, preprocessing, and matrix operations.

You might also like