0
0
ML Pythonml~10 mins

t-SNE for visualization in ML Python - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the t-SNE class from scikit-learn.

ML Python
from sklearn.manifold import [1]
Drag options to blanks, or click blank then click option'
ATSNE
BtSNE
Ctsne
DTSne
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase or incorrect capitalization for TSNE.
Trying to import from sklearn.cluster instead of sklearn.manifold.
2fill in blank
medium

Complete the code to create a t-SNE object with 2 output dimensions.

ML Python
tsne = TSNE(n_components=[1])
Drag options to blanks, or click blank then click option'
A1
B3
C0
D2
Attempts:
3 left
💡 Hint
Common Mistakes
Setting n_components to 3 or 1 which are not typical for 2D visualization.
Using 0 which is invalid.
3fill in blank
hard

Fix the error in the code to fit and transform data using t-SNE.

ML Python
X_embedded = tsne.[1](X)
Drag options to blanks, or click blank then click option'
Afit
Bfit_transform
Ctransform
Dfit_predict
Attempts:
3 left
💡 Hint
Common Mistakes
Using fit() alone which does not return transformed data.
Using transform() which is not supported by t-SNE.
Using fit_predict() which is not a method of TSNE.
4fill in blank
hard

Fill both blanks to create a scatter plot of the t-SNE results with colors.

ML Python
plt.scatter(X_embedded[:, [1]], X_embedded[:, [2]], c=labels, cmap='viridis')
Drag options to blanks, or click blank then click option'
A0
B1
C2
D3
Attempts:
3 left
💡 Hint
Common Mistakes
Using indices 1 and 2 which may cause index errors.
Using 2 or 3 which are out of range for 2D data.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps each label to the count of points with that label.

ML Python
label_counts = {label: sum(1 for x in labels if x [1] label) for label in set(labels) if label [2] 0 and label [3] -1}
Drag options to blanks, or click blank then click option'
A==
B>
C!=
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong comparison operators causing logic errors.
Confusing != and == in conditions.