US Visa Approval Prediction Platform
A modular, production-oriented machine learning platform that predicts US visa application outcomes. The system covers ingestion from MongoDB, schema validation & drift checks, preprocessing and class-imbalance handling, model training and evaluation, and conditional promotion to production (S3), with a FastAPI inference layer for real-time predictions.
Dataset
Source: Kaggle → MongoDB
The dataset includes employer characteristics and applicant attributes.
It contains categorical and numerical variables, with a derived feature (company_age) used to improve the model.
| Feature | Type | Description |
|---|---|---|
| case_id | categorical | Unique applicant identifier |
| continent | categorical | Applicant continent |
| education_of_employee | categorical | Highest education level |
| has_job_experience | categorical | Job experience flag (Y/N) |
| requires_job_training | categorical | Training required (Y/N) |
| region_of_employment | categorical | US region of employment |
| unit_of_wage | categorical | Wage unit (Hour/Week/Month/Year) |
| full_time_position | categorical | Employment type (Y/N) |
| no_of_employees | numerical | Company size |
| yr_of_estab | numerical | Company establishment year |
| prevailing_wage | numerical | Salary / wage |
| company_age | numerical | Derived: current_year − yr_of_estab |
| case_status | target | Approved / Denied |
Data Storage & Ingestion
MongoDB • PyMongo • PandasData is stored in MongoDB as BSON documents. The ingestion component connects via PyMongo using a connection URI stored in environment variables (credentials are not hardcoded). The collection is loaded into a Pandas DataFrame for downstream pipeline stages.
# High-level ingestion workflow
1) MongoClient(uri_from_env)
2) db = client[database_name]
3) collection.find(...)
4) DataFrame(records)
5) Save snapshot → us_visa.csv
6) Train/Test split → train.csv, test.csv
CI/CD & Automation
MLOps ReadinessThe project is structured for automation: reproducible artifacts, automated metric logging, and conditional promotion. This design supports future CI/CD integration (e.g., GitHub Actions) for consistent training, testing, and deployment.
- Automated artifact creation per pipeline stage
- Metric persistence for run-to-run comparison
- Promotion policy prevents model regression
- Extensible for scheduled retraining and monitoring
Pipeline Architecture
Artifacts • ReproducibilityThe platform follows a staged pipeline design where each component produces versioned artifacts. This supports reproducibility, traceability, and controlled model promotion based on objective metrics.
Data Ingestion
Load from MongoDB → snapshot us_visa.csv → split into train.csv/test.csv.
Data Validation
Schema checks + drift reporting to detect distribution shifts that can degrade model performance using Evidently.
Data Transformation
Feature engineering, encoding, scaling, target mapping, and SMOTEENN imbalance handling. Preprocessing object saved to the artifact folder.
Model Training
Train multiple models using neuro_mf + GridSearchCV for hyperparameter tuning. Best model saved to artifact folder.
Model Evaluation
Compare trained model vs production baseline using F1-score; accept only if it improves.
Model Pusher
Push model artifacts to S3 when accepted (or on first run); otherwise retain production model.
artifact/
├── data_ingestion/
│ ├── feature_store/
│ │ └── us_visa.csv
│ └── ingested/
│ ├── train.csv
│ └── test.csv
├── data_validation/
│ └── drift_report.yaml
├── data_transformation/
│ ├── transformed_object/
│ │ └── preprocessing.pkl
│ └── transformed/
│ ├── train.npy
│ └── test.npy
├── model_trainer/
│ └── trained_model.pkl
└── metric/
└── metric.csv
Data Validation
Schema • Drift ReportThe validation stage ensures the ingested data matches expected schema (column presence, correct column counts) and generates a drift report by comparing reference vs current distributions. Drift monitoring is crucial because changes in feature distributions can reduce predictive quality over time.
- Column count check against schema config
- Required categorical & numerical column presence
- Dataset drift detection and persisted report artifact
Data Transformation
Preprocessing Object
Transformation applies feature engineering (company_age), drops non-essential fields, encodes categoricals, scales numericals,
maps targets to numeric labels, and handles class imbalance using SMOTEENN. The preprocessing pipeline is serialized to guarantee identical
transformations during inference.
- Feature engineering:
company_age - Encoding: OneHot/Label as required
- Scaling: StandardScaler
- Imbalance handling: SMOTEENN
- Outputs:
preprocessing.pkl,train.npy,test.npy
Model Training
GridSearchCV • Model SelectionThe training component fits 2 models and performs hyperparameter tuning via GridSearchCV. The best tuned model is saved as the training output artifact.
- Models: Random Forest, KNN
- Hyperparameter tuning: GridSearchCV
- Final model artifact:
trained_model.pkl
Model Evaluation
F1 Score • Baseline ComparisonEach training run is evaluated against the current production model. The system uses F1-score to reduce the risk of performance regression, especially under class imbalance. Only models that outperform the baseline are promoted.
- If no production model exists → push trained model to production
- If production exists → compare F1(trained) vs F1(production)
- Push only when improved → conditional deployment
Prediction Pipeline (Inference)
FastAPI • Low LatencyThe inference layer converts user inputs into a DataFrame, loads the production model (and preprocessing object), and returns a prediction. Inference does not trigger retraining—retraining is explicitly initiated via the training endpoint to keep prediction latency predictable.
# Inference flow
1) Collect input features (UI / API)
2) Convert to DataFrame
3) Load preprocessing.pkl + production model from S3
4) Transform inputs
5) Predict → Approved / Denied
6) Return label + latency( prediction time)