Threat Detection using Machine Learning is a FastAPI web app that detects toxic, threatening, and cyberbullying text using a hybrid machine learning approach. It combines a TF-IDF Logistic Regression model with Hugging Face Toxic-BERT to classify text as malicious or safe, provide confidence scores, severity levels, and threat categories.
The system includes prediction APIs, scan history, keyword highlighting, AWS S3 artifact storage, Docker support, CI/CD automation, and an analytics dashboard for monitoring detected threats.
- Detects toxic, threatening, cyberbullying, and unsafe text.
- Uses a hybrid model: Logistic Regression + TF-IDF + Hugging Face Toxic-BERT.
- Returns prediction label, confidence score, severity, threat category, sentiment, and highlighted keywords.
- Provides a web scanner UI and analytics dashboard.
- Stores scan history in SQLite.
- Supports model/data artifact upload and download with AWS S3.
- Supports Docker and Docker Compose for local and production-style runs.
- Includes GitHub Actions CI/CD for validation, Docker image publishing, S3 artifact upload, Hugging Face Space deployment, and AWS EC2 deployment.
git clone https://github.com/vuchau0802/Threat-Detection-using-Machine-Learning.git
cd Threat-Detection-using-Machine-LearningWindows (PowerShell):
python -m venv venv
venv\Scripts\activateMac / Linux:
python3 -m venv venv
source venv/bin/activate.\.venv\Scripts\Activate.ps1python -m pip install --upgrade pip
python -m pip install -r requirements.txt$env:AWS_S3_BUCKET="threat-detection-vutrongchau"
$env:AWS_S3_KEY="threat-detection/artifacts.zip"
$env:AWS_REGION="us-east-2"
$env:AWS_ACCESS_KEY_ID="your-access-key-id"
$env:AWS_SECRET_ACCESS_KEY="your-secret-access-key"python AWS/s3_store.py downloadpython -m uvicorn app:app --host 127.0.0.1 --port 5000http://127.0.0.1:5000
http://127.0.0.1:5000/dashboard


