-
-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #629 from shivansh-2003/main
[Feature Addition]: Web App for Vehicle Live Risk Prediction
- Loading branch information
Showing
15 changed files
with
785 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
noteId: "41f3da5024b711ef81150b8fd372c2c7" | ||
tags: [] | ||
|
||
--- | ||
|
||
# Live Vehicle Risk Prediction Dataset | ||
|
||
## Overview | ||
|
||
The Live Vehicle Risk Prediction Dataset is a comprehensive collection of data points aimed at predicting the risk associated with vehicles in various driving conditions. The dataset includes information on visibility, road surface conditions, weather, traffic density, road hazards, driver fatigue, medical conditions, speeding, and light conditions, among others. | ||
|
||
## Dataset Description | ||
|
||
The dataset contains the following features: | ||
|
||
- **Visibility**: Indicates the visibility level (e.g., Clear, Foggy, Rainy). | ||
- **Road_Surface_Conditions**: Describes the state of the road surface (e.g., Dry, Wet, Icy). | ||
- **Weather**: Weather conditions at the time of data collection (e.g., Sunny, Rainy, Snowy). | ||
- **Traffic_Density**: Density of traffic (e.g., Low, Medium, High). | ||
- **Road_Hazards**: Presence of any road hazards (e.g., None, Potholes, Debris). | ||
- **Fatigue_Level**: Driver's level of fatigue (e.g., Low, Medium, High). | ||
- **Medical_Condition**: Driver's medical condition (e.g., None, Mild, Severe). | ||
- **Speeding**: Indicates if the vehicle was speeding (e.g., Yes, No). | ||
- **Light_Conditions**: Lighting conditions during data collection (e.g., Daylight, Dusk, Night). | ||
|
||
Additional columns may include: | ||
- **Driver_Age**: Age of the driver. | ||
- **Last_Service_Months_Ago**: Time since the vehicle was last serviced in months. | ||
|
||
## Usage | ||
|
||
This dataset can be used for building predictive models to assess vehicle risk under various conditions. It is suitable for machine learning applications such as classification and regression tasks aimed at improving vehicle safety and reducing accidents. | ||
|
||
|
||
|
||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+971 KB
...ive Risk Prediction/Images/covid19-risk-assessment-automobile-manufacturers.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions
19
Vehicle Live Risk Prediction/Model/ML-Crate.code-workspace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"folders": [ | ||
{ | ||
"path": "../.." | ||
}, | ||
{ | ||
"path": "../.." | ||
}, | ||
{ | ||
"path": "../.." | ||
}, | ||
{ | ||
"path": "../.." | ||
}, | ||
{ | ||
"path": "../.." | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
--- | ||
noteId: "5336f36024b711ef81150b8fd372c2c7" | ||
tags: [] | ||
|
||
--- | ||
|
||
# Live Vehicle Risk Detection using XGBoost Model | ||
|
||
This project aims to predict vehicle risk scores using various environmental and driver-related factors. The model is trained using an XGBoost classifier and is capable of making real-time risk predictions based on the input data. | ||
|
||
## Table of Contents | ||
|
||
- [Project Description](#project-description) | ||
- [Dataset](#dataset) | ||
- [Usage](#usage) | ||
- [Model Training](#model-training) | ||
- [Evaluation](#evaluation) | ||
- [Saving the Model](#saving-the-model) | ||
|
||
## Project Description | ||
|
||
The Live Vehicle Risk Detection project utilizes machine learning to predict the risk associated with a vehicle's current conditions. The model considers factors such as visibility, road surface conditions, weather, traffic density, road hazards, driver fatigue level, medical conditions, speeding, and light conditions to determine a risk score. The XGBoost model categorizes the risk as high or low based on a threshold value. | ||
|
||
## Dataset | ||
|
||
https://www.kaggle.com/datasets/punyamodi/vehicle-live-risk-prediction | ||
|
||
|
||
|
||
## Usage | ||
|
||
To use the vehicle risk detection model, follow these steps: | ||
|
||
1. **Prepare the Dataset**: | ||
Ensure the dataset is named `Vehicle Risk Prediction Dataset.csv` and placed in the project directory. | ||
|
||
2. Make Predictions: | ||
Once the model is trained, you can use the saved model to make predictions on new data. Load the model, encoders, and scaler from the vehicle_risk_model.pkl file and use them to transform and predict new data inputs. | ||
|
||
## Model Training | ||
### The training process involves several steps: | ||
|
||
Load the Dataset: | ||
The dataset is loaded from a CSV file using pandas. | ||
|
||
Encode Categorical Features: | ||
Categorical features are encoded using LabelEncoder to convert them into numerical values that can be used by the model. | ||
|
||
Define Features and Target: | ||
The features (X) include various environmental and driver-related factors. The target (y) is a binary classification based on the risk score (1 if the risk score is above 50, otherwise 0). | ||
|
||
Split the Data: | ||
The dataset is split into training and testing sets using train_test_split. | ||
|
||
Standardize Features: | ||
Feature values are standardized using StandardScaler to have a mean of 0 and a standard deviation of 1. | ||
|
||
Train the Model: | ||
An XGBoost classifier is created and trained on the scaled training data. | ||
|
||
|
||
## Evaluation | ||
After training the model, its performance is evaluated on the test set: | ||
|
||
Make Predictions: | ||
The model makes predictions on the scaled test data. | ||
|
||
Calculate Accuracy: | ||
The accuracy of the model is computed to determine how well the model predicts the correct class. | ||
|
||
Classification Report: | ||
A detailed classification report is generated, which includes precision, recall, and F1 scores for both classes (high risk and low risk). | ||
|
||
## Saving the Model | ||
After training and evaluating the model, the following components are saved to a single file named vehicle_risk_model.pkl using joblib: | ||
|
||
## Model used in this Project | ||
1) Decision Tree | ||
2) Random Forest | ||
3) ANN | ||
4) Multivariate Logisitic Regression | ||
5) Lasso | ||
6) Gradient Boost | ||
7) Ridge | ||
8) MLP | ||
9) XGBoost | ||
|
||
### Models and Accuracies | ||
|
||
| Model | Accuracy | MSE SCORE | | ||
| ----------------------------- |:----------:| ------------------:| | ||
| Decision Tree | 0.9996 | | | ||
| Random Forest | 1.0 | | | ||
| ANN | 1.0 | | | ||
| Logistic Regression | 1.0 | | | ||
| Lasso | N.A | 0.03247239784420999| | ||
| Gradient Boost | 1.0 | | | ||
| Ridge | N.A | 0.007214250517408194| | ||
| MLP | 0.9997 | | | ||
| XGBoost | 1.0 | | |
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
|
||
## [Feature Addition]: Web App for Vehicle Live Risk Prediction #602 | ||
 | ||
|
||
### Overview | ||
The Vehicle Risk Prediction application is designed to predict the risk associated with driving a vehicle based on various factors such as weather conditions, road hazards, visibility, traffic density, and driver-related factors like fatigue level, speeding, and medical conditions. The application utilizes a machine learning model trained on historical data to provide risk predictions. | ||
|
||
|
||
### Goal 🎯 | ||
'The aim is to create a web app for the Vehicle Live Risk Prediction project. Use the best existing model in the project folder. Follow the Web App README template for the same.' | ||
|
||
|
||
### Functionality | ||
#### Main Model Page: | ||
- **Input Fields:** Users can enter details such as Visibility, Road Surface Conditions, Weather, Traffic Density, Road Hazards, Fatigue Level, Medical Condition, Speeding, and Light Condition. | ||
- **Prediction:** After entering the required information and clicking on the "Predict Risk" button, the application calculates the risk level (High Risk or Low Risk) based on the user's input. | ||
|
||
#### Visualization Page: | ||
- **Data Overview:** Displays the first few rows of the dataset and provides an overview of the data. | ||
- **Data Statistics:** Shows summary statistics of numerical columns in the dataset. | ||
- **Correlation Heatmap:** Visualizes the correlation between numerical features using a heatmap. | ||
- **Countplots of Categorical Features:** Displays count plots for each categorical feature in the dataset. | ||
|
||
|
||
#### About Page: | ||
- **Model Explanation (XGBoost):** Provides an explanation of the machine learning model used in the application, focusing on the XGBoost (Extreme Gradient Boosting) algorithm. | ||
- **Purpose:** Explains the purpose and goal of the Vehicle Risk Prediction application. | ||
|
||
## Technology Stack | ||
The Vehicle Risk Prediction application is built using the following technologies: | ||
- **Streamlit:** Used for building the user interface and web application. | ||
- **Pandas:** Used for data manipulation and handling input data. | ||
- **Joblib:** Used for loading the machine learning model, encoders, and scaler. | ||
- **XGBoost:** Machine learning algorithm used for risk prediction. | ||
|
||
## How to Use | ||
1. **Navigation:** Use the sidebar to navigate between the Main Model Page, Visualization Page, and About Page. | ||
2. **Main Model Page:** | ||
- Fill in all required fields with relevant information. | ||
- Click on the "Predict Risk" button to see the risk prediction. | ||
3. **Visualization Page:** | ||
- Explore data overview, statistics, correlations, countplots, and pairplots to gain insights into the dataset. | ||
4. **About Page:** | ||
- Provides information about the model explanation and purpose of the application. | ||
|
||
### Video Demonstration 🎥 | ||
[Watch the video](https://vimeo.com/953208773?share=copy) | ||
|
||
|
||
|
||
https://github.com/shivansh-2003/ML-Crate/assets/144326194/d8b87a5f-0f80-477f-877c-0d60df781289 | ||
|
||
### Signature ✒️ | ||
|
||
Name:-Shivansh Mahajan | ||
|
||
Github:-https://github.com/shivansh-2003 | ||
|
||
Linkedin:-https://www.linkedin.com/in/shivansh-mahajan-13227824a/ |
Binary file added
BIN
+9.75 MB
Vehicle Live Risk Prediction/Web App/Screen_Recording_2024-06-02_at_10.54.49 PM.mp4
Binary file not shown.
Oops, something went wrong.