Views
No views yet
0 to 100%) based on simulated Malaysian hydrological data. The model analyzes historical and current hourly rainfall (mm) and river water levels (m) to calculate short-term flooding risks, capturing the delayed response of river runoff to heavy monsoonal storms.flash_flood_predictor.joblib) was trained on a 10-year simulated dataset (2015-2025) which provides the best balance of variance and generalization.river_level_lag_1h, river_level_lag_2h, rainfall_1h_lag_1hriver_change_1h, river_change_3h, river_change_6hrain_river_interaction_24h (Rainfall 24h × River Level)hour, monthjoblib:1import joblib
2import pandas as pd
3import numpy as np
4
5# 1. Load the model artifact
6model_data = joblib.load("flash_flood_predictor.joblib")
7model = model_data['model']
8expected_features = model_data['features']
9
10# 2. Prepare your feature dictionary (must be pre-engineered)
11sample_features = {
12 'rainfall_1h_mm': 15.0,
13 'rainfall_3h_mm': 45.0,
14 'rainfall_6h_mm': 60.0,
15 'rainfall_24h_mm': 90.0,
16 'cumulative_rainfall_3day_mm': 120.0,
17 'river_water_level_m': 4.2,
18 'river_change_1h': 0.3,
19 'river_change_3h': 0.8,
20 'river_change_6h': 1.2,
21 'river_level_lag_1h': 3.9,
22 'river_level_lag_2h': 3.6,
23 'rainfall_1h_lag_1h': 20.0,
24 'rainfall_1h_lag_2h': 10.0,
25 'rain_river_interaction_3h': 45.0 * 4.2,
26 'rain_river_interaction_24h': 90.0 * 4.2,
27 'hour': 21,
28 'month': 5
29}
30
31# 3. Convert to DataFrame and Predict
32X_single = pd.DataFrame([sample_features])[expected_features]
33prediction = model.predict(X_single)[0]
34
35# Clamp to 0-100% probability
36flood_probability = np.clip(prediction, 0.0, 100.0)
37print(f"Predicted Flash Flood Probability: {flood_probability:.1f}%")