An advanced machine learning API that predicts whether a stolen bicycle is likely to be recovered or remain stolen, based on historical bicycle theft data. View visualizations and predictions on the frontend against data. Enter your own bike data to see predictions.
- Theft Prediction: Get probability scores for bicycle recovery using machine learning
- Location Services: Convert latitude/longitude to neighborhood information
- Field Options: Access all valid options for bike makes, models, colors, and more
- Data Preprocessing: Automatic handling of data formatting and encoding
Make predictions about bicycle theft outcomes:
POST /predictRequired fields:
BIKE_TYPE: Type of bicycle (REGULAR, MOUNTAIN, or RACING)PREMISES_TYPE: Type of premises where incident occurredLOCATION_TYPE: Type of locationOCC_DATE: Date of occurrence (YYYY-MM-DD)OCC_DOW: Day of weekOCC_HOUR: Hour of occurrence (0-23)OCC_DOY: Day of year (1-366)REPORT_DATE: Date reported (YYYY-MM-DD)HOOD_140: Neighborhood codeNEIGHBOURHOOD_140: Neighborhood name
Optional fields:
BIKE_MAKE: Make of the bicycleBIKE_MODEL: Model of the bicycleBIKE_SPEED: Number of speedsBIKE_COLOUR: Color of the bicycleBIKE_COST: Cost of the bicycle
Get neighborhood information from coordinates:
POST /neighbourhoodRequired fields:
latitude: Latitude of the locationlongitude: Longitude of the location
Get all valid options for input fields:
GET /options##Webpage Endpoints
- Clone the repository:
git clone git@github.com:hodanysf/Group5-Project2.git
###Frontend
-
cd Frontend
-
npm install
-
npm start
-
Open http://localhost:3000 in your browser
###Backend
-
cd BicycleTheftPrediction
-
Create a virtual environment (recommended):
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Python >= 3.8
- Dependencies:
- numpy >= 1.21.0
- pandas >= 1.3.0
- scikit-learn >= 0.24.2
- xgboost >= 1.4.2
- imbalanced-learn >= 0.8.1
- matplotlib >= 3.4.3
- seaborn >= 0.11.2
- flask >= 2.0.1
- flask-restx >= 1.1.0
- joblib >= 1.0.1
- requests >= 2.26.0
- Start the API server:
cd api/
python -m flask --app app.py run- Access the API documentation:
http://localhost:5000/docs
- Make a prediction:
import requests
data = {
"BIKE_TYPE": "REGULAR",
"PREMISES_TYPE": "House",
"LOCATION_TYPE": "Single Home",
"OCC_DATE": "2023-01-01",
"OCC_DOW": "Sunday",
"OCC_HOUR": 14,
"OCC_DOY": 1,
"REPORT_DATE": "2023-01-02",
"HOOD_140": "080",
"NEIGHBOURHOOD_140": "Palmerston-Little Italy (80)"
}
response = requests.post("http://localhost:5000/predict", json=data)
print(response.json())- Hodan Ahmed Yusuf
- Dimitrios Avgerakis
- Chris Busse
- Gabriel Normand
- Nabanita Saha
ReadME based on original by Mindful-Developer