AI Experiment 2
AI Experiment 2
(UNC504P)
Experiment No. 2
Libraries in Python
1 2 3
A= 4 5 6 (1)
7 8 9
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)
10. Using the following data plot a bar plot and a horizontal bar plot.
company = [”Apple”, ”Microsoft”, ”Google”, ”AMD”]
profit = [3000, 8000, 1000, 10000]
12. You have a dataset containing sales data for a retail store. Design a program using
pandas to: