{"id":28374191,"url":"https://github.com/rohansardar/speechflowguard","last_synced_at":"2026-04-17T11:31:57.783Z","repository":{"id":294218461,"uuid":"985391097","full_name":"RohanSardar/SpeechFlowGuard","owner":"RohanSardar","description":"A machine learning web API that detects toxic language in user comments using classical ML","archived":false,"fork":false,"pushed_at":"2025-05-21T11:09:00.000Z","size":41801,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-25T18:45:49.649Z","etag":null,"topics":["docker","logistic-regression","machine-learning","python3","scikit-learn","tf-idf","tfidf-text-analysis","tfidf-vectorizer"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","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/RohanSardar.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,"zenodo":null}},"created_at":"2025-05-17T17:01:07.000Z","updated_at":"2025-05-21T11:09:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"a0f5a66e-f9f6-4624-a968-0738e91bdb8f","html_url":"https://github.com/RohanSardar/SpeechFlowGuard","commit_stats":null,"previous_names":["rohansardar/speechflowguard"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/RohanSardar/SpeechFlowGuard","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RohanSardar%2FSpeechFlowGuard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RohanSardar%2FSpeechFlowGuard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RohanSardar%2FSpeechFlowGuard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RohanSardar%2FSpeechFlowGuard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RohanSardar","download_url":"https://codeload.github.com/RohanSardar/SpeechFlowGuard/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RohanSardar%2FSpeechFlowGuard/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31927738,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-17T10:35:34.458Z","status":"ssl_error","status_checked_at":"2026-04-17T10:35:09.472Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["docker","logistic-regression","machine-learning","python3","scikit-learn","tf-idf","tfidf-text-analysis","tfidf-vectorizer"],"created_at":"2025-05-29T21:11:39.438Z","updated_at":"2026-04-17T11:31:57.778Z","avatar_url":"https://github.com/RohanSardar.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SpeechFlowGuard\n\nA machine learning web API that detects toxic language in user comments using classical ML models (TF-IDF + Logistic Regression). Built with **FastAPI**, trained on the **Jigsaw Toxic Comment Classification Challenge** dataset.\n\n## ✅ Features\n\n- Multi-label classification: \n  - `toxic`, `severe_toxic`, `obscene`, `threat`, `insult`, `identity_hate`\n- Real-time REST API (FastAPI)\n- Modular codebase\n- Dockerized for portability\n- Preprocessed with custom regex cleaner\n\n\n## 🧪 Model Details\n\n- Vectorizer: `TfidfVectorizer` (max_features=4096, stop_words='english')\n- Classifier: `LogisticRegression` (class_weight='balanced', max_iter=500, C=1.6)\n- Trained on: [Jigsaw Toxic Comment Dataset](https://www.kaggle.com/c/jigsaw-toxic-comment-classification-challenge)\n\n## 🗂️ Project Structure\n\n```\nSpeechFlowGuard/\n├── app/\n│   ├── main.py\n│   ├── api.py\n│   ├── model.py\n│   ├── schemas.py\n│   ├── utils.py\n│   └── config.py\n├── data/\n│   ├── data_processed.csv\n│   └── trains.csv\n├── models/\n│   ├── tf-idf_vectorizer.pkl\n│   └── classifier.pkl\n├── notebooks/\n│   ├── data_cleaning.ipynb\n│   └── tf-idf_model_train.ipynb\n├── .gitignore\n├── docker-requirements.txt\n├── Dockerfile\n├── README.md\n└── requirements.txt\n```\n\n## 🧰 Technical Stack\n- **Language:** Python 3.12+\n- **Framework:** FastAPI (ASGI-compatible)\n- **ML Model:**\n    - TfidfVectorizer for feature extraction\n    - LogisticRegression (one classifier per label, binary relevance method)\n- **Serialization:** `dill` for saving sklearn models\n- **Request Schema:** Pydantic-based input validation\n- **Serving:** Uvicorn for ASGI serving\n- **Containerization:** Docker \n\n## 📡 API Endpoints\nThe FastAPI server exposes the following endpoints:\n\n### `GET /`\n\nReturns a welcome message to confirm the API is live.\n\n**Request:**\n\n`curl http://localhost:8000/`\n\n**Response:**\n```\n{\n  \"message\": \"Hello and welcome to SpeechFlowGuard API\"\n}\n```\n### `POST /predict`\n\nPerforms multi-label classification on the input text and returns the predicted probabilities for each toxicity label.\n\n**Request:**\n```\nPOST /predict\nContent-Type: application/json\n```\n**Request Body:**\n```\n{\n  \"text\": \"You are a criminal person\"\n}\n```\n**Response:**\n```\n{\n  \"toxic\": 0.6774,\n  \"severe_toxic\": 0.039,\n  \"obscene\": 0.0994,\n  \"threat\": 0.1204,\n  \"insult\": 0.5151,\n  \"identity_hate\": 0.6681\n}\n```\n\n## 🛠️ Git Setup \u0026 Repository Cloning\nIf you haven't installed Git:\n\n### 🔨 Install Git\n**Windows:**\n\nDownload from https://git-scm.com/download/win and install with default settings.\n\n**Ubuntu/Linux:**\n```\nsudo apt update\nsudo apt install git\n```\n\n**macOS:**\n```\nbrew install git\n```\n\n### 📦 Clone the Repository\n```\ngit clone https://github.com/RohanSardar/SpeechFlowGuard.git\ncd SpeechFlowGuard\n```\n\n## 🔧 How to Train the Model\n\nEnsure you have the following installed:\n- Python (≥ 3.12)\n- Conda (for Conda-based setup)\n- Virtualenv (install via `pip install virtualenv` if not already available)\n\n### 🐍 Using conda\n#### Create a conda virtual environment\nRun the following command to create a virtual environment in a specific directory:\n```\nconda create -p venv python=3.12 -y\n```\n#### Activate it\n```\nconda activate venv/\n```\n#### Install dependencies\n```\npip install -r requirements.txt\n```\n\n### 💻 Using virtualenv\nRun the following command to create a virtual environment in a specific directory:\n```\npython -m virtualenv venv\n```\n#### Activate it\n- **Windows**\n```\nvenv\\Scripts\\activate\n```\n- **Linux/macOS**\n```\nsource venv/bin/activate\n```\n#### Install dependencies\n```\npip install -r requirements.txt\n```\n\nUse the Jupyter notebooks in `notebooks/` or create a script to:\n\n1. Load and preprocess the dataset.\n2. Train TF-IDF and LogisticRegression models.\n3. Save them using `dill`.\n\n## 🐳 Docker Setup\n🔥 1. Build the Image\n```\ndocker build -t speechflowguard .\n```\n🚀 2. Run the Container\n```\ndocker run -p 8000:8000 speechflowguard\n```\nYou can also access the interactive API docs at:\n\n- Swagger UI: http://localhost:8000/docs\n- ReDoc: http://localhost:8000/redoc\n\n**Example using cURL**\n```\ncurl -X POST http://localhost:8000/predict \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"text\": \"You are a criminal person\"}'\n```\n\n**Response**\n```\n{\n  \"toxic\": 0.6774,\n  \"severe_toxic\": 0.039,\n  \"obscene\": 0.0994,\n  \"threat\": 0.1204,\n  \"insult\": 0.5151,\n  \"identity_hate\": 0.6681\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frohansardar%2Fspeechflowguard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frohansardar%2Fspeechflowguard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frohansardar%2Fspeechflowguard/lists"}