Challenge - 5 Problems
Text Classification Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate1:30remaining
Purpose of Text Classification
Why do we use text classification in machine learning?
Attempts:
2 left
💡 Hint
Think about what it means to sort or label text automatically.
✗ Incorrect
Text classification is used to automatically assign labels or categories to text based on its content, helping organize and understand large amounts of text data.
❓ Model Choice
intermediate1:30remaining
Choosing a Model for Text Classification
Which model is commonly used for text classification tasks?
Attempts:
2 left
💡 Hint
Look for a model that can learn patterns in text sequences.
✗ Incorrect
CNNs can capture local patterns in text and are effective for text classification tasks. K-Means is unsupervised clustering, Linear Regression is for continuous outputs, and PCA is for dimensionality reduction.
❓ Metrics
advanced2:00remaining
Evaluating Text Classification Accuracy
You trained a text classification model and got these results on test data: 80 true positives, 10 false positives, 15 false negatives, and 95 true negatives. What is the precision of the model?
Attempts:
2 left
💡 Hint
Precision = True Positives / (True Positives + False Positives)
✗ Incorrect
Precision measures how many predicted positive cases are actually positive. Here, precision = 80 / (80 + 10) = 0.89.
🔧 Debug
advanced2:00remaining
Debugging Text Classification Code Output
What error will this code produce?
```python
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.naive_bayes import MultinomialNB
texts = ['spam message', 'ham message']
labels = [1, 0]
vectorizer = CountVectorizer()
X = vectorizer.fit_transform(texts)
model = MultinomialNB()
model.fit(X, labels)
pred = model.predict(['spam message'])
print(pred)
```
Attempts:
2 left
💡 Hint
Check the input type for the predict method.
✗ Incorrect
The predict method expects a vectorized input, not a raw string. Passing a string causes a TypeError.
🧠 Conceptual
expert2:30remaining
Why Text Classification Uses Predefined Categories
Why does text classification require predefined categories before training?
Attempts:
2 left
💡 Hint
Think about supervised learning and how labels guide the model.
✗ Incorrect
Text classification is a supervised task where the model learns from labeled examples to assign new texts to the same predefined categories.