Welcome to the Energy Consumption Prediction API, an open-source project designed to predict energy consumption based on a given date. This project uses a pre-trained XGBoost model and provides a simple HTTP API for making predictions.
- Overview
- Directory Structure
- Installation
- Usage
- API Endpoints
- Testing
- Improvements
- Contributing
- License
This project provides an API for predicting energy consumption using a pre-trained XGBoost model. The API accepts a date in the format YYYY-MM-DDTHH:MM:SS and returns a prediction of energy consumption for that date and time.
energy-consumption-prediction-api/
├── app.py
├── data_ingestion.py
├── models/
│ └── xgboost_energy_model.pkl
├── tests/
│ └── test_app.py
├── utils.py
├── improvements/
│ └── README.md
├── requirements.txt
├── README.md
└── CONTRIBUTING.md
- Python 3.9 or higher
- Flask
- Pandas
- XGBoost
- Flask-Marshmallow
-
Clone the repository:
git clone https://github.com/your-username/energy-consumption-prediction-api.git cd energy-consumption-prediction-api -
Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the required packages:
pip install -r requirements.txt
-
Run Tests:
pytest
-
Run the Flask application:
python src/app.py
To use the API, send a GET request to the /predict endpoint with a date parameter in the correct format.
Example:
curl "http://127.0.0.1:5000/predict?date=2024-05-31T12:00:00"