UNIVERSITY EXAMINATIONS: 2019/2020
EXAMINATION FOR THE BACHELOR OF SCIENCE IN APPLIED
COMPUTING
BAC 3102: ARTIFICIAL INTELLIGENCE PROGRAMMING
FULL TIME/PART TIME
ORDINARY EXAMINATIONS
DATE: MAY, 2020 TIME: 6 HOURS
INSTRUCTIONS: Answer ALL Questions
SECTION B [20 MARKS]
1.You ran a search test for the word “cat”. After the test ran, the search engine retrieved the
documents that are shown here. 10 MARKS
You test your solution by searching for the word “cat”. Your algorithm returns 250 documents,
where 150 documents are relevant (which means your algorithm missed 50 relevant documents)
and 100 documents are irrelevant (which means your algorithm correctly eliminated 700 of the
irrelevant documents).Represent the above information using a confusion matrix
How many relevantdocuments were retrievedby the algorithm? 150 documents
True positive (Tp).
•How many irrelevantdocuments were retrievedby the algorithm? 100 documents
False positive (Fp)(total 250 documents retrieved –150 relevant documents).
•How many relevant documents did the algorithm does not retrieve?50 documents
False negative (Fn).
•How many irrelevant documents did the algorithm does not retrieve?700 documents
True negative (Tn).
2. We would like to predict the sex of a person based on two binary at-tributes: leg-cover (pants
or skirts) and facial-hair (some or none). We have a data set of 2,000 individuals, half male and
half female. 75% of the males have no facial hair. Skirts are worn by 50% of the females. All
females are bare faced, and no male wears a skirt.
(i)What is the initial entropy in the system? [4 Marks]
initial entropy = I(1/2,1/2) = -(1/2*log(1/2) + 1/2*log(1/2)) = 1
(ii)Compute the information gain of initially choosing the attribute leg-cover and for initially
choosing facial-hair. [6 Marks]
Entropy after leg-cover = ¼*I(0,1) + ¾*I(1/3,2/3) ≈ 0 + 0.69 = 0.69
Information gain for leg cover = 0.31
Entropy after facial-hair = 1/8*I(0,1) + 7/8*I(3/7,4/7) ≈ 0 + 0.86
Information gain for facial hair = 0.14
SECTION C: [20 MARKS]
import cv2
import numpy as np
1.Now, for reading an image, use the imread () function.
image = cv2.imread(‘Penguins.jpg’)
2.Now, use the Canny () function for detecting the edges of the already read image.
cv2.imwrite(‘edges_Penguins.jpg’, cv2.Canny(image,200,300))
3.Now, for showing the image with edges, use the imshow() function.
cv2.imshow(‘edges’, cv2.imread(‘‘edges_Penguins.jpg’))
Required
a. Screenshot the image you get
b. Use your favorite image and repeat the process above
c. Convert the image you used above from RGB to grayscale and show your code
[20 Marks]