How emmaarenas/tfm_fraudeseguros works
Project type and purpose
• This is an end-to-end machine-learning web application built with Python and Streamlit.
• Purpose: ingest raw insurance‐claims data, preprocess it, train multiple models (logistic regression, random forest, XGBoost, LightGBM), ensemble them, and expose an interactive UI for inference.
File structure
• Top-level directories:
• Artifacts – serialized model files (.pkl) and metadata (feature columns, I/O schema, ensemble config)
• Data – raw and processed CSV datasets
• Docs – EDA, preprocessing, modeling reports (PDFs)
• Notebooks – Jupyter workflows for each pipeline stage
• Service – the production code: Streamlit UI (app.py), backend API (api_backend.py), config
• Other files: requirements.txt, LICENSE, .gitignore
README
• The README link points to the deployed Streamlit app (carclaim.streamlit.app)
• Confirms the app’s public URL and high-level UI purpose
Main components and their roles
a. Data Layer
• Raw data (Data/data_raw.csv)
• Processed data (Data/data_processed.csv)
b. Feature Engineering & Training
• Jupyter notebooks for EDA, preprocessing, modeling
• Outputs: feature_cols.pkl, explainer.pkl, model_*.pkl, ensemble_config.json
c. Artifact Store
• Central folder (Artifacts/) that holds all pickled artifacts and schema definitions
d. Backend Service
• api_backend.py: loads artifacts and exposes inference functions
• historial.json: persisted request/response log
e. Frontend UI
• app.py: Streamlit application code using Service/.streamlit/config.toml
• Assets/: static assets (images, CSS, JS if any)
f. External Libraries & Infra
• Python, Streamlit, scikit-learn, XGBoost, LightGBM, pandas, numpy
Relationships & data flow
1. Data Ingestion → preprocessing (notebook) → processed data
2. Processed data → model training (notebook) → serialized artifacts
3. Artifacts → loaded by api_backend.py at startup
4. Streamlit UI (app.py) ←→ Backend (in-process function calls)
5. User inputs on UI → backend inference → ensemble predictions → UI output
6. Requests logged to historial.json
Architectural patterns & design principles
• Separation of concerns: distinct layers for data, training, storage, backend, UI
• Artifact versioning: models and schemas in a single folder
• Configuration as code: streamlit config, ensemble config JSON
• Reproducibility: notebooks + serialized artifacts