Free MS-DS Master of Data science Unsupervised Machine Learning Models Questions and Answers — Questions and Answers
Question 1: A data scientist is working with a large dataset containing customer transaction histories. The goal is to identify groups of customers with similar purchasing behaviors without any predefined labels for customer types. The dataset is known to contain outliers and the resulting clusters are expected to be of arbitrary shapes and varying sizes. Which of the following unsupervised learning algorithms is most suitable for this task?
- K-Means Clustering
- DBSCAN (Density-Based Spatial Clustering of Applications with Noise) (Correct answer)
- Principal Component Analysis (PCA)
- Agglomerative Hierarchical Clustering
Correct answer: DBSCAN (Density-Based Spatial Clustering of Applications with Noise)
DBSCAN is ideal for this scenario because it is a density-based clustering algorithm that can identify clusters of arbitrary shapes and is robust to outliers (noise). K-Means assumes clusters are spherical and is sensitive to outliers. Agglomerative Hierarchical Clustering can struggle with large datasets and the interpretation of the resulting dendrogram can be subjective. Principal Component Analysis (PCA) is a dimensionality reduction technique, not a clustering algorithm.
Question 2: A financial services company wants to build a system to detect fraudulent credit card transactions. They have a very large dataset of transactions, but only a tiny fraction are labeled as fraudulent. They decide to use an unsupervised approach by training a model on non-fraudulent transactions. The model should learn the underlying patterns of normal transactions and flag any deviations as potential fraud. Which model is best suited for this anomaly detection task?
- Apriori Algorithm
- K-Means Clustering
- Autoencoder (Correct answer)
- Hierarchical Clustering
Correct answer: Autoencoder
An autoencoder is a type of neural network well-suited for anomaly detection. It is trained to reconstruct its input data. By training it on normal (non-fraudulent) transactions, it learns to reconstruct them with low error. When a fraudulent transaction, which deviates from the learned patterns, is passed through, the reconstruction error will be high, flagging it as an anomaly. The Apriori algorithm is for association rule mining. K-Means and Hierarchical Clustering are for grouping data, not specifically for identifying rare, anomalous data points based on reconstruction error.
Question 3: Which of the following is a primary advantage of Hierarchical Clustering over K-Means Clustering?
- It is more computationally efficient for large datasets.
- It can handle categorical features without any transformation.
- It does not require the number of clusters to be specified beforehand. (Correct answer)
- It always converges to the same solution regardless of initialization.
Correct answer: It does not require the number of clusters to be specified beforehand.
A key advantage of Hierarchical Clustering is that it does not require the user to pre-specify the number of clusters. It produces a dendrogram, a tree-like diagram that visualizes the cluster hierarchy, allowing the user to choose the number of clusters after the model is built. K-Means, in contrast, requires the number of clusters (K) as an input parameter. Hierarchical clustering is generally more computationally expensive than K-Means for large datasets, and K-Means is sensitive to initial centroid placement.
Question 4: A data science team is analyzing a high-dimensional dataset with hundreds of correlated features. Their goal is to reduce the number of features to a smaller set of new, uncorrelated variables that capture the maximum possible variance from the original data. This is often done as a preprocessing step before applying a supervised learning model. Which unsupervised technique is most appropriate for this task?
- Gaussian Mixture Model (GMM)
- t-Distributed Stochastic Neighbor Embedding (t-SNE)
- Principal Component Analysis (PCA) (Correct answer)
- DBSCAN
Correct answer: Principal Component Analysis (PCA)
Principal Component Analysis (PCA) is an unsupervised linear transformation technique used for dimensionality reduction. Its primary goal is to transform the data into a new coordinate system of principal components, which are orthogonal (uncorrelated) and ordered by the amount of variance they explain from the original data. This makes it perfect for reducing correlated features while retaining most of the information. t-SNE is primarily for visualization, not feature extraction for modeling. GMM and DBSCAN are clustering algorithms.
Question 5: An e-commerce company is performing a market basket analysis to discover which products are frequently purchased together. They are analyzing a large transaction database to generate association rules like '{Diapers} -> {Beer}'. Which algorithm is fundamentally designed for this type of association rule mining?
- K-Means Clustering
- Apriori Algorithm (Correct answer)
- Singular Value Decomposition (SVD)
- Isolation Forest
Correct answer: Apriori Algorithm
The Apriori algorithm is a classic algorithm used for association rule learning and market basket analysis. It identifies frequent individual items in a database and extends them to larger and larger item sets as long as those item sets appear sufficiently often in the database. These frequent itemsets are then used to generate association rules. The other options are used for different purposes: K-Means for clustering, SVD for dimensionality reduction, and Isolation Forest for anomaly detection.
Question 6: A significant drawback of the K-Means clustering algorithm is its sensitivity to the initial placement of cluster centroids. A poor initialization can lead to a suboptimal clustering solution. Which of the following is a common method used to mitigate this issue?
- Using a dendrogram to visualize the clusters.
- Applying the elbow method to determine the optimal K.
- Running the algorithm multiple times with different random initializations and choosing the best result. (Correct answer)
- Scaling the data using Min-Max normalization before clustering.
Correct answer: Running the algorithm multiple times with different random initializations and choosing the best result.
Because K-Means can converge to a local optimum depending on the random starting positions of its centroids, a common and effective strategy is to run the algorithm multiple times (n_init) with different random initializations. The final result is then chosen from the run that yields the best performance, typically measured by the lowest within-cluster sum of squares (inertia). The elbow method helps find K but doesn't solve the initialization problem. Scaling is good practice but doesn't directly address initialization sensitivity. Dendrograms are associated with hierarchical clustering.
A data scientist is working with a large dataset containing customer transaction histories.
The goal is to identify groups of customers with similar purchasing behaviors without any predefined labels for customer types.
The dataset is known to contain outliers and the resulting clusters are expected to be of arbitrary shapes and varying sizes.
Which of the following unsupervised learning algorithms is most suitable for this task?