
Streamlit-based insider threat detection prototype using XGBoost and Isolation Forest to analyze employee activity data, generate risk summaries, and provide SHAP-based per-employee explanations.
ThreatDetect is a Streamlit-based insider threat detection prototype that analyzes employee activity data and flags potentially risky behavior. It uses a trained XGBoost classifier together with an Isolation Forest anomaly detector to produce organisation-level risk summaries and explainable employee-level insights.
The app can be run locally using Streamlit. A deployed demo was previously published at:
streamlit_app.py — main Streamlit applicationrequirements.txt — Python package dependenciesAI_Model_Code/insider_threat_model.pkl — saved inference pipeline and trained model artifactsAI_Model_Code/insider_threat_clean_dataset.csv — bundled sample dataset for EDAAI_Model_Code/cos720_ai_model_FINAL.ipynb — model development notebookassets/app_styling.css — custom UI styling for the Streamlit appunit testing/ — test files for feature preparation and explanation logicdocs/TECHNICAL_DOCUMENTATION.md — technical documentation for the projectstreamlitpandasnumpyscikit-learnmatplotlibseabornplotlyxgboostshapInstall all dependencies with:
pip install -r requirements.txt
git clone https://github.com/jazbengu/ThreatDetect.git
cd ThreatDetect
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Start the app with:
streamlit run streamlit_app.py
Then open the local URL shown in the terminal (usually http://localhost:8501).
Run Threat Detection to calculate risk probabilities for each record.AI_Model_Code/insider_threat_clean_dataset.csv.Organisational Search via CSV is the main batch threat detection workflow.Single Search is shown in the sidebar but is not currently implemented in the app logic.Exploratory Data Analysis is available for dataset exploration and quick anomaly checks.AI_Model_Code/insider_threat_model.pkl contains a serialized model package with:
xgb_model: trained XGBoost classifieriso_forest: trained Isolation Forest anomaly detectorscaler: StandardScaler for numeric inputslabel_encoders: encoders for categorical featuresfeature_columns: ordered feature listcat_cols, num_cols, bin_cols: feature groupingsbest_threshold: classification threshold used for risk decisionsshap_explainer: SHAP explainer for explainabilityThe model file is loaded by streamlit_app.py and used to preprocess inputs, compute risk probabilities, and generate explanations.
The repository includes tests under unit testing/.
Run the test suite with:
pytest "unit testing/"
This repository is configured for enhancement and testing. Future improvements may include expanding feature coverage, and retraining the model with additional insider threat data.