0
0
ML Pythonml~20 mins

t-SNE for visualization in ML Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
t-SNE Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding t-SNE's Purpose

What is the main goal of using t-SNE in data analysis?

ATo perform linear regression on high-dimensional data
BTo increase the number of features in the dataset for better model training
CTo reduce high-dimensional data to a lower dimension for visualization while preserving local structure
DTo cluster data points into predefined groups based on labels
Attempts:
2 left
💡 Hint

Think about what t-SNE does to data dimensions and what it tries to keep intact.

Predict Output
intermediate
2:00remaining
t-SNE Output Shape

Given the following Python code using sklearn's t-SNE, what is the shape of tsne_result?

ML Python
from sklearn.manifold import TSNE
import numpy as np

X = np.random.rand(100, 50)  # 100 samples, 50 features
model = TSNE(n_components=2, random_state=42)
tsne_result = model.fit_transform(X)
print(tsne_result.shape)
A(100, 2)
B(50, 2)
C(2, 100)
D(100, 50)
Attempts:
2 left
💡 Hint

Remember, t-SNE reduces features but keeps the number of samples.

Hyperparameter
advanced
2:00remaining
Effect of Perplexity in t-SNE

Which statement best describes the effect of increasing the perplexity parameter in t-SNE?

AHigher perplexity reduces the number of iterations needed for convergence
BHigher perplexity decreases the number of output dimensions
CHigher perplexity increases the learning rate automatically
DHigher perplexity considers more neighbors, leading to a more global view of the data structure
Attempts:
2 left
💡 Hint

Think about how perplexity relates to neighborhood size in t-SNE.

Metrics
advanced
2:00remaining
Evaluating t-SNE Visualization Quality

Which metric is commonly used to evaluate how well t-SNE preserves local structure in the reduced space?

AK-nearest neighbor preservation score
BMean squared error between original and reduced data
CSilhouette score of clusters in original high-dimensional space
DAccuracy of a classification model trained on reduced data
Attempts:
2 left
💡 Hint

Consider metrics that measure neighborhood consistency after reduction.

🔧 Debug
expert
2:00remaining
Identifying t-SNE Runtime Error

What error will this code raise and why?

from sklearn.manifold import TSNE
import numpy as np

X = np.random.rand(10, 5)
model = TSNE(n_components=3, random_state=0)
result = model.fit_transform(X)
print(result.shape)
AValueError because n_components cannot be greater than 2 for t-SNE
BNo error, output shape will be (10, 3)
CTypeError because input data X is not a pandas DataFrame
DRuntimeWarning due to random_state not being set
Attempts:
2 left
💡 Hint

Check the allowed output dimensions for t-SNE in sklearn.