Skip to content

A Python-based sentiment analysis project that predicts whether a given text is positive or negative using a Naive Bayes model. The model is integrated with a FastAPI backend, allowing programmatic access via a REST API. The project demonstrates machine learning pipelines, API development, and modular code organization.

Notifications You must be signed in to change notification settings

Poorna-Raj/simple-sentiment-analysis-model

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sentiment Analysis API

Overview

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

Tech Stack

  • Python – core language

  • scikit-learn – model training and pipelines

  • FastAPI – REST API backend

  • Joblib – model serialization

Features

  • Predict sentiment of text input (positive/negative)

  • Modular pipeline for preprocessing and model inference

  • Simple API endpoint to integrate with other applications

Getting Started

  1. Clone the Repository
git clone https://github.com/Poorna-Raj/simple-sentiment-analysis-model.git
cd sentiment-analysis
  1. Install Dependencies
pip install -r requirements.txt
  1. Get the dataset and move to data folder
https://www.kaggle.com/datasets/lakshmi25npathi/imdb-dataset-of-50k-movie-reviews
  1. Run the API
cd app
fastapi dev main.py

Api Usage

  1. Visit the Api documentation(Swagger)
http://127.0.0.1:8000/docs

api screenshot

Model Details

  • Algorithm: Multinomial Naive Bayes

  • Preprocessing: Tokenization, vectorization using CountVectorizer, handled via scikit-learn pipeline

  • Accuracy: ~86% on test set

About

A Python-based sentiment analysis project that predicts whether a given text is positive or negative using a Naive Bayes model. The model is integrated with a FastAPI backend, allowing programmatic access via a REST API. The project demonstrates machine learning pipelines, API development, and modular code organization.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages