0
0
ML Pythonml~10 mins

UMAP for dimensionality reduction 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 UMAP class from the umap-learn library.

ML Python
from umap import [1]
Drag options to blanks, or click blank then click option'
AKMeans
BPCA
CTSNE
DUMAP
Attempts:
3 left
💡 Hint
Common Mistakes
Importing PCA or TSNE instead of UMAP.
Trying to import from sklearn instead of umap.
2fill in blank
medium

Complete the code to create a UMAP object with 2 output dimensions.

ML Python
reducer = UMAP(n_components=[1])
Drag options to blanks, or click blank then click option'
A2
B1
C10
D3
Attempts:
3 left
💡 Hint
Common Mistakes
Using 3 or more components when 2 is needed for 2D plots.
Using 1 component which reduces to 1D, not 2D.
3fill in blank
hard

Fix the error in the code to fit and transform data using UMAP.

ML Python
embedding = reducer.[1](data)
Drag options to blanks, or click blank then click option'
Afit_transform
Bfit
Ctransform
Dpredict
Attempts:
3 left
💡 Hint
Common Mistakes
Using fit alone which does not return transformed data.
Using predict which is not a method for UMAP.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps each word to its length if length is greater than 3.

ML Python
{word: [1] for word in words if [2]
Drag options to blanks, or click blank then click option'
Alen(word)
Blen(word) > 3
Cword.startswith('a')
Dword.isalpha()
Attempts:
3 left
💡 Hint
Common Mistakes
Using word.startswith('a') which filters words starting with 'a' instead of length.
Using word.isalpha() which checks if word has only letters.
5fill in blank
hard

Fill all three blanks to create a dictionary of embeddings where keys are uppercase words, values are the first component of embedding, and only include if the first component is positive.

ML Python
{ [1]: embedding[i, 0] for i, [2] in enumerate(words) if embedding[i, 0] [3] 0 }
Drag options to blanks, or click blank then click option'
Aword.upper()
Bword
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' in the condition.
Using 'i' instead of 'word' in the loop unpacking.