0% found this document useful (0 votes)
11 views5 pages

AI Experiment 2

Uploaded by

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

AI Experiment 2

Uploaded by

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

Artificial Intelligence Lab

(UNC504P)
Experiment No. 2
Libraries in Python

1. Generate the following matrix in numpy

1 2 3
A= 4 5 6 (1)
7 8 9

and modify the entries to


1 999 999
B= 4 999 999 (2)
7 8 9
Ans.

2. Consider the system of equations

3x + 2y = 5
(3)
10x − y = 3

Find the unique solution to these equations using matrix calculus in Numpy array.
Ans.
3. Generate a 5 by 5 random matrix and find the maximum, minimum, average (mean)
& variance values along all axes.

Ans.

4. Generate a 5 by 5 random integer matrix whose values are between 2 & 100. Find
the another matrix which produces boolean output as true where Values of random
matrix are between 20 & 70.

Ans.

5. Find the mean square error between two array A = [1,2,3,4,5,6] & B = [7,8,9,10,12,17]
using function in Numpy module.

Ans.

6. Create a Normalized random variable of size 20 using Numpy and find out each
quartile & their corresponding counts.

Ans.
7. Find out the eigen value and eigen vectors of covariance of the data matrix,
X=[[4,11],[8,4],[13,5],[7,14]] where each row is one observation while colums are
attribures of that observation. (Hint: Question is related to PCA & use np.cov
and np.linalg.eig functions of numpy package)

Ans.
8. Create a pandas data structure (series) X using a dictionary D = ”Rohan”: 176,”John”:
175,”Harvinder”: 180,”Hasan”: 174 . Then pass other list [”Tinku”,”John”,”Ramesh”,”Hasan”]
as index into series X . Comment on the resultant output & locate the index of
NAN values.
Ans.
print("Indices with NaN:", nan_indices)

9. Draw four line plots using the subplot() function.


Use the following data:
For line 1: x = [0, 1, 2, 3, 4, 5] and y = [0, 100, 200, 300, 400, 500]
For line 2: x = [0, 1, 2, 3, 4, 5] and y = [50, 20, 40, 20, 60, 70]
For line 3: x = [0, 1, 2, 3, 4, 5] and y = [10, 20, 30, 40, 50, 60]
For line 4: x = [0, 1, 2, 3, 4, 5] and y = [200, 350, 250, 550, 450, 150]
Ans.

10. Using the following data plot a bar plot and a horizontal bar plot.
company = [”Apple”, ”Microsoft”, ”Google”, ”AMD”]
profit = [3000, 8000, 1000, 10000]

11. Using the following data to plot a box plot.


import numpy as np
box1 = np.random.normal(100, 10, 200)
box2 = np.random.normal(90, 20, 200)

12. You have a dataset containing sales data for a retail store. Design a program using
pandas to:

(a) Load the dataset into a pandas DataFrame.


(b) Calculate the total sales revenue for each month.
(c) Identify the top-selling product for each month.
(d) Visualize the monthly sales trend using a line plot.
Ans.

You might also like