Back to the 2021 paper

Module 3: Classification and Prediction

202110m

The results of an exam are recorded along with some data about the students. The results can be found in the table below :

ID Cell No. Language Passed all Assignments GPA Passed Exam
1 93333-11101 Java No 3.1 Yes
2 93333-11112 Java No 2.0 No
3 93333-11102 C++ Yes 3.5 Yes
4 93333-11113 Python Yes 2.5 Yes
5 93333-11103 Java Yes 3.9 No
6 93333-11114 C++ No 2.9 No
7 93333-11104 Java No 1.9 No
8 93333-11115 Python Yes 3.2 Yes

In no more than one page of text, describe the design of a K-Nearest Neighbour classifier to predict if a student will fail or pass the exam.

Worked SolutionAI Assisted

Designing a K-Nearest Neighbour (k-NN) Classifier for Exam Pass/Fail Prediction

1. Choose the attributes (features)

From the given table, use prediction-relevant attributes and drop identifiers:

Attribute Type Role
ID, Cell No. identifier ignored (no predictive value)
Language categorical (nominal): Java/C++/Python matching feature
Passed all Assignments binary (Yes/No) matching feature
GPA numeric (continuous) main numeric feature
Passed Exam binary (Yes/No) class label to predict

2. Encode attributes for distance computation

  • GPA — numeric; normalise it (e.g., min–max or z-score) so its scale does not dominate distances.
  • Passed all Assignments — encode as 1 (Yes) / 0 (No).
  • Language — a categorical matching indicator: 1 if the student's language equals the new student's language, else 0.
  • For "Cell No.", a student's phone number should NOT be used (like an ID — it would destroy the algorithm).

3. Define the distance measure

Combine the per-attribute differences, e.g. the weighted Euclidean distance:

d(q,t)=wg (gpaq−gpat)2+wa (assignq−assignt)2+wl (langq−langt)2d(q, t) = \sqrt{w_g\,(gpa_q - gpa_t)^2 + w_a\,(\text{assign}_q - \text{assign}_t)^2 + w_l\,(\text{lang}_q - \text{lang}_t)^2}

with default weights 1 for each feature (GPA already normalised). Binary/categorical features contribute 0 (match) or 1 (mismatch).

4. Choose kk and the voting rule

  • Use small odd kk (typically k=3k=3 or k=5k=5) to avoid ties.
  • Tune kk by leave-one-out cross-validation on the 8 training tuples (training set is small — each tuple is the test set once, rest train).
  • Voting: assign the new student the majority class ("Passed Exam? = Yes/No") among the kk nearest neighbours. Ties broken by nearer neighbours or by choosing the smaller distance sum.

5. Evaluation

Compute the classifier's accuracy = (correct predictions)/(total test tuples), and measure the confusion matrix showing false positives (predicted pass, actually failed) vs false negatives — important because failing a student who would pass is arguably worse.

6. Algorithm summary

1. Store all training tuples (X, y): X = (GPA, Assign, Language), y = PassedExam.
2. For a new student q:
      a. normalise GPA features consistently;
      b. compute d(q, t_i) for every stored tuple;
      c. take the k tuples with smallest distance;
      d. output = majority class among those k neighbours.
3. Tune k (and weights) by leave-one-out cross-validation.

This design uses the given table as the training set and predicts Passed Exam for any new student using their GPA, assignment performance, and programming language similarity.

Similar questions

Data MiningUsing the dataset from Q5a, use your K-NN classifier to predict whether the following student (who overslept and missed the original exam) will pass the re-exam : | ID | Cell No. | Language | Passed all Assignments | GPA | Passed Exam | | :---: | :---: | :---: | :---: | :---: | :---: | | 9 | 93333-11109 | C++ | Yes | 3.0 | ?? |20214mDatabase Management SystemConsider: * Student(SID, Name, Dept, Age) * Course(CID, CName, Faculty) * Enroll(SID, CID, Marks) 1. Write relational algebra expressions to find: * a) Students enrolled in DBMS * b) Students scoring >80 marks * c) Students not enrolled in any course 2. Write SQL queries: * a) Find highest marks * b) Find average marks department-wise * c) Display students enrolled in more than two courses 3. Translate the following query into tuple relational calculus: * "Find names of students from CSE department." 4. Convert the following relational algebra into SQL: * \pi_{Name}(\sigma_{Marks > 85}(Student \bowtie Enroll))202510mData MiningA university plans to build a data warehouse that would help them in analyzing the performance of the students in various courses in different academic sessions. They want to analyze if there is any relation between the average grade of a course and the number of students attending it. They would also like to know if there were some courses offered but did not have any students registered for them. Relative performance among boys and girls and average grades of students from various States and cities of the country for each course must be analyzed and also overall CGPA. Design a star schema for such a data warehouse clearly identifying the fact table(s) and dimension table(s), their primary key(s) and foreign key(s). Your schema should at least be able to satisfy the above-mentioned analysis requirements. You may consider other suitable attributes for the dimension table(s).202110mSoftware EngineeringDraw the first two levels of DFDs for an 'Online Examination System'. Make necessary assumptions.20217m
Official AppAndroid App

PYQDeck for Android

Solve BEU previous-year exam papers anywhere, anytime. Fast search, offline paper viewing, and step-by-step solutions designed specifically for your phone.