How vik1292/auto-loan-project works
Project Type & Purpose
• This is a standalone, command-line driven machine-learning pipeline for auto-loan default risk prediction.
• Key capabilities: data generation/ingestion, preprocessing & feature engineering, model training & selection, model explainability (SHAP), and automated risk-assessment reporting.
File Structure (High-Level Components)
• main.py / run_demo.py: CLI entry points driving the pipeline modes (full, train, report).
• src/: Core modules, each implementing a pipeline stage:
• data_generator.py (synthetic data ingestion)
• data_preprocessing.py (cleaning + feature engineering)
• model_training.py (train & evaluate LogisticRegression, RF, XGBoost + select best)
• model_explainability.py (SHAP analysis)
• risk_assessment_report.py (risk categorization, summary + detailed reports)
• data/: Raw and processed datasets.
• models/: Serialized trained model artifacts (best_model.pkl).
• output/ (described in README): Generated reports, plots, JSON for dashboards.
• logs/: Application log files.
• requirements.txt / setup.py: Environment & deployment config.
Main Components & Their Interactions
a. Data Ingestion
• Synthetic generation (data_generator.py) or user-supplied CSV (--data-file).
• Output: raw data → data/raw storage.
b. Data Preprocessing & Feature Engineering
• Reads raw data → cleans, engineers features (DTI, payment ratios).
• Outputs processed dataset → data/processed storage.
c. Model Training & Selection
• Trains multiple models, evaluates metrics (ROC, AUC).
• Selects best model → serializes to models/best_model.pkl.
d. Model Explainability
• Loads best_model → computes SHAP values → generates feature importance, waterfall plots.
• Outputs visuals & JSON summaries.
e. Risk Assessment & Reporting
• Applies best_model on processed data → computes risk scores.
• Categorizes risk levels (High, Medium, Low).
• Produces: executive summary (.txt), detailed customer reports, dashboard_data.json.
f. Logging & Monitoring
• All stages emit logs to logs/ for debugging & audit.
g. CLI Interface
• main.py orchestrates modes (full, train, report), wiring all components in sequence.
Architectural Patterns & Design Principles
• Pipeline / ETL pattern: sequential stages with clear inputs/outputs.
• Modular separation: each src/ module encapsulates one concern.
• Artifact management: models/ for model binaries; data/ for datasets; output/ for results.
Technologies & Frameworks
• Python 3.7+
• pandas, numpy for data handling
• scikit-learn, xgboost for modeling
• shap for explainability
• matplotlib, seaborn for plots
• joblib for serialization