Api Rest developed in flask
to make predictions based on a Machine Learning model.
scikit-learn
- Main library for predictive model creation and training, including data preprocessing and performance evaluation.pandas
- Used for data manipulation and analysis, facilitating the processing of input and output data of the model.flask
- Development of the project API, allowing communication between the prediction model and users.joblib
- Save and load the Machine Learning model efficiently, ensuring fast inference.flask-cors
- API CORS configuration.Python
- Language used for developer.
This Machine Learning model was developed to predict the number of vehicles in different contexts, based on the available data. The API allows you to send new information and receive accurate forecasts that can be applied to improve traffic, logistics and infrastructure planning and management. Below are some of the insights this model offers:
-
Vehicle Volume Forecast: With the data provided, the model estimates the number of vehicles for a given scenario, providing a useful reference base for traffic analysis.
-
Pattern Identification: The model captures trends and seasonality in the flow of vehicles, which is useful for identifying times and periods of greater and lesser movement.
-
Impact of Specific Variables: When using a Random Forest model, it is possible to determine which variables have the greatest influence on the number of vehicles, such as days of the week, weather conditions or special events.
-
Model Accuracy Assessment: Metrics such as Mean Squared Error (MSE) and R2 Score are calculated to understand the accuracy of predictions:
- The MSE quantifies the mean squared difference between the predicted and actual values, providing a measure of the mean forecast error.
- The R2 Score indicates the proportion of variation in the data explained by the model, helping to assess how well it represents reality.
These results can be applied to improve decision-making in traffic management, urban planning and logistics optimization, providing practical forecasts that support informed decisions.
- Clone the Repository:
git clone https://github.com/felipeclarindo/vehicle-predict-api.git
- Enter directory:
cd vehicle-predict-api
- Create
Virtual Environment
:
python -m venv .venv
-
Enable
Virtual Environment
by running the.bat
file in.venv/Scripts/activate.bat
. -
Install dependencies :
pip install - r ./requirements.txt
-
Run the jupyter cell phone from the file model_training.ipynb.
-
Run the api:
python ./src/api/api.py
- After run access api in:
http://localhost:3000/api
Contributions are welcome! If you have suggestions for improvements, feel free to open an issue or submit a pull request.
Felipe Clarindo
This project is licensed under the GNU Affero License.