How aronagent/vehicles_severity_ml_model works
Project Type and Purpose
• This is a full-stack web application built with Django that integrates a Machine Learning (ML) model to predict vehicle accident severity.
• It accepts user inputs, processes them through an ML model (loaded via joblib), and returns a prediction. It also exposes a REST API endpoint for programmatic access.
File Structure
• The primary Django project directory (VehicleSeverity) contains all Django configuration files (settings.py, urls.py, asgi.py, wsgi.py) and the core app files (views.py, __init__.py).
• There is a joblib file (accident_ready.joblib) which represents the saved ML model.
• A SQLite database (db.sqlite3) is used by Django as the data storage.
• The project includes templates (index.html, modelresponse.html) for the front-end and static assets (style.css) for styling.
• The Django management script (manage.py) is present to run the server and handle migrations.
README for Additional Insights
• The README outlines the core functionalities: user input, ML-based prediction, and REST API support.
• It lists the factors input into the model and the expected prediction output (Minor, Major, or Fatal).
• Instructions to set up the virtual environment, install dependencies, and run the application are provided.
• The provided API section indicates the existence of an endpoint (/predict/) that accepts JSON payload via POST.
a. Main Components:
• Web Server / Django Application: This includes the core Django components (views, URL configs, settings).
• ML Prediction Engine: Represented by the accident_ready.joblib file, used within Django views to make predictions.
• Database: SQLite (db.sqlite3) for persisting data.
• Frontend Components: Templates (index.html, modelresponse.html) and static assets (CSS) for the UI.
• RESTful API Layer: An endpoint (likely mapped in urls.py) that accepts prediction requests.
b. Relationships and Interactions:
• The Client (web browser or API consumer) sends HTTP requests to the Django server.
• Django’s URL routing maps requests to specific view functions.
• View functions process inputs, invoke the ML prediction model, and route the results back to the client (either by rendering an HTML template or returning a JSON response).
• The static files and templates serve as presentation layers.
• The database may be used to store logs, user sessions, or any persistent data as required.
c. Architectural Patterns / Design Principles:
• Separation of Concerns: Clearly defined roles for presentation (templates and static files), business logic (views handling user input and predictions), and data storage (SQLite).
• Integration of ML components into web routes: The use of joblib for model persistence and integration into a web request-response cycle.
d. Relevant Technologies and Frameworks:
• Django Framework (for the web application and API endpoints).
• joblib (for loading the pre-trained ML model).
• SQLite (as the database).
• HTML/CSS for UI components.
• REST API concepts using Django routes.