How ayesha1209/predictionfailure works
Project Type & Purpose
• This is a full-stack, ML-powered web application (“Predictive Maintenance System”) built with Python and Flask.
• Purpose: Provide a real-time interface that takes machine parameters from a user, loads a pre-trained XGBoost model (pickled), predicts Time-To-Failure (TTF) for multiple components, and returns the results via a web UI or API.
File Structure Analysis
• Top-level files:
• app.py – Flask application entry point (controllers + routing)
• templates/index.html – Web UI
• test_data_xgb_enhanced.pkl, tttf_xgb_model_enhanced*.pkl – Serialized ML models/test data
• requirements.txt, runtime.txt, Procfile – Deployment configs (Heroku)
• No dedicated “model training” folder here; training pipeline lives elsewhere or upstream. This checkout focuses on serving/inference.
Key Architectural Components
a. Client (Browser or API Consumer)
b. Flask Web Server (app.py)
– Request handlers + business logic
– Loads/holds in memory the XGBoost model on startup
c. Model & Artifacts Store
– Local filesystem (pickle files)
– Could be abstracted to object storage (S3) or database in future
d. Preprocessor & Predictor
– Data validation & feature scaling/encoding (if included)
– Calls XGBoost model for multi-output regression
e. Presentation Layer
– Renders index.html template, form inputs, returns JSON or HTML
f. Deployment Environment
– WSGI server (Gunicorn recommended) behind a reverse proxy
– Heroku or Docker container (Procfile, runtime.txt, Dockerfile snippet)
Relationships & Data Flows
• Client submits input (form POST or JSON) →
Flask route “/predict” receives request →
Preprocessor normalizes & encodes inputs →
Predictor passes features to XGBoost model →
Model returns TTF predictions →
Flask formats response (JSON or HTML) →
Client displays results.
• On startup: Flask loads pickled model files into memory.
Architectural Patterns & Design Principles
• Monolithic ML inference service with clear separation:
• Presentation (templates)
• Controller (Flask routes)
• Model (pickle files & prediction logic)
• Future extensibility: swap filesystem storage for cloud storage, extract Preprocessor into its own service, scale with Gunicorn workers.
• Twelve-factor app principles: Procfile + requirements/runtime files for environment separation.
Technology Stack Highlights
• Python 3.x, Flask
• XGBoost via joblib/pickle files
• HTML/Jinja2 templates
• Deployment: Heroku (Procfile), optional Docker (Dockerfile)
• Dependencies managed via requirements.txt