A data-driven, machine learning-powered application that predicts whether it's good to stay in a city based on real-time weather and air quality index (AQI) data fetched from OpenWeatherMap APIs. It also provides a 5-day weather forecast with a visualization, combining environmental science with practical AI insights.
- 🔍 Real-Time Data: Fetches live weather and AQI data from OpenWeatherMap API.
- 🧠 Machine Learning Prediction: Predicts if the current conditions are suitable to live using a trained Random Forest model.
- 📈 5-Day Forecast Visualization: Beautiful temperature trendline using Seaborn and Matplotlib.
- 🛠️ Custom Trained Classifier: Uses synthetic data to train a model that evaluates temperature, humidity, wind speed, and AQI levels.
- 🌐 Interactive CLI Input: Asks users to input any city and country code.
| Component | Tech Stack |
|---|---|
| Language | Python 3.x |
| Data Source | OpenWeatherMap API (Weather + Air Pollution) |
| Machine Learning | Scikit-learn (Random Forest Classifier) |
| Data Viz | Matplotlib, Seaborn |
| Scaling | StandardScaler from Scikit-learn |
-
Clone the repository:
git clone https://github.com/PULKESH01/smart-city-suitability-predictor.git cd smart-city-suitability-predictor -
Install dependencies (or use Colab):
pip install -r requirements.txt
-
Add your OpenWeatherMap API key:
API_KEY = "5acc79a4dd0593bf86e79fe226f2db09"
-
Run the script:
python main.py
- User Input: User enters the city and country code.
- API Fetching: Weather and AQI data are pulled using latitude & longitude.
- Model Evaluation:
- Temperature, Humidity, Wind Speed, and AQI are input into a classifier.
- A Random Forest Classifier (trained on 200 synthetic environmental samples) determines whether conditions are suitable to stay.
- Forecast Plot: The script pulls and displays the 5-day temperature forecast using line charts.
Enter city name: Delhi
Enter country code (e.g., IN): IN
📍 City: Delhi, IN
🌡️ Temperature: 33.1°C
💧 Humidity: 30%
🍃 Wind Speed: 2.5 m/s
💨 AQI Level: 4 (1=Good, 5=Very Poor)
🏠 Stay Suitability: ⚠️ Not ideal to stay
Followed by a 5-day temperature line chart.
You need a free API key from OpenWeatherMap. Enable:
- Geocoding API
- Current Weather Data API
- Air Pollution API
- 5-Day / 3-Hour Forecast API
- ✅ Add support for storing historic city performance
- 📈 Track AQI trends across weeks/months
- 🌱 Recommend health precautions based on air quality
- ☁️ Deploy as a web dashboard using Streamlit or Flask
This project is licensed under the MIT License.