Cloud cover, RainToday, RainTomorrow, Location, Date
In this notebook I focus on:
Classification task:
Predicting a 3-class target MaxTemp_class (cool / medium / hot days).
Regression task:
Predicting the continuous target MaxTemp.
4. Notebook Structure
Part 1 – Data Loading & Cleaning
Load the CSV, parse dates, handle missing values, and basic type conversions.
Part 2 – Exploratory Data Analysis (EDA)
Summary statistics, distributions, correlations and key visualizations.
Part 3 – Baseline Models
Initial regression and classification baselines using raw features.
Part 4 – Feature Engineering & Clustering
Create engineered features.
Apply K-Means clustering and visualize clusters using PCA.
Part 5 – Regression with Engineered Features
Train Linear Regression, Random Forest and Gradient Boosting on the engineered dataset.
Part 6 – Winning Regression Model
Select the best regression model and export it as a pickle file.
Part 7 – Regression-to-Classification
Create temperature classes from the numeric target using quantile binning.
Check class balance and discuss metrics.
Part 8 – Train & Evaluate Classification Models
Train Logistic Regression, Random Forest and Gradient Boosting classifiers.
Evaluate using classification reports, confusion matrices and macro F1.
Choose and save the winning classifier.
Part 9 – Presentation Video
Link to the recorded walkthrough of the project.
5. Exploratory Data Analysis (EDA) & Research Questions
In Part 2 I explored the Weather in Australia dataset to understand data quality, basic patterns and relationships before building any models.
2.1 Data cleaning and structure
Parsed the Date column to a proper datetime type and kept only relevant columns.
Checked for duplicates and removed them if present.
Inspected data types and fixed inconsistencies (for example, categorical vs. numeric fields).
Handled missing values:
For the regression and classification targets (MaxTemp, RainTomorrow, MaxTemp_class) I dropped rows with a missing target.
For numeric features I used simple strategies such as median imputation or row dropping, depending on how critical the feature was.
For categorical features I grouped rare categories and, when needed, used an "Unknown" category for missing values.
Verified that the final working dataset had no NA values in the features used for modeling.
2.2 Outlier detection and handling
Inspected distributions and box plots for key numeric features such as Rainfall, MaxTemp, MinTemp, Humidity3pm and wind speed.
Identified extreme outliers in Rainfall (values up to 371 mm).
Applied a mild winsorization to Rainfall at the 99th percentile (clipping very extreme days), without removing any rows:
Original max ≈ 371.0
Clipped max at 99th percentile ≈ 37.2
All other numeric variables showed reasonable behaviour, so no additional outlier removal was applied.
2.3 Descriptive statistics
Computed descriptive statistics (mean, median, std, min, max, quartiles) for all numeric variables.
Examined the correlation matrix between weather features and the target MaxTemp.
Observed strong positive correlations between MaxTemp and:
MinTemp
Temp3pm and Temp9am
Also found meaningful relationships between humidity, rainfall and the rain indicator RainTomorrow, which later guided feature engineering.
2.4 Exploratory visualizations
To better understand the data, I used several visualizations:
Histograms and KDE plots for key numeric variables (temperatures, rainfall, humidity, pressure).
Box plots of MaxTemp by Location and by Season.
Scatter plots (e.g., Rainfall vs MaxTemp, Humidity3pm vs MaxTemp).
image
A correlation heatmap to summarize linear relationships.
image
PCA plots later used to visualize clusters (see Part 4).
These plots allowed me to identify skewed distributions, potential non-linear relationships and variables that are likely to be important for prediction.
2.5 Research questions (6) and visual answers
Based on the EDA, I defined six research questions and answered each of them with specific plots and short written interpretations:
RQ1 – MaxTemp by location and season
How does the distribution of daily maximum temperature (MaxTemp) differ across locations and seasons in Australia?
→ Answered with box plots of MaxTemp by Location and by Season.
image
RQ2 – MaxTemp vs. rainfall
What is the relationship between daily rainfall and MaxTemp?
image
→ Answered with scatter plots and trend patterns showing how heavy rainfall days tend to be cooler.
RQ3 – Seasonality of temperature
How does MaxTemp vary across the four seasons (summer, autumn, winter, spring)?
image
→ Answered with seasonal box plots highlighting higher temperatures and larger variability in summer vs. winter.
RQ4 – Humidity and rain tomorrow
How are afternoon humidity levels (Humidity3pm) related to the likelihood of rain the next day (RainTomorrow)?
image
→ Answered with density/box plots comparing humidity distributions for RainTomorrow = Yes vs. No.
RQ5 – Intraday temperature dynamics
How do intraday temperature metrics (such as TempRange and TempChange_9am_3pm) relate to cloud cover, wind and other conditions?
image
→ Answered with scatter plots and correlation views using the engineered features.
RQ6 – Weather “types”
Can we discover meaningful weather “types” using clustering, and do they help explain variation in MaxTemp and humidity?
image
→ Answered by applying K-Means, visualizing clusters in PCA space and summarizing each cluster’s average profile (hot & dry, cool & humid, etc.).
These questions and visual answers bridge the gap between raw EDA and the modeling parts of the project: they directly motivated the engineered features, the clustering step, and the choice of models and metrics later on.
6. Feature Engineering
To improve model performance and capture domain structure, I engineered several new features:
Temperature-based features
TempRange = MaxTemp - MinTemp
TempChange_9am_3pm = Temp3pm - Temp9am
Humidity & pressure changes
HumidityDiff_9am_3pm = Humidity3pm - Humidity9am
PressureDiff_9am_3pm = Pressure3pm - Pressure9am
Seasonality
Season (Winter / Spring / Summer / Autumn), derived from the date.
Month_sin, Month_cos – cyclical encoding of the month to capture yearly periodicity.
Clustering feature
weather_cluster – cluster ID (0–4) from K-Means on standardized weather variables.
Classification targets
MaxTemp_bin / MaxTemp_class – 3-class label for daily maximum temperature, based on quantile thresholds (approximately 33% / 66%).
These engineered features are used consistently across both regression and classification pipelines.
7. Clustering (Part 4.2)
I applied K-Means on standardized weather features (MinTemp, Temp3pm, humidity, pressure, wind, etc.):
Number of clusters:k = 5
Visualization: PCA projection with cluster colors.
image
Interpretation:
Some clusters correspond to cooler and more humid days, others to hot and dry days.
The cluster profiles table (mean values per cluster) shows distinct combinations of temperature, humidity and wind.
The categorical feature weather_cluster was added to the dataset and later turned out to be important for the models.
8. Regression Models (Part 5)
Target: MaxTemp (continuous).
Training is done on the feature-engineered dataset using a consistent preprocessing pipeline:
Uploaded to the same / another HuggingFace repository.
Both models can be loaded via pickle and used to predict MaxTemp (regression) or MaxTemp_class (classification) on new data with the same preprocessing steps.