A weather forecasting application that provides real-time weather updates and predictive analytics for cities worldwide using the OpenWeatherMap API and TensorFlow for temperature predictions.
- Project Overview
- Features
- Data Processing & Model Training
- Application Architecture
- Flask Integration & Deployment
- API Usage & Key Management
- Usage Instructions
- Setup Guide
- Technologies Used
- Future Improvements
Weather.IO is a state-of-the-art weather forecasting application that delivers real-time weather updates for any city worldwide. It offers features such as temperature, humidity, wind speed, and pressure updates, along with predictive analytics for up to five days. The system leverages the OpenWeatherMap API for live data and uses machine learning (LSTM) for temperature predictions. Additionally, the app includes interactive visualizations and geolocation-based weather fetching for a seamless user experience.
- Real-time Weather Data: Provides live weather updates, including temperature, humidity, wind speed, and pressure.
- 7-Day Weather Forecast: Detailed weather forecasts for the next 7 days.
- Temperature Predictions: Predicts temperature trends up to 5 days ahead using a machine learning model (LSTM).
- Geolocation Detection: Automatically detects the user's location and shows the relevant weather.
- User Preferences: Allows users to save favorite cities for quick access.
- Interactive Visualizations: Displays graphs for temperature trends using libraries like Matplotlib or Plotly.
Weather data is collected using the OpenWeatherMap API, which provides real-time updates and historical weather data used for training the predictive models.
- The model is an LSTM (Long Short-Term Memory) neural network built with TensorFlow and Keras to forecast temperature trends based on historical weather data.
- Historical weather data is processed and fed into the LSTM model, which predicts temperature changes for up to 5 days ahead.
The trained LSTM model is stored as a TensorFlow SavedModel for easy deployment and real-time inference.
The app is built with a microservices architecture:
- Frontend: Built using HTML5, CSS3, and Bootstrap 5 for a responsive and clean user interface.
- Backend: The Flask server handles API requests, manages user sessions, and serves the machine learning model for temperature predictions.
- Machine Learning Service: The machine learning model is hosted as a separate service, which handles predictions.
- API Integration: Fetches live weather data from the OpenWeatherMap API and uses TensorFlow for predictive analytics.
The Flask web app serves the real-time weather data, processes user requests, and handles machine learning predictions. The two main routes are:
/
: Displays the weather details of the user's current or searched city./predict
: Provides a temperature prediction for the next 5 days using the LSTM model.
The app is deployed on Render, where Flask handles user interaction, API integration, and prediction services.
The OpenWeatherMap API is used to fetch live weather data, and keys are managed through the .env
file. The app reads the API key from the environment, and you can get your own API key from OpenWeatherMap.
- Create a
.env
file in the root directory. - Add your OpenWeatherMap API key:
API_KEY=your_openweathermap_api_key
-
Homepage:
- Shows the weather details based on your current geolocation.
- You can also search for a city's weather information manually.
-
Temperature Prediction:
- Provides predictive temperature graphs using the LSTM model for up to 5 days in advance.
-
Favorites:
- Save your favorite cities for quick access to their weather data.
- Python 3.7+
- Flask
- TensorFlow, Keras
- Pandas, NumPy
- OpenWeatherMap API Key
-
Clone the repository:
git clone https://github.com/yourusername/weather-forecasting-app.git cd weather-forecasting-app
-
Create a virtual environment and activate it:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the required dependencies:
pip install -r requirements.txt
-
Set up the
.env
file with your OpenWeatherMap API key. -
Run the Flask app:
python app.py
-
Visit the app at
http://127.0.0.1:5000
in your browser.
- Frontend: HTML5, CSS3, Bootstrap 5
- Backend: Flask
- Machine Learning: TensorFlow, Keras
- Data Handling: Pandas, NumPy
- API: OpenWeatherMap API
- Visualization: Matplotlib, Plotly
- Environment Management: Python Dotenv for environment variables
- Enhanced Prediction Model: Incorporating other weather features like humidity and wind speed into the machine learning model for more accurate predictions.
- User Authentication: Implement OAuth2 for secure user authentication and personalized settings.
- Mobile Responsiveness: Further UI optimizations for mobile and tablet devices.
- Weather Alerts: Add push notifications for severe weather conditions based on user preferences.