Blog
Data Mining Past Paper 2017 – BSCS 7th Term UOS (CS-471)
University of Sargodha Data Mining (CS-471) paper for BS Computer Science 7th term, 2017 exam (80 marks, 2:30 hours). The paper has been retyped, and solved answers are given below for all 16 short questions and all five long questions, including the decision-tree root node, K-means clustering and Apriori frequent itemsets with full working.
Solved answers
Q1 – Short answers (16 × 2)
A. What is a model in data mining? A model is a pattern or mathematical representation learned from data (e.g. a decision tree, regression equation or set of clusters/rules) that describes the data or predicts unknown values for new records.
B. Data mining vs data warehousing: A data warehouse is a subject-oriented, integrated, time-variant store of historical data built for querying and analysis. Data mining is the process of discovering hidden patterns and knowledge from such data using algorithms (classification, clustering, association). The warehouse stores data; mining analyses it.
C. Example of discrete data: Data that takes countable, separate values – e.g. number of items in a basket (0, 1, 2…), number of children, gender or blood group.
D. Why do we preprocess data? Real data is incomplete (missing values), noisy (errors/outliers) and inconsistent. Preprocessing (cleaning, integration, transformation, reduction) improves data quality so that mining results are accurate and efficient – “garbage in, garbage out”.
E. What is noise? Noise is random error or variance in a measured variable, e.g. wrong entries, outliers or typing mistakes. It is handled by binning, regression, clustering or outlier removal.
F. Selection in data mining: Selecting the relevant data (records and attributes) from the database for the mining task – the first step of the KDD process (selection → preprocessing → transformation → mining → evaluation).
G. Why dimensionality reduction? Many attributes increase computation time, storage and noise, and cause the “curse of dimensionality” (data becomes sparse). Reducing dimensions (PCA, attribute subset selection) gives faster, simpler and often more accurate models.
H. Predictive data mining: Mining that uses known data to predict unknown or future values, e.g. classification (will a customer leave? yes/no) and regression (next month’s sales).
I. Classification: A supervised technique that assigns records to predefined classes using a model learned from labelled training data, e.g. classifying e-mail as spam or not spam (decision tree, naïve Bayes, KNN).
J. Regression: A technique that predicts a continuous numeric value from other attributes, e.g. predicting house price from area and location (linear regression y = a + bx).
K. Significance of the Apriori property: “All non-empty subsets of a frequent itemset must also be frequent” (equivalently, any superset of an infrequent itemset is infrequent). It lets Apriori prune candidate itemsets and greatly reduces the search space.
L. Market basket analysis: Analysing customers’ transactions to find items frequently bought together, e.g. {bread, butter} → {milk}. Used for shelf layout, cross-selling and promotions.
M. Frequent pattern: An itemset, subsequence or substructure that appears in the data with support ≥ a minimum support threshold, e.g. {milk, bread} appearing in 40% of transactions.
N. Closed pattern: A frequent itemset X is closed if no proper superset of X has the same support. Closed patterns give a lossless compact representation of all frequent itemsets.
O. Maximal pattern: A frequent itemset X is maximal if none of its proper supersets is frequent. Maximal patterns are fewer than closed ones but lose the exact support of subsets.
P. An application area of data mining: Banking – fraud detection: transaction patterns are mined to flag unusual card usage. (Others: retail recommendations, medical diagnosis, customer churn prediction.)
Q2 – Root node of the decision tree (golf data)
There are 14 records: 9 yes and 5 no. Entropy of the whole set:
H(S) = −(9/14)log2(9/14) − (5/14)log2(5/14) = 0.940| Attribute | Values (yes/no) | Weighted entropy | Information gain |
|---|---|---|---|
| Outlook | overcast 4/0, rainy 3/2, sunny 2/3 | (4/14)(0) + (5/14)(0.971) + (5/14)(0.971) = 0.694 | 0.247 |
| Temperature | hot 2/2, mild 4/2, cool 3/1 | (4/14)(1) + (6/14)(0.918) + (4/14)(0.811) = 0.911 | 0.029 |
| Humidity | high 3/4, normal 6/1 | (7/14)(0.985) + (7/14)(0.592) = 0.788 | 0.152 |
| Windy | FALSE 6/2, TRUE 3/3 | (8/14)(0.811) + (6/14)(1) = 0.892 | 0.048 |
Outlook has the highest information gain (0.247), so it is the root node. The overcast branch is pure (all yes) and becomes a leaf; the rainy and sunny branches are split further (in this data, rainy splits best on Windy and sunny on Humidity). All values were checked with a short Python program.
Q3 – K-Means clustering (K = 2)
Points: A(3,4), B(4,6), C(2,5), D(5,4), E(5,6), F(7,3), G(2,8). Take the first two points as initial centroids: c1 = (3,4), c2 = (4,6). Distance = Euclidean.
| Iteration | Cluster 1 | Cluster 2 | New centroids |
|---|---|---|---|
| 1 | A(3,4), C(2,5), D(5,4), F(7,3) | B(4,6), E(5,6), G(2,8) | c1 = (4.25, 4.00), c2 = (3.67, 6.67) |
| 2 | A(3,4), D(5,4), F(7,3) | B(4,6), C(2,5), E(5,6), G(2,8) | c1 = (5.00, 3.67), c2 = (3.25, 6.25) |
| 3 | A, D, F | B, C, E, G | no change → stop |
Example of iteration 2 for C(2,5): distance to c1(4.25,4) = √(2.25² + 1²) = 2.46; to c2(3.67,6.67) = √(1.67² + 1.67²) = 2.36, so C moves to cluster 2.
Final clusters: K1 = {(3,4), (5,4), (7,3)} with centre (5, 3.67); K2 = {(4,6), (2,5), (5,6), (2,8)} with centre (3.25, 6.25). (Different initial centroids can give a different result; K-means only finds a local optimum.)
Q4 – Significance and applications of data mining
Significance: organisations collect huge amounts of data; data mining turns it into useful knowledge for decision making – finding hidden patterns, predicting trends, reducing cost and risk, and giving competitive advantage.
- Retail and marketing: market basket analysis, product recommendations (Amazon, Daraz), customer segmentation and targeted ads.
- Banking and finance: credit scoring, loan default prediction, credit-card fraud detection.
- Healthcare: disease prediction and diagnosis, finding effective treatments, hospital resource planning.
- Telecom: churn prediction and call-pattern analysis to detect fraud.
- Education: predicting student performance and drop-outs.
- Web and social media: search ranking, sentiment analysis, spam filtering.
- Security and government: intrusion detection, crime pattern analysis, tax fraud.
- Science and agriculture: weather and crop-yield prediction, bioinformatics.
Issues to consider: privacy of personal data, data quality and correct interpretation of results.
Q5 – Classification vs clustering
| Classification | Clustering |
|---|---|
| Supervised learning | Unsupervised learning |
| Classes (labels) are predefined | No predefined labels; groups are discovered |
| Needs labelled training data | Works on unlabelled data |
| Builds a model to predict the class of new records | Groups similar objects so that intra-cluster similarity is high and inter-cluster similarity is low |
| Evaluated by accuracy, precision, recall on test data | Evaluated by cohesion/separation (e.g. SSE, silhouette) |
| Algorithms: decision tree, naïve Bayes, KNN, SVM | Algorithms: K-means, K-medoids, hierarchical, DBSCAN |
| Example: spam vs non-spam e-mail | Example: grouping customers by buying behaviour |
Q6 – Frequent itemsets (min support count = 2)
C1 / L1 (1-itemsets): Bread 3, Butter 2, Diaper 2, Jam 2, Milk 2 – all are frequent.
C2 (pairs from L1) with counts: {Bread, Butter} 1, {Bread, Diaper} 0, {Bread, Jam} 1, {Bread, Milk} 2, {Butter, Diaper} 1, {Butter, Jam} 0, {Butter, Milk} 1, {Diaper, Jam} 1, {Diaper, Milk} 0, {Jam, Milk} 1.
L2 = {Bread, Milk} (support 2). No C3 can be formed (only one frequent pair), so the algorithm stops.
All frequent itemsets: {Bread}, {Butter}, {Diaper}, {Jam}, {Milk}, {Bread, Milk}. (Checked by enumerating all itemsets in Python.)
