Crash Detection Model

This model predicts whether a crash is likely based on sensor data (accelerometer and gyroscope values).

Input Features:

  • accel_x: Accelerometer data on the x-axis.
  • accel_y: Accelerometer data on the y-axis.
  • accel_z: Accelerometer data on the z-axis.
  • gyro_x: Gyroscope data on the x-axis.
  • gyro_y: Gyroscope data on the y-axis.
  • gyro_z: Gyroscope data on the z-axis.
  • timestamp: Unix timestamp of the data.

Output:

  • crash_prediction: 1 if a crash is predicted, 0 otherwise.

Example Request:

To send a POST request to the /predict endpoint with the sensor data, the JSON body should be formatted like this:

{
    "accel_x": -1.5,
    "accel_y": 8.2,
    "accel_z": 0.3,
    "gyro_x": 0.15,
    "gyro_y": -0.25,
    "gyro_z": 0.13,
    "timestamp": 1625432933
}

Example Response:

The response will contain a JSON object with the crash prediction:

{
    "crash_prediction": 1
}
  • crash_prediction: 1 indicates a crash is predicted, and 0 indicates no crash.

How to Use:

  1. Send a POST request with the JSON data above to the /predict endpoint.
  2. Receive a response with the predicted crash status (either 1 for a crash or 0 for no crash).

Model Details:

The model was trained using accelerometer and gyroscope data. It was built with a Random Forest classifier, a reliable model for this type of prediction task. The input features are preprocessed using a StandardScaler to normalize the data.

The model is packaged in a Flask API for easy deployment and integration.

Requirements:

  • Python 3.6+
  • Flask
  • scikit-learn
  • pandas
  • joblib

To install the necessary dependencies, run:

pip install -r requirements.txt

Example Usage:

  1. Clone the repository and install the dependencies as shown above.
  2. Run the Flask app locally by executing:
python app.py

By default, it runs on http://127.0.0.1:5000/. 3. Send a POST request to http://127.0.0.1:5000/predict with the sensor data to get the crash prediction.


Troubleshooting:

  • If you encounter issues with dependencies, make sure to use a virtual environment.
  • For deployment, ensure your model files (crash_detection_model.pkl and scaler.pkl) are properly included.


This README provides detailed information for using the model API, including how to structure your data for prediction requests and the expected output. It also includes basic setup instructions, dependencies, and usage steps.
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support