How aliprf/california_housing_explainable_prediction works
Main Components
a. CLI / Orchestration Layer
• Pixi runner (pixi run train, pixi run explain, pixi run up)
• Entrypoints: main.py, ml/main.py
b. Data & Model Pipeline
• Data Loader & Preprocessor (ml/data_parser/data_parser.py)
• Model Trainer & Predictor (ml/model/random_forest_prediction.py)
• Model Explainer (ml/model/random_forest_explainer.py)
• Schema Definitions (ml/common/schemas/*.py)
• Artifact Storage (trained model weights, evaluation data under weights/)
c. Server
• API & Routing (server/server.py)
• Configuration Loader (config.py)
d. Client (Web UI)
• Gradio (or similar) frontend (client/client.py)
e. External Users/Systems
• End users interacting via browser
• SHAP visualizations or downloaded reports
Relationships & Data Flows
• Training Flow (triggered via CLI):
[CLI] → loads ml/data_parser → passes processed data to random_forest_prediction → saves model & metrics.
• Explainer Flow (CLI):
[CLI] → loads saved model + test data → runs random_forest_explainer (SHAP) → outputs plots & feature‐importance.
• Serving Flow (run up):
[Server] ← configured by config.py
[Server] ↔ loads trained model artifacts
[Client/UI] ↔ [Server] via HTTP (Predictions & Explain requests)
[Server] → invokes ML modules (prediction or explainer) → returns JSON/HTML/images → [Client/UI] renders them
Architectural Patterns & Technologies
• Modular ML Pipeline: separation of data parsing, model training, and explainability.
• CLI‐driven orchestration: Pixi for environment & commands.
• Micro‐service‐like separation of server & client.
• Use of SHAP for interpretability.
• Python modules as “services” (e.g., ml/data_parser, ml/model).