0
0
NLPml~20 mins

Visualizing embeddings (t-SNE) in NLP - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Embedding Visualization Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
1:30remaining
Output of t-SNE embedding shape
Given the following code snippet that applies t-SNE on a set of 100 word embeddings each of dimension 50, what is the shape of the output embedding array?
NLP
from sklearn.manifold import TSNE
import numpy as np

embeddings = np.random.rand(100, 50)
tsne = TSNE(n_components=2, random_state=42)
reduced_embeddings = tsne.fit_transform(embeddings)
print(reduced_embeddings.shape)
A(50, 100)
B(2, 50)
C(100, 2)
D(100, 50)
Attempts:
2 left
💡 Hint
t-SNE reduces the dimensionality to the number of components specified.
🧠 Conceptual
intermediate
1:00remaining
Purpose of perplexity in t-SNE
What does the 'perplexity' parameter control in the t-SNE algorithm when visualizing embeddings?
AThe number of nearest neighbors considered during the embedding
BThe learning rate for gradient descent optimization
CThe final number of dimensions after reduction
DThe random seed for reproducibility
Attempts:
2 left
💡 Hint
Think about how t-SNE balances local and global aspects of data.
Metrics
advanced
1:30remaining
Evaluating t-SNE visualization quality
Which metric is commonly used to evaluate how well a t-SNE visualization preserves the local structure of high-dimensional data?
AKullback-Leibler divergence
BMean Squared Error
CAccuracy
DSilhouette Score
Attempts:
2 left
💡 Hint
t-SNE minimizes a specific divergence during training.
🔧 Debug
advanced
2:00remaining
Identifying error in t-SNE usage
What error will the following code raise when trying to visualize embeddings with t-SNE?
NLP
from sklearn.manifold import TSNE
import numpy as np

embeddings = np.random.rand(50, 100)
tsne = TSNE(n_components=3)
reduced = tsne.fit_transform(embeddings)
print(reduced.shape)
ATypeError: fit_transform() missing 1 required positional argument
BAttributeError: 'TSNE' object has no attribute 'fit_transform'
CValueError: n_components must be less than original dimension
DNo error, output shape is (50, 3)
Attempts:
2 left
💡 Hint
Check the relationship between n_components and input dimension.
Model Choice
expert
2:30remaining
Choosing dimensionality reduction for large NLP embeddings
You have 1 million word embeddings of dimension 300 and want to visualize them in 2D. Which dimensionality reduction technique is most suitable considering both speed and quality?
At-SNE with default parameters
BUMAP on the full dataset
CPCA followed by t-SNE on a sample
DRandom projection to 2D
Attempts:
2 left
💡 Hint
Consider scalability and preservation of local/global structure.