Artificial intelligence • Original RRTutors lesson
Clustering and Dimensionality Reduction
Explore unlabeled data with clustering and lower-dimensional representations.
Concept and explanation
Clustering groups examples according to a chosen distance or density notion. K-means favors compact clusters and requires a chosen k; density-based methods can discover irregular groups and mark noise. Dimensionality reduction can compress features or support visualization, but visual separation in two dimensions is not proof of meaningful categories.
How to apply it
Scale features where distances require it, test sensitivity to parameters and initialization, and validate clusters with domain knowledge.
Worked example
Customer behavior vectors can be grouped for exploratory analysis, but clusters should not be treated as objective customer types without validation.
Illustrative Python example
from sklearn.cluster import KMeans
groups = KMeans(n_clusters=3, n_init="auto", random_state=7).fit_predict(X_scaled)
print(groups[:5])
Expected result
Each sample is assigned a cluster index under the selected distance and k.
Limitations and cautions
Clusters may be unstable, sensitive to feature scaling, or have no actionable interpretation.
Practice exercise
Compare cluster assignments after removing a feature and describe what changes.
Key takeaway: Unsupervised patterns are hypotheses to investigate, not ground truth.