What it shows
Farmers decide sowing dates and reservoir managers plan releases using rainfall outlooks. The project builds a machine learning model that predicts the coming month’s rainfall of one district from past rainfall and temperature, tests it honestly against a simple average baseline and reports where it fails.
The science
A random forest averages many decision trees trained on random samples of the data, which reduces overfitting. Features here are the previous three months of rainfall, month number and temperature. Time series must be split by time (train on early years, test on later years) and not randomly, because random splitting leaks information from the future. The model is judged against a baseline that predicts the long-term average of each month.
Materials
Cost: free. Many items come from home or from waste; spare parts such as LEDs, motors and wire are in the store.
- A laptop with Python 3, pandas, numpy, scikit-learn and matplotlib
- 30 or more years of monthly rainfall and temperature for one district from an open data portal (CSV)
- Jupyter notebook
- A notebook and printer for the report
- Free Google Colab account as an alternative
Safety
For this project: Use only public data and cite the source and licence. State clearly that the model is a student exercise and not a forecast for decisions.
Never use mains electricity: power models with cells, batteries or a low-voltage adapter. Sharp and hot tools, flames and lab chemicals need an adult or your teacher beside you. Keep magnets, button cells and small parts away from young children, and wash your hands after making.
All the safety rulesStep by step
12 steps. Do them in order, and test each part before you go on to the next. Write what you notice in a notebook as you go.
Download the data, check that the dates are complete and write down how many months are missing.
Fill gaps carefully, for example by the long-term mean of that calendar month, and keep a record of how many were filled.
Create features: rainfall of the previous 1, 2 and 3 months, the month number as sine and cosine, and the previous month’s temperature.
Split by time, training on the first 80 percent of years and testing on the last 20 percent.
Compute the baseline error: predict each month’s average from the training years and calculate mean absolute error on the test years.
Train a RandomForestRegressor and calculate the same error on the test years.
Plot predicted against actual rainfall for the test period and look at how the model handles the monsoon peak.
Tune the number of trees and the depth with cross validation using time-series splits.
Print feature importances and explain which features matter most.
Check separately the months of June to September and the dry months.
Test how the model performs in an unusually dry or wet year and comment on extreme events.
Write the report with problem statement, data, method, results, comparisons with the baseline, limits and conclusions.
What you should see
The model is only modestly better than the monthly-average baseline: typically 5 to 20 percent lower error in the monsoon months, and it underestimates extremes. An honest report shows this limitation clearly.
Viva questions
A teacher or a judge will ask how it works. Try to answer each question before you open it, then compare.
1Why not split the data randomly?
In time series, random splits let the model see the future, which gives a falsely good score.
2What is a baseline model?
A very simple prediction, such as the monthly average, that any useful model must beat.
3What does feature importance tell you?
How much each input reduces the error across the trees, which is not proof of cause.
4Why is the model weak for extremes?
Extreme events are rare in the data, so the model has few examples to learn from.
Take it further
Add a sea-surface temperature index such as the Indian Ocean Dipole as a feature and test if the skill improves.
Change one thing, measure what happens, and add a table or chart of your readings: that is what turns a model into your own investigation.
Free ebooks for this project
Science projects
Writing a Science Project File
How to write the report, from the cover page to the bibliography
