Skip to content

mwbrulhardt/yelp-absa

Repository files navigation

Where should I eat after the pandemic?: Decision Making with Aspect-Based Sentiment Analysis Using Transformers.

Exploring the Yelp dataset using Aspect-Based Sentiment Analysis.

Installation

To install all the required libraries run,

$ pip install -r requirements.txt

Part 1

The following code is associated with the first Medium article of my 2 part series.

Setup

Run the setup script to create all the proper files and directories. Use the --skip-yelp flag to skip downloading the Yelp dataset from Kaggle.

$ python setup.py --skip-yelp

Train and Evaluate

For the model_id parameter, you can select any model from the transformers library that supports sentence-pair classification.

Train the model by running the following command:

$ python train.py --model-id=distilbert-base-uncased --epochs=4 --batch-size=24 --lr=5e-2

These are the models I've used on this task:

  • prajjwal1/bert-tiny
  • prajjwal1/bert-small
  • distilbert-base-uncased
  • bert-base-uncased

Of these models, I've found distilbert to be the best.

drawing

Part 2

The following is code associated with the second article of the 2 part Medium series. Make sure that you have run part 1 before running any of the following. Additionally, make sure you have kaggle setup on your computer.

Setup

The following will download the data from Yelp:

$ python setup.py

Run

Run the trained model over all tips in the Yelp dataset using,

$ python run.py --model-id=distilbert-base-uncased --batch-size=15

drawing

Generate all charts associated with your trained model, as shown in the Medium article.

$ python make_charts.py --model-id=distilbert-base-uncased

Find out your results by choosing your importance weights for each aspect of a restaurant.

$ python find.py --model-id=distilbert-base-uncased --importances=7,9,10,5,5,2

drawing

References

About

Exploring the Yelp dataset using aspect-based sentiment analysis.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages