{"id":19297056,"url":"https://github.com/tarunsha009/sentiment-analysis-api","last_synced_at":"2026-04-09T20:37:16.157Z","repository":{"id":261536320,"uuid":"884597567","full_name":"tarunsha009/sentiment-analysis-api","owner":"tarunsha009","description":"Sentiment Analysis API: A Flask-based API to classify text sentiment as Positive, Neutral, or Negative using machine learning.","archived":false,"fork":false,"pushed_at":"2024-11-07T03:43:15.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-05T21:43:43.409Z","etag":null,"topics":["api","flask","genai","machine-learning","ml","python","sentiment-analysis"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tarunsha009.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-07T03:24:52.000Z","updated_at":"2024-11-07T03:43:18.000Z","dependencies_parsed_at":"2024-11-07T04:31:17.373Z","dependency_job_id":"65b574ae-fb30-4b8a-b492-083f79d2cd4e","html_url":"https://github.com/tarunsha009/sentiment-analysis-api","commit_stats":null,"previous_names":["tarunsha009/sentiment-analysis-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarunsha009%2Fsentiment-analysis-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarunsha009%2Fsentiment-analysis-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarunsha009%2Fsentiment-analysis-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarunsha009%2Fsentiment-analysis-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tarunsha009","download_url":"https://codeload.github.com/tarunsha009/sentiment-analysis-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240400292,"owners_count":19795331,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","flask","genai","machine-learning","ml","python","sentiment-analysis"],"created_at":"2024-11-09T23:01:07.603Z","updated_at":"2026-04-09T20:37:11.131Z","avatar_url":"https://github.com/tarunsha009.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sentiment Analysis API\n\n![Python](https://img.shields.io/badge/Python-3.12%2B-blue)\n![Flask](https://img.shields.io/badge/Framework-Flask-green)\n![AI](https://img.shields.io/badge/Machine%20Learning-AI-yellow)\n![Natural Language Processing](https://img.shields.io/badge/NLP-Natural%20Language%20Processing-orange)\n![Sentiment Analysis](https://img.shields.io/badge/Sentiment%20Analysis-Project-lightblue)\n![GenAI](https://img.shields.io/badge/Generative%20AI-GenAI-blueviolet)\n![License](https://img.shields.io/badge/License-MIT-blue)\n\n\n\nThis project is a **Sentiment Analysis API** built with Flask and Flask-RESTx. It classifies input text into **Positive**, **Neutral**, or **Negative** sentiment categories, using a trained machine learning model.\n\n---\n\n## Table of Contents\n\n- [Project Overview](#project-overview)\n- [Features](#features)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Project Structure](#project-structure)\n- [Model and API Details](#model-and-api-details)\n- [Future Improvements](#future-improvements)\n- [Contributing](#contributing)\n- [License](#license)\n\n---\n\n## Project Overview\n\nThe API is designed to classify text-based inputs by sentiment, helping users analyze the tone of sentences or reviews. It leverages a Logistic Regression model with TF-IDF vectorization for efficient text classification.\n\n---\n\n## Features\n\n- **Sentiment Classification**: Predicts Positive, Neutral, or Negative sentiment for input text.\n- **Confidence Score**: Returns the model's confidence level for each prediction.\n- **REST API**: Built with Flask and Flask-RESTx, with automatic API documentation.\n- **Error Handling**: Provides clear error messages for invalid inputs.\n\n---\n\n## Installation\n\n### 1. Clone the Repository\n   ```bash\n   git clone https://github.com/tarunsha009/sentiment-analysis-api\n   cd sentiment-analysis-api\n   ```\n\n### 2. Create a Virtual Environment\n   ```bash\n   python3 -m venv venv\n   source venv/bin/activate  # On Windows use: venv\\Scripts\\activate\n   ```\n\n### 3. Install Dependencies\n   ```bash\n   pip install -r requirements.txt\n   ```\n\n### 4. Train the Model\n   Run `train_model.py` to preprocess data, train the model, and save it as `text_classifier_model.joblib`.\n   ```bash\n   python train_model.py\n   ```\n\n### 5. Run the API\n   Start the Flask API server.\n   ```bash\n   python app.py\n   ```\n\n---\n\n## Usage\n\nTo classify the sentiment of a sentence, send a POST request to `/predict` with the text you want to analyze. \n\n**Example Request**:\n```bash\ncurl -X POST http://127.0.0.1:5000/predict -H \"Content-Type: application/json\" -d '{\"text\": \"The product is amazing!\"}'\n```\n\n**Example Response**:\n```json\n{\n  \"text\": \"The product is amazing!\",\n  \"predicted_sentiment\": \"Positive\",\n  \"confidence\": 0.82\n}\n```\n\n---\n\n## Project Structure\n\n```\nsentiment-analysis-api/\n├── app.py              # Flask API with Flask-RESTx\n├── preprocessor.py     # Preprocessing module for text data\n├── train_model.py      # Model training script\n├── requirements.txt    # Project dependencies\n└── README.md           # Project documentation\n```\n\n---\n\n## Model and API Details\n\n- **Model**: Logistic Regression with TF-IDF vectorization (bigrams)\n- **Training Data**: Custom dataset with labeled Positive, Neutral, and Negative examples\n- **Confidence Threshold**: Optional threshold set to avoid low-confidence predictions (configurable in `app.py`)\n\n---\n\n## Future Improvements\n\n- **Expand Training Data**: Incorporate larger datasets for improved accuracy.\n- **Advanced Models**: Experiment with transformer-based models for nuanced sentiment analysis.\n- **Deployment**: Deploy the API on cloud services like AWS, GCP, or Azure.\n\n---\n\n## Contributing\n\nContributions are welcome! Feel free to submit pull requests or open issues to improve the project.\n\n---\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftarunsha009%2Fsentiment-analysis-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftarunsha009%2Fsentiment-analysis-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftarunsha009%2Fsentiment-analysis-api/lists"}