Shaheed Zulfikar Ali Bhutto Institute of Science & Technology University
DEPARTMENT OF ROBOTICS & ARTIFICIAL INTELLIGENCE
Total Marks: 04
Obtained Marks:
Data Mining
Assignment # 03
Last Date of Submission: 29th April 2025
Submitted To: Mr. Syed M. Muslim Rizvi
Mohib
Student Name: Wajih Ur Ahmed
Rehman
23108213
Registration Number: 23108240
Data Mining BS(AI)-4C SZABIST-ISB
Shaheed Zulfikar Ali Bhutto Institute of Science & Technology University
DEPARTMENT OF ROBOTICS & ARTIFICIAL INTELLIGENCE
Instructions: Copied or shown assignments will be marked zero. Late submissions are not
entertained in any case.
CLO 3 – C5 – PLO A, B, D
Q1: (4 Marks)
Consider the following publicly available datasets.
1. Water Quality Dataset
o Source: UCI Machine Learning Repository – Water Quality
o ~400 rows, several missing values, about 15+ attributes related to water pollution
levels.
o No strong labels — perfect for clustering and semi-supervised methods.
2. Steel Plates Faults Dataset
o Source: UCI Machine Learning Repository – Steel Plates Faults Data Set
o ~2000 rows, labeled data on different types of faults in steel plates (good for
supervised learning).
o Minor class imbalance.
Tasks (Do All 4):
1. Supervised Learning:
Train a supervised classification model on the Steel Plates Faults dataset.
Report at least two evaluation metrics (such as F1-score, Precision, Recall) and comment on
model performance.
2. Semi-Supervised Learning:
Assume that only 10% of the Steel Plates Faults dataset labels are known.
Develop a semi-supervised learning approach to predict the rest of the labels and justify your
method.
3. Unsupervised Learning:
Apply a clustering technique (e.g., K-Means, DBSCAN) to the Water Quality dataset.
Interpret clusters and suggest how they could help authorities monitor and improve water
quality.
4. Systematic Evaluation and Recommendation:
Compare your supervised, semi-supervised, and unsupervised models systematically.
Recommend which approach is most suitable for each domain (fault detection or water
monitoring) with logical reasoning.
Data Mining BS(AI)-4C SZABIST-ISB
Shaheed Zulfikar Ali Bhutto Institute of Science & Technology University
DEPARTMENT OF ROBOTICS & ARTIFICIAL INTELLIGENCE
1. Supervised Learning (Steel Plates Faults Dataset)
import pandas as pd
from sklearn.model_selection import train_test_split
from [Link] import RandomForestClassifier
from [Link] import classification_report
data = pd.read_csv('[Link]')
X = [Link]('Class', axis=1)
y = data['Class']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
model = RandomForestClassifier()
[Link](X_train, y_train)
y_pred = [Link](X_test)
print(classification_report(y_test, y_pred))
2. Semi-Supervised Learning (Using 10% labeled data)
import numpy as np
from sklearn.semi_supervised import LabelPropagation
from [Link] import classification_report
y_array = y.to_numpy()
labels = -np.ones_like(y_array)
[Link](0)
labeled_idx = [Link](len(y_array), size=int(0.1 * len(y_array)), replace=False)
labels[labeled_idx] = y_array[labeled_idx]
semi_model = LabelPropagation()
semi_model.fit(X, labels)
predicted = semi_model.transduction_
print(classification_report(y_array[labeled_idx], predicted[labeled_idx]))
3. Unsupervised Learning (Water Quality Dataset using K-Means)
import pandas as pd
from [Link] import KMeans
from [Link] import StandardScaler
from [Link] import SimpleImputer
water_data = pd.read_csv('[Link]')
data = water_data.select_dtypes(include='number')
data = SimpleImputer(strategy='mean').fit_transform(data)
data = StandardScaler().fit_transform(data)
Data Mining BS(AI)-4C SZABIST-ISB
Shaheed Zulfikar Ali Bhutto Institute of Science & Technology University
DEPARTMENT OF ROBOTICS & ARTIFICIAL INTELLIGENCE
kmeans = KMeans(n_clusters=3)
clusters = kmeans.fit_predict(data)
water_data['Cluster'] = clusters
print(water_data[['Cluster']].value_counts())
[Link] Evaluation
Semi-Supervised
Aspect Supervised Learning Unsupervised Learning
Learning
Steel Plates Faults (10%
Dataset Used Steel Plates Faults Water Quality
labels only)
Data Few labels, most data
Fully labeled data No labels needed
Requirements unlabeled
Random Forest
Model Used Label Propagation K-Means Clustering
Classifier
Moderate accuracy
High accuracy, precise No labels → interpret
Performance (depends on data
class predictions clusters manually
structure)
Clear class definitions Labels are expensive or Explore hidden patterns or
Best Use Case
exist partially available group similar samples
Evaluation F1-Score, Precision, Cluster statistics, domain
Same (on known labels)
Metric Recall interpretation
------------------------------------------------------------------------------------------
Data Mining BS(AI)-4C SZABIST-ISB