A sequence classification problem assigns one class label to an input sequence, even when sequences have different lengths. The sequence may be treated as a time series with T steps, such as words in a sentence, characters in a name, or daily measurements. An RNN processes the sequence and uses its final activation hT to produce a class prediction. section 4.0
Common classification uses include:
- Detect sentiment as positive, negative, or neutral from a sentence, tweet, or paragraph. section 4.0
- Predict whether vehicle measurements indicate repairs within a future period. section 4.0
- Classify weather or traffic outcomes from daily measurements such as temperature, humidity, and wind speed. section 4.0
A practical PyTorch pipeline first turns nonnumeric sequence items into integer IDs. A vocabulary maps each character or token to a unique value; a Dataset stores the sequences and their labels; and data loaders provide training and test examples. For name-origin classification, each name is a variable-length character sequence and the language is its label. Ambiguous names make perfect accuracy impossible, while class imbalance requires care during evaluation. section 4.2.1
Classifying a name's language
Represent “Steven” as a sequence of character IDs, feed those characters through an RNN, and pass the final activation to a linear layer that predicts a language class. “Frank” illustrates an unavoidable edge case because it may belong to more than one language. section 4.2.1
Sequence order is useful but not mandatory. An alternative embeds each item, applies the same network independently at every time step, averages the resulting representations, and sends the fixed-size vector to a classifier. This handles changing T efficiently, but discards order and may reduce prediction quality. section 12.2
