This project demonstrates two machine learning tasks using real-time weather data fetched from an API:
We use the OpenWeatherMap API to fetch current weather data (e.g., temperature, humidity, pressure) for a specific location. The data is then used in two separate machine learning tasks:
We used the OpenWeatherMap API in a script to:
- Call the weather API using a personal API key.
- Fetch current weather data for a specific city (e.g., London).
- Extract features like:
temperaturehumiditypressureweather condition(as a label)
- Save the collected data to a local CSV file (
weather_data.csv) for further use.
💡 API used:
api.openweathermap.org/data/2.5/weather?q=CityName&appid=YOUR_API_KEY
- Objective: Predict temperature using other weather features.
- Features: Humidity, Pressure
- Target: Temperature
- Model Used:
LinearRegression - Notebook:
01_Temperature_Regression.ipynb
- Objective: Classify the type of weather (e.g., Clear, Rainy, Cloudy) using numerical weather features.
- Data Reuse: We reuse the same
weather_data.csvgenerated in the regression task. - Preprocessing:
- Encode weather conditions (e.g.,
Rain,Clear) into numeric labels. - Scale the features using
StandardScaler.
- Encode weather conditions (e.g.,
- Model Used:
RandomForestClassifier(with baseline comparison toLogisticRegression) - Notebook:
02_Condition_Classification.ipynb
| File | Description |
|---|---|
models/temperature_model.pkl |
Trained Linear Regression model |
models/condition_classifier.pkl |
Trained Logistic Regression/Random Forest Classifier |
data/ |
Original |
notebooks/01_Temperature_Regression.ipynb |
Regression training notebook |
notebooks/02_Condition_Classification.ipynb |
Classification training notebook |
- Install dependencies:
pip install -r requirements.txt