How agnare/staffsenseml works
StaffSenseML is a FastAPI microservice that accepts employee features from StaffSense, predicts attrition risk, and returns a score, risk factors, and retention actions. Its prediction path runs through request validation and the predictor; the service can use a trained scikit-learn model or a weights-based fallback. A separate documented retraining path generates synthetic data and saves model artifacts. The tree and excerpts support these main responsibilities, but omitted portions of services.py leave some internal sequencing uncertain.
Main entry points: services.py Prediction service · train.py Training workflow · main.py FastAPI endpoints · weights.json Fallback weights
Components 16
API boundary
- FastAPI endpoints
main.py - Request and response schemas
schemas.py - Prediction response
schemas.py
Risk prediction
- Prediction service
services.py - Feature preparation
services.py - Model scoring
services.py - Risk score and level
services.py - Trained model and scaler
model - Fallback weights
model/weights.json
Decision support
- Risk factor analysis
services.py - Retention action plan
services.py
Model training
- Training workflow
train.py - Synthetic employee data
train.py - Training dataset
train.py - Saved model artifacts
model
Other components
- StaffSense client
Connections 17
- StaffSense client → FastAPI endpoints: POST prediction
- FastAPI endpoints → Request and response schemas: validates request
- FastAPI endpoints → Prediction service: calls predict
- Prediction service → Feature preparation: prepares features
- Prediction service → Model scoring: scores features
- Prediction service → Trained model and scaler: loads model and scaler
- Prediction service → Fallback weights: loads fallback
- Prediction service → Risk score and level: computes risk
- Prediction service → Risk factor analysis: analyzes factors
- Prediction service → Retention action plan: generates actions
- Prediction service → Prediction response: builds response
- FastAPI endpoints → StaffSense client: returns prediction
- Training workflow → Synthetic employee data: generates records
- Synthetic employee data → Training dataset: writes dataset
- Training workflow → Training dataset: loads for training
- Training workflow → Saved model artifacts: saves model and scaler
- Training workflow → Fallback weights: writes weights