Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import the library used for dimensionality reduction visualization.
ML Python
from sklearn.manifold import [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
2fill in blank
mediumComplete the code to create a TSNE object with 2 components for visualization.
ML Python
tsne = TSNE(n_components=[1], random_state=42)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
3fill in blank
hardFix the error in the code to fit and transform the data using TSNE.
ML Python
X_embedded = tsne.[1](X) Drag options to blanks, or click blank then click option'
Attempts:
3 left
4fill in blank
hardFill both blanks to create a scatter plot of the 2D TSNE results with labels.
ML Python
plt.scatter(X_embedded[:, [1]], X_embedded[:, [2]], c=labels, cmap='viridis') plt.xlabel('Dimension 1') plt.ylabel('Dimension 2') plt.title('TSNE Visualization') plt.colorbar()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
5fill in blank
hardFill all three blanks to create a dictionary comprehension that maps each label to its count in the dataset.
ML Python
label_counts = [1] [2] for [3] in set(labels)}
Drag options to blanks, or click blank then click option'
Attempts:
3 left