0
0
ML Pythonml~20 mins

UMAP for dimensionality reduction in ML Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
UMAP Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Understanding UMAP's Core Idea
What is the main goal of UMAP when reducing data dimensions?
ATo cluster data points into predefined groups
BTo maximize the variance of the data in the reduced space
CTo preserve the local structure of data points while reducing dimensions
DTo increase the number of features for better model training
Attempts:
2 left
💡 Hint
Think about what UMAP tries to keep similar between high and low dimensions.
Predict Output
intermediate
1:30remaining
UMAP Output Shape
What will be the shape of the output after applying UMAP with n_components=2 on a dataset X with shape (100, 50)?
ML Python
import numpy as np
import umap
X = np.random.rand(100, 50)
reducer = umap.UMAP(n_components=2)
X_reduced = reducer.fit_transform(X)
print(X_reduced.shape)
A(100, 50)
B(100, 2)
C(50, 2)
D(2, 50)
Attempts:
2 left
💡 Hint
The number of rows stays the same; only the number of features changes.
Hyperparameter
advanced
2:00remaining
Effect of 'n_neighbors' in UMAP
What is the effect of increasing the 'n_neighbors' parameter in UMAP?
AIt increases the focus on preserving global structure over local details
BIt speeds up the computation by reducing data points considered
CIt decreases the number of output dimensions
DIt changes the distance metric used internally
Attempts:
2 left
💡 Hint
Think about how many neighbors UMAP considers when building the graph.
Metrics
advanced
1:30remaining
Evaluating UMAP Embedding Quality
Which metric is commonly used to evaluate how well UMAP preserves local neighborhood structure?
AMean squared error
BAccuracy score
CF1 score
DTrustworthiness score
Attempts:
2 left
💡 Hint
This metric measures how well neighbors in high dimensions remain neighbors in low dimensions.
🔧 Debug
expert
2:30remaining
UMAP Runtime Error Diagnosis
Given the code below, what is the most likely cause of the error? import numpy as np import umap X = np.array([[1, 2], [3, 4], [5, 6]]) reducer = umap.UMAP(n_components=3) X_reduced = reducer.fit_transform(X)
ML Python
import numpy as np
import umap
X = np.array([[1, 2], [3, 4], [5, 6]])
reducer = umap.UMAP(n_components=3)
X_reduced = reducer.fit_transform(X)
An_components cannot be greater than the original feature dimension
BInput data X must be a pandas DataFrame
CUMAP requires at least 10 samples to run
DThe distance metric is not specified
Attempts:
2 left
💡 Hint
Check the relationship between n_components and input feature size.