Bird
0
0

Using sklearn's NMF with n_components=5 on input matrix X of shape (100, 1000), what will be the shape of the components_ attribute after fitting?

medium📝 Predict Output Q4 of 15
NLP - Topic Modeling
Using sklearn's NMF with n_components=5 on input matrix X of shape (100, 1000), what will be the shape of the components_ attribute after fitting?
A(100, 1000)
B(100, 5)
C(5, 1000)
D(5, 100)
Step-by-Step Solution
Solution:
  1. Step 1: Recall NMF output shapes

    For input X (samples=100, features=1000) and n_components=5, NMF factorizes X ≈ W * H.
  2. Step 2: Understand components_ attribute

    components_ corresponds to matrix H with shape (n_components, n_features) = (5, 1000).
  3. Final Answer:

    (5, 1000) -> Option C
  4. Quick Check:

    Check sklearn NMF docs for attribute shapes [OK]
Quick Trick: components_ shape is (n_components, n_features) [OK]
Common Mistakes:
MISTAKES
  • Confusing components_ with W matrix shape
  • Swapping rows and columns in output shapes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NLP Quizzes