4.1 Data Collection
The Indian Meteorological Department (IMD) offers convenient accessibility to meteorological information [6], encompassing various parameters like rainfall, temperature, humidity, and related variables crucial for discerning climate-induced water scarcity. This data can be obtained by specifying the desired location and timeframe. It initially required preprocessing for conversion into a universally readable CSV format.
4.2 Data Loading and Manipulation
The data selected, with monthly timestamps, aligns perfectly with the specific characteristics of Latur's climate and spans over four decades (1980–2022), forming the cornerstone of our approach. In this approach, the raw climatic data is imported into a DataFrame using the pandas library. The dataset comprises key columns:
• Date: Denoting the observation date.
• Rain: Indicating the recorded rainfall amount (in mm).
• Min-temp, max-temp: Representing the minimum and maximum temperatures recorded on the respective dates (in °C).
Initially, the dataset provides a daily time series record. However, to compute the Standardized Precipitation Evapotranspiration Index (SPEI), it is imperative to aggregate the data on a monthly basis. This task is accomplished using the resample method available in the DataFrame. Each column undergoes a specific aggregation function: the Rain column is summed to derive the total monthly rainfall, while the temperature columns are subjected to the mean function to determine the average monthly temperature. This processed dataset is then stored as a newly generated attribute named 'monthly dataframe'. This aggregated dataset forms the foundation for subsequent analyses and computations.
4.3 Data Engineering
1. Data Loading: Initiate the process by importing the raw climatic dataset, encompassing essential variables such as date, rainfall, and temperature.
2. Data Resampling: Effect a transformation of the daily data into a monthly frequency, a crucial preparatory step for precise SPEI computation.
3. Exporting Data: Systematically archive the resampled dataset in a CSV file, ensuring its readiness for comprehensive further analysis
Calculating SPEI using the Thornthwaite Method
To compute the Standardized Precipitation-Evapotranspiration Index (SPEI) [8], a pivotal drought index considering both precipitation and potential evapotranspiration (PET) for evaluating water availability, the Thornthwaite method is employed.
The first step involves computing the Thornthwaite Heat Index (I):
I =\(\sum _{i=1}^{12}\text{W}\text{i}\) (1)
Here, Wi is the temperature index for each month, calculated using the formula:
Wi = 100× \({\left(\frac{Ti}{5}\right)}^{1.514}\) (2)
If Ti < 0, then Wi = 0. Where Ti represents the monthly average temperature in ℃.
Thornthwaite Exponent (a):
Following the calculation of (I), the Thornthwaite Exponent (a) is determined as follows:
a = 6.75 × 10− 7 × I3 − 7.71 × 10− 5 × I2 + 0.01792 × I + 0.49239 (3)
The exponent (a) adjusts the sensitivity of PET to temperature fluctuations, thereby modulating its effect.
Thornthwaite Potential Evapotranspiration (PET):
Next, compute the monthly PET using the formula:
$$PET=16\times {(10\times \frac{T}{I})}^{a}$$
4
Here, T signifies the calculated monthly average temperature, I denote the annual heat index, and a represents the Thornthwaite component. PET estimates the potential water loss due to evaporation and transpiration.
Monthly Water Balance (P - PET):
Represented as (P - PET), the monthly water balance reflects the difference between total monthly precipitation (P) and potential evapotranspiration (PET). Calculate it as the variance between the values in the "Rain" column and the values in the "PET" column. Store the result in a new column labelled "P_minus_PET" in the DataFrame.
Standardizing to Obtain SPEI
Finally, determine the SPEI by standardizing the (P - PET) values using the z-score formula:
$$SPEI=\frac{P-PET-\mu }{{\sigma }}$$
5
Here, (µ) signifies the mean and (σ) denotes the standard deviation of the (P - PET) values across the specified time period. This standardization ensures comparability of SPEI across different locations and timeframes.
Stationarity Test:
When dealing with time series data, it's important to ensure that the underlying patterns and trends remain consistent over time. Non-stationary data, where these patterns shift or change, can pose challenges for accurate modeling and forecasting. To address this, we apply stationarity tests. If the data is found to be non-stationary, we implement differencing techniques to stabilize the time series, making it suitable for modeling. This step is crucial because if the data remains non-stationary, our models might struggle to accurately capture the true underlying patterns. As a result, the predictions and findings generated by the models may be unreliable or even misleading. Therefore, by rigorously assessing and ensuring stationarity in our time series data, we enhance the accuracy and reliability of our drought prediction models.
Normalization:
Normalization is a pivotal preprocessing step within our machine learning framework. It encompasses the adjustment of all input features to a uniform scale, a process instrumental in refining the model's training procedure and optimizing overall performance. This standardization ensures that each feature contributes equally to the learning process, fostering a more accurate and robust predictive model for drought detection and visualization.
4.4 Dataset Preparation:
The initial step involves structuring the data to align with machine learning requirements. This process entails creating sequential data points, where each instance encompasses a set of input features, such as historical SPEI values, and a corresponding target output, representing a future SPEI value. Following formatting, the dataset is systematically saved as a CSV file. This file is intentionally reserved for use in upcoming notebooks, specifically designed for tasks like model training and SPEI prediction evaluations. In these notebooks, the data is diligently arranged into sequences, ready to be fed into the base learner algorithms of the model. This process is integral to the two-tier ensemble model where, in the initial stage, several base models (SVR, ARIMA, and LSTM) are deployed. Each sequence incorporates historical SPEI values as features, while the target SPEI value acts as the sought-after output for the predictive model.
4.5 LSTM model training for Drought Detection
Constructing a robust LSTM neural network model involves strategic decisions on layers, neurons, activation functions, and potential enhancements like dropout or dense layers.
The network's complexity depends on the task and available data. Activation functions (sigmoid, tanh, or ReLU) introduce non-linearity, vital for discerning complex data relationships. Regularization techniques like dropout layers prevent overfitting. Dense layers after LSTM refine information processing. Careful configuration combines domain expertise and dataset understanding for a potent neural network [1].
Model Initialization
Sequential setup is ideal for straightforward data flow.
First LSTM Layer
50 memory units analyze intricate patterns. 'return_sequences = True' yields data sequences for subsequent layers.
Second LSTM Layer
Another 50 neurons capture nuanced temporal patterns.
Output Layer
Single neuron predicts continuous values. Adam optimizer, MSE loss, 23 epochs, batch size 32, 20% validation data, and early stopping prevent overfitting.
Early Stopping
Monitors validation loss, halting training if no improvement after 20 epochs. Prevents overfitting.
This model, composed of two LSTM layers followed by a Dense layer, demonstrates exceptional performance. It yielded low error metrics, indicating close alignment between predictions and actual values. With an impressive R² value of 0.9825, it exhibits substantial explanatory power, effectively capturing temporal patterns without excessive computational demands. Notably, the model achieved an accuracy of 98.01%, successfully classifying true positive and true negative cases. It attained a precision score of 1.0, signifying accurate positive predictions. The recall score of 91.67% highlighted the model's sensitivity to true positive cases. These results emphasized the model's robust performance, making it highly applicable, particularly in critical tasks like drought prediction. Evaluation involved comparing predicted SPEI values with actual observations, considering any uncertainties in the predictions.
4.6 Weighted Ensemble
A weighted ensemble is a technique used to combine predictions from multiple models by assigning different weights to each model's output. In this study, the weighted ensemble incorporates three base models:
Ridge Regression
This model employs a balanced approach, leveraging both linear regression and regularization techniques to navigate potential multicollinearity among predictor variables.
Support Vector Regression (SVR)
With its versatility in handling both linear and non-linear regression tasks, SVR excels in capturing intricate relationships within the data.
Long Short-Term Memory (LSTM)
A specialized recurrent neural network, LSTM is adept at discerning long-term dependencies in time-series data, making it an invaluable asset for tasks involving temporal patterns.
The basic equation for Weighted Average is:
$$\widehat{y}= \frac{\sum _{i=1}^{n}\frac{1}{MSEi}\text{*}yi}{\sum _{i=1}^{n}\frac{1}{MSEi}}$$
Table 1
Base Model Performance (for weighting)
Model | MSE | Weighting Factor |
Ridge Regression | 0.0042 | 238.10 |
SVR | 0.0038 | 263.16 |
LSTM | 0.0045 | 222.22 |
The innovation lies in the dynamic weighting scheme, finely-tuned to the inverse of Mean Squared Error (MSE). This nuanced approach ensures that models exhibiting lower MSE i.e., indicative of higher precision, bear more influence in the final prediction. This adaptability allows our ensemble to concentrate its efforts on models that demonstrate superior performance. The ultimate prediction is synthesized through a meticulous combination of all base model predictions, each imbued with a weight proportional to its predictive prowess. This harmonious amalgamation of insights ensures that our Weighted Ensemble Model not only captures the essence of each base model but does so with an astute emphasis on accuracy.
This approach serves to optimize predictive outcomes by taking full advantage of the unique capabilities of each base model. By dynamically adjusting weights based on individual model performance, it aims towards mitigating both systematic error and sensitivity to fluctuations in the training data.
4.7 Meta Learner
A meta-learner is a higher-level model that learns to combine the predictions from multiple base models to generate a final prediction. In the quest for improved predictive abilities, a multi-tiered approach has been formulated, harnessing the strengths of various models. In this study, the meta-learner employs predictions from four base models:
Ridge Regression
A judicious blend of linear regression and regularization techniques, adept at handling potential multicollinearity among the predictor variables.
Support Vector Regression (SVR)
A versatile algorithm equipped to navigate both the linear and non-linear regression tasks, excelling in the discernment of intricate relationships within the data.
ARIMA (Autoregressive Integrated Moving Average)
A time-honored method renowned for its effectiveness in the time-series forecasting, particularly in capturing linear dependencies within sequential data.
LSTM (Long Short-Term Memory)
A recurrent neural network, identical in architecture to the earlier model, chosen for its prowess in discerning long-term dependencies in time-series data.
The basic Equation (Random Forest Regressor):
$$\widehat{y}=RF\left(X\right)$$
where, X is the input matrix of predictions from Ridge, SVR, ARIMA, and LSTM models.
Meta-Learner Model - RandomForest Regressor: Steering our approach to the next level, we've introduced a RandomForest Regressor as our meta-learner. This robust ensemble learning method is poised to extract collective insights from our base models and refine our predictions.
Input to Meta-Learner
The bedrock of our Meta-Learner lies in the amalgamation of predictions from our diverse base models. These collective insights serve as the foundation upon which the meta-learner refines its understanding and hones its predictive abilities.
The meta-learner undergoes rigorous training to optimize the final prediction, effectively automating the art of combining forecasts from distinct models. This intricate process not only elevates our predictive accuracy but also encapsulates the collective wisdom of our modelling efforts, resulting in a refined and robust predictive framework.
4.8 Time Series Validation
Time Series Validation involves dividing the dataset into sequential time periods for model training and validation. In this study, a selected timeline from 1980 to 2022 is utilized, with timestamps set at 1-month intervals. This ensures that models are evaluated on data they haven't seen before, mimicking real-world forecasting scenarios.
Time series validation, employing techniques like TimeSeriesSplit, involves dividing the dataset into consecutive 'slices'. Each slice serves once as a validation set, while preceding slices are for training. This iterative process rigorously tests the model across diverse time periods, assessing its ability to generalize to unseen data. Performance metrics like Mean Squared Error and R-Squared provide insights into expected performance on new data.
Table 2
Comparison of the performance metrics for different validation techniques
Performance Metrics | MSE | MAE | RMSE | R-squared |
Standard Test Metrics | 0.0037 | 0.0235 | 0.0607 | 0.9951 |
Time Series Cross-Validation | 0.0022 | 0.0216 | 0.0444 | 0.9979 |
Simple Time-Based Split | 0.0028 | 0.0230 | 0.0531 | 0.9974 |
This methodology proves instrumental in addressing slow-onset climate-induced water scarcity, particularly in regions like Latur, where precise drought detection is pivotal for sound water resource management.