A simple sentiment analysis project that predicts whether a given text is positive or negative.
-
Trained using Python and scikit-learn
-
Uses a Naive Bayes model with pipelines for preprocessing and prediction
-
Exposed via a FastAPI backend for programmatic access
-
Python – core language
-
scikit-learn – model training and pipelines
-
FastAPI – REST API backend
-
Joblib – model serialization
-
Predict sentiment of text input (positive/negative)
-
Modular pipeline for preprocessing and model inference
-
Simple API endpoint to integrate with other applications
- Clone the Repository
git clone https://github.com/Poorna-Raj/simple-sentiment-analysis-model.git
cd sentiment-analysis- Install Dependencies
pip install -r requirements.txt- Get the dataset and move to
datafolder
https://www.kaggle.com/datasets/lakshmi25npathi/imdb-dataset-of-50k-movie-reviews- Run the API
cd app
fastapi dev main.py- Visit the Api documentation(Swagger)
http://127.0.0.1:8000/docs-
Algorithm: Multinomial Naive Bayes
-
Preprocessing: Tokenization, vectorization using CountVectorizer, handled via scikit-learn pipeline
-
Accuracy: ~86% on test set
