review-sentiment

This was a group project for a machine learning course at Portland State. The task was predicting the star rating (1 to 5) of an Amazon review from its text, and we split it by method - a Naive Bayes classifier, a multilayer perceptron, and BERT - so we could compare them on the same data. I was in charge of BERT.

That mostly meant fine-tuning bert-base-uncased for five-class sequence classification: tokenizing reviews to a fixed length, attaching a classification head, and training with a low learning rate. It was a lot of practice with the mechanics of adapting a pretrained model to a specific task, as opposed to training something from scratch.

I also added a second metric alongside plain accuracy: predictions within one star of the true rating. Star ratings are ordinal, and treating them as five unrelated classes makes a 4-for-5 mistake look as bad as a 1-for-5 mistake, which doesn’t reflect how wrong the model actually is.

Again this was just a school project, but if you’re interested the code is here on GitHub.

← Back to Projects