0
0
NLPml~20 mins

Fine-grained sentiment (5-class) in NLP - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Fine-grained Sentiment Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Model Choice
intermediate
2:00remaining
Choosing the best model for 5-class sentiment classification

You want to classify movie reviews into 5 sentiment classes: very negative, negative, neutral, positive, very positive. Which model is best suited for this task?

AA regression model predicting a continuous sentiment score from 1 to 5.
BA binary logistic regression model trained to predict positive vs negative sentiment.
CA clustering algorithm like K-means to group reviews into 5 clusters.
DA multi-class logistic regression model trained to predict one of the 5 sentiment classes.
Attempts:
2 left
💡 Hint

Think about the type of output needed: discrete classes vs continuous values.

Metrics
intermediate
1:30remaining
Evaluating a 5-class sentiment classifier

You trained a 5-class sentiment classifier. Which metric best measures overall accuracy across all classes?

AAccuracy (percentage of correct predictions)
BPrecision for the positive class only
CRecall for the negative class only
DMean Squared Error (MSE)
Attempts:
2 left
💡 Hint

Consider a metric that accounts for all classes equally.

Predict Output
advanced
2:00remaining
Output of softmax layer for 5-class sentiment

Given the logits output from a neural network for 5 sentiment classes as [2.0, 1.0, 0.1, 0.5, 3.0], what is the predicted class index after applying softmax and choosing the highest probability?

NLP
import numpy as np
logits = np.array([2.0, 1.0, 0.1, 0.5, 3.0])
exp_logits = np.exp(logits - np.max(logits))
probs = exp_logits / exp_logits.sum()
predicted_class = np.argmax(probs)
print(predicted_class)
A0
B4
C1
D2
Attempts:
2 left
💡 Hint

Softmax picks the class with the highest logit after normalization.

Hyperparameter
advanced
1:30remaining
Choosing batch size for training a 5-class sentiment model

You are training a neural network for 5-class sentiment classification on a dataset of 10,000 reviews. Which batch size is likely to give a good balance of training speed and stable gradient updates?

ABatch size of 64
BBatch size of 1 (stochastic gradient descent)
CBatch size of 10,000 (full batch gradient descent)
DBatch size of 1,000,000
Attempts:
2 left
💡 Hint

Consider typical batch sizes used in practice for stability and speed.

🔧 Debug
expert
2:30remaining
Debugging incorrect predictions in 5-class sentiment model

Your 5-class sentiment model always predicts the 'neutral' class regardless of input. Which is the most likely cause?

AThe optimizer learning rate is set to a moderate value like 0.001.
BThe model uses ReLU activation in hidden layers.
CThe model's output layer uses softmax activation but the loss function is mean squared error.
DThe training data is perfectly balanced across all 5 classes.
Attempts:
2 left
💡 Hint

Think about compatibility between output activation and loss function.