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

Artificial Intelligence (AI) Final Term Spring 2023

Uploaded by

Ahmad Raza
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 views2 pages

Artificial Intelligence (AI) Final Term Spring 2023

Uploaded by

Ahmad Raza
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/ 2

University of Central Punjab, Faculty of IT

Final Term Examination- Spring 23


Artificial Intelligence-Lab

Program: BSCS Course Code: CSAL3241 Time Allowed: 90minutes


Total Marks: 80
Instructors: Hafiz Usama, Ms. Sadia

Instructions:

• Time to attempt the exam is 80 minutes. Last 10 minutes are for submission.
• Understanding of a question is part of exam. Don’t ask invigilator for any explanation.
• Plagiarism will be penalized.
• Name your solution as “<your roll number>_mid_<section>”, zip and submit.

Task 01: (Genetic Algorithm) (40)


Determine the minimum value of the function
f(x) = –x^2 + 200x [5]
1) Generate an initial population randomly. [5]

a. Encode the problem using chromosomes composed of 8 genes (8


bits)
b. Create an initial random population with a size of N = 8

2) 2- Develop a Roulette Wheel selection method. [5]

3) 3- Choose pairs of chromosomes for mating: pair the 1st chromosome with
the 3rd chromosome and the 2nd chromosome with the 4th chromosome,
based on specified criteria. [5]

4) 4- Apply 1-point crossover using a random value as a crossover point. [5]

5) 5- Introduce mutation by altering the middle 2 bits in a chromosome. [5]

The fitness criterion is to achieve a fitness score of at least 90% of -13999. If this
criterion is not met after a maximum of three iterations, display the
chromosome with the minimum value. [10]
University of Central Punjab, Faculty of IT
Final Term Examination- Spring 23
Artificial Intelligence-Lab

Task 02: (KNN) (40)


About Dataset: This is a set of data created from imaginary data of water quality.
What's inside is more than just rows and columns. Each column represents an
ingredient amount in water.
Class attribute (Y) = {1 – Drinkable, 0 – Not Drinkable}

You are provided with a code to read and basic preprocessing of data.
You must implement the following:
1- You must remove the mentioned columns/features: X1, X11, X12, X20 [5]
2- Perform Train Test Split considering the classes must be equal [5]
3- Implement Distance i.e. Train implemented or built-in KNN model using
training data. [5]
4- Perform Prediction using testing data at k =5 and k = 21. [10]
5- Calculate Accuracy. [5]
6- Now predict the following point with the model with better accuracy (k=5 OR k
= 21) that is stored in a separate list named as p: [10]
p= [0.1, 2.2, 0.03, 1.4, 0.05, 0.6, 0.07, 1.08, 1.9, 0.11, 8.012, 0.13, 0.014,
6.15, 0.016, 4.17, 0.018, 0.019]

You might also like