This solution is based on the IMDB Dataset of 50K Movie Reviews. The dataset is used to perform sentiment analysis on the movie reviews. The trained model is served as a REST API using FastAPI and dockerized using Docker.
You can find the API hosted at https://sentiment-analysis.astro-dev.tech
- Python 3.12
- Scikit-learn
- Pandas
- FastAPI
- Docker
The model is trained using a dataset of 50K IMDB reviews:
- Open the app/sentiment_analysis.ipynb notebook.
- Follow the steps for Exploratory Data Analysis (EDA) and model training.
- Save the trained model and vectorizer as .pkl files in the models directory.
GET /
: Returns a welcome messagePOST /analyze/
: Perform sentiment analysis on the input text
Make sure to execute all the cells in the notebook (app/sentiment_analysis.ipynb) sequentially to train and save the model before running the API.
- Build the docker image
docker build -t imdb-sentiment-analysis .
- Run the docker image
docker run -p 8000:8000 imdb-sentiment-analysis
- Access the API
http POST localhost:8000/analyze input_text="i really like react hooks" --follow
- Install the requirements
pip install -r requirements.txt
- Run the app
python app/main.py
- Access the API
http POST localhost:8000/analyze input_text="i really like react hooks" --follow