Skip to content

OpenInitia/AI-Powered-Weather-Predictor

Repository files navigation

AI-Powered-Weather-Predictor

A LSTM model based AI-Powered Weather Predictor

Maintainer - @Deadpool2000

GitHub language GitHub Repo stars GitHub issues GitHub contributors GitHub pull requests GitHub license

This project is an AI-powered weather prediction system that fetches real-time weather data using the OpenWeatherMap API and predicts future temperatures using an LSTM (Long Short-Term Memory) neural network.

🚀 Features

  • Fetches real-time weather data from OpenWeatherMap API 🌍
  • Trains an LSTM-based deep learning model for temperature prediction 🔥
  • Provides weather predictions via a Flask API 🖥️
  • Stores trained models for faster inference ⚡
  • Fully modular directory structure 🏗️

📁 Project Directory Structure

AI-Powered-Weather-Predictor/
│── lib/                         # External helper functions
│   ├── openweather.py            # Fetch weather data from OpenWeatherMap API
│
│── src/                         # Core logic of the project
│   ├── model.py                  # LSTM model training and prediction
│   ├── preprocess.py             # Data preprocessing
│
│── templates/                    # HTML templates (for Flask UI)
│   ├── index.html                 # Frontend UI (Optional)
│
│── static/                        # Static files (CSS, JS, Images)
│
│── main.py                        # Flask app (Runs API & triggers training)
│── requirements.txt                # Python dependencies
│── README.md                       # Project documentation

🔧 Installation & Setup

1️⃣ Clone the Repository

git clone https://github.com/OpenInitia/AI-Powered-Weather-Predictor
cd AI-Powered-Weather-Predictor

2️⃣ Set Up a Virtual Environment

# For Windows
python -m venv venv
venv\Scripts\activate

# For Mac/Linux
python3 -m venv venv
source venv/bin/activate

3️⃣ Install Dependencies

pip install -r requirements.txt

4️⃣ Set Up OpenWeatherMap API Key

  1. Get your API key from OpenWeatherMap
  2. Create a .env file in the root directory:
    OPENWEATHER_API_KEY=your_api_key_here

🎯 Running the Project

1️⃣ Run the Flask Server

python main.py
  • This will: ✅ Fetch the latest weather data
    Train the model (if not already trained)
    Start the Flask server at http://127.0.0.1:5000/

2️⃣ Predict Weather via API

Send a POST request with JSON data:

curl -X POST http://127.0.0.1:5000/predict      -H "Content-Type: application/json"      -d '{"temperature": 30, "humidity": 70, "pressure": 1013}'

Response Example:

{
  "predicted_temperature": 31.2
}

📌 API Endpoints

Endpoint Method Description
/ GET Returns the homepage (Optional UI)
/predict POST Predicts the future temperature based on inputs

🛠️ Technologies Used

  • Flask - Web framework for API development
  • TensorFlow/Keras - LSTM-based machine learning model
  • Scikit-learn - Data preprocessing
  • NumPy & Pandas - Data handling
  • Requests - Fetching weather data from OpenWeatherMap

🌟 Future Improvements

  • ✅ Add support for predicting rainfall & wind speed 🌧️
  • ✅ Deploy on a cloud platform like AWS / Heroku ☁️
  • ✅ Improve UI with charts 📊

🤝 Contributing

Feel free to fork this project and submit a pull request!
If you find any bugs, open an issue. 🚀