How swaraj-6/credit_card_default_prediction works
Project Type and Purpose
• This is a full-stack machine-learning web application for predicting credit-card defaults.
• Frontend: simple Flask HTML forms (templates/form.html, templates/result.html).
• Backend: Flask app (application.py) invoking a prediction pipeline (src/pipeline/prediction_pipeline.py).
• ML components: data-ingestion, transformation, model training modules under src/components, producing artifacts (model.pkl, preprocessor.pkl).
• Deployment: configured for AWS Elastic Beanstalk (.ebextensions) and currently hosted on Render.
Main Components
a. User Interface (Frontend)
• Browser → HTML form (form.html)
• Result page (result.html)
b. Flask Application (Backend Controller)
• application.py: routes “/” for form, “/predict” for submissions
• src/logger.py & src/exception.py for logging and error handling
c. Prediction Pipeline
• src/pipeline/prediction_pipeline.py loads artifacts, applies preprocessing, returns prediction
• src/utils.py supports loading and I/O
d. Training Pipeline (Offline/Batch)
• src/pipeline/training_pipeline.py orchestrates:
• data_ingestion.py → loads UCI dataset
• data_transformation.py → handles encoding, scaling
• model_training.py → trains model, persists model.pkl & preprocessor.pkl
e. Artifacts Store
• artifacts/: raw.csv, train.csv, test.csv, preprocessor.pkl, model.pkl
f. Configuration & Deployment
• requirements.txt, setup.py
• .ebextensions/python.config for AWS EB
Relationships and Data Flow
• User submits form → Flask route calls Prediction Pipeline → Pipeline fetches preprocessor & model from artifacts → returns default/no-default → Flask renders result page.
• Training is invoked separately (CLI or scheduled job): raw.csv → data_ingestion → data_transformation → model_training → write updated artifacts.
• Logging & exception modules wrap all interactions.
Architectural Patterns & Principles
• Layered separation:
• Presentation (templates + Flask routes)
• Application (prediction_pipeline & training_pipeline orchestrators)
• Domain/Components (data_ingestion, transformation, model_training)
• Infrastructure (artifact persistence, configuration)
• Single-responsibility modules (each component handles only one pipeline stage).
• Reusability: utils.py for shared I/O, logger/exception for cross-cutting concerns.