US Visa Approval Prediction
End-to-End MLOps Project
Machine Learning • MLOps

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.

Primary Goal
Supervised Classification Model
Approved Denied
Production Model Store
AWS S3 (model + metrics)
Baseline comparison F1-driven governance
Serving Layer
FastAPI UI + prediction endpoint
Low-latency inference No retrain on predict

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_idcategoricalUnique applicant identifier
continentcategoricalApplicant continent
education_of_employeecategoricalHighest education level
has_job_experiencecategoricalJob experience flag (Y/N)
requires_job_trainingcategoricalTraining required (Y/N)
region_of_employmentcategoricalUS region of employment
unit_of_wagecategoricalWage unit (Hour/Week/Month/Year)
full_time_positioncategoricalEmployment type (Y/N)
no_of_employeesnumericalCompany size
yr_of_estabnumericalCompany establishment year
prevailing_wagenumericalSalary / wage
company_agenumericalDerived: current_year − yr_of_estab
case_statustargetApproved / Denied

Data Storage & Ingestion

MongoDB • PyMongo • Pandas

Data 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 Readiness

The 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 • Reproducibility

The platform follows a staged pipeline design where each component produces versioned artifacts. This supports reproducibility, traceability, and controlled model promotion based on objective metrics.

1

Data Ingestion

Load from MongoDB → snapshot us_visa.csv → split into train.csv/test.csv.

2

Data Validation

Schema checks + drift reporting to detect distribution shifts that can degrade model performance using Evidently.

3

Data Transformation

Feature engineering, encoding, scaling, target mapping, and SMOTEENN imbalance handling. Preprocessing object saved to the artifact folder.

4

Model Training

Train multiple models using neuro_mf + GridSearchCV for hyperparameter tuning. Best model saved to artifact folder.

5

Model Evaluation

Compare trained model vs production baseline using F1-score; accept only if it improves.

6

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 Report

The 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 Selection

The 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 Comparison

Each 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 Latency

The 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)