# Research on Real-Time Local Rainfall Prediction Based on MEMS Sensors

Authors: Zeyi Chao; Fangling Pu; Yuke Yin; Bin Han; Xiaoling Chen
Journal: Journal of Sensors
 (2018)

---

## Abstract

A more accurate and timely rainfall prediction is needed for flood disaster reduction and prevention in Wuhan. The in situ microelectromechanical systems’ (MEMS) sensors can provide high time and spatial resolution of weather parameter measurement, but they suffer from stochastic measurement error. In order to apply MEMS sensors in real-time rainfall prediction in Wuhan, firstly, seasonal trend decomposition using Loess (STL) algorithm is utilized to decompose the observed time series into trend, seasonal, and remainder components. The trend of the observed series is compared with the corresponding trend of the data downloaded from the authoritative website with the same weather parameter in terms of Euclidean distance and cosine similarity. The similarity demonstrates that the observation of MEMS sensors is believable. Secondly, the long short-term memory (LSTM) is used to predict the real-time rainfall based on the observed data. Compared with autoregressive and moving average (ARMA), random forest (RF), support vector machine (SVM), and back propagation neural networks (BPNNs), LSTM not only performs as well as ARMA in real-time rainfall prediction but also outperforms the other four models in seasonal rainfall pattern description and seasonal real-time rainfall prediction. Our experiment results show that more detailed, timely, and accurate rainfall prediction can be achieved by using LSTM on the MEMS weather sensors.


---

## Body

## 1. Introduction

Rainfall is one of the major severe phenomena within a climate system. It has a direct influence on water resource management, agriculture, and ecosystems [1]. The heavy rainfall mostly contributes to landslides, mudslides, floods, and other natural disasters. The rainfall-induced disasters in each year lead to serious damage and losses of both life and infrastructure [2]. Take the central large city, Wuhan, for instance, Wuhan locates at longitude between 113°41′ and 115°05′, latitude between 29°58′ and 31°22′. Wuhan belongs to subtropical moist monsoon climate [3]. In July 2016, affected by El Nino, Wuhan suffered heavy rainfall disaster. The rainfall from June 30 to July 6 reaches 582.5 mm, which is the highest weekly rainfall since the historical records [4]. It caused severe mass floods, 2.265 billion economic loss, and death of 14 citizens. Therefore, rainfall prediction is a problem that needs to be solved to avoid or minimize losses of both life and belongings.According to the definition of World Meteorological Organization (WMO) (http://www.wmo.int/pages/prog/www/DPS/GDPS-Supplement5-AppI-4.html), the weather forecasting can be divided into real-time, short-term, middle-term, and long-term forecasting. Real time forecasting means 0–2 hours of weather prediction. Short-term forecasting ranges from 2 hours to 72 hours. Middle-term forecasting is beyond 72 hours and up to 240 hours. Long-term forecasting is beyond 10 days and up to 30 days and further extends to 2 years. Most weather forecasts provide today’s and tomorrow’s weather, an hour-by-hour forecast, and a 15-day forecast for a region. The hour level weather forecasting usually does not provide timely and accurate weather parameters for early warning, especially during rainstorm. The accurate early warning is difficult to extract from the current weather forecasting data to support the emergency response and disaster management. A shorter and more accurate weather prediction is needed for flood disaster reduction and prevention.Weather parameters have been measured by gauges, weather radars, or satellites. The observation equipment evaluation index involves measurement precision, spatial range, time range, and deployment price. Satellite-based measurement has a wider spatial coverage but a longer repeated observation period. The common sampling interval for weather radar is 15 minutes [5]. The microelectromechanical systems’ (MEMS) sensors for weather observation have the highest time resolution and spatial resolution. The local weather parameters around the sensors can be repeatedly measured within one minute or less. selected points are computed. Combined with the embedded technique and wireless communication interface, such as WiFi, Zigbee, or Bluetooth, an automatic meteorological station can be established. The price to build a meteorological network using MEMS sensors is cheaper than that paid on a radar or a satellite. However, the MEMS sensors suffer from deterministic and stochastic errors. The deterministic error can be removed by calibration techniques before sale. The stochastic error cannot be directly removed from the measurement. The stochastic error is modeled as additive noise [6]. The law of weather change is hidden in the sensor time series with error.We have built several weather monitoring stations that utilized MEMS sensors to monitor local weather in China. Two stations located in Wuhan. Four stations were deployed around Erhai, Yunnan. Each station has been equipped with seven sensors, which are wind speed, wind direction, atmospheric temperature, atmospheric humidity, atmospheric pressure, rainfall sensor, and radiation sensor. The 7 weather parameters are sampled every 5 minutes. After obtaining weather sensor data for more than 3 years in Wuhan, we wish to demonstrate that the MEMS sensor observation is believable and the data are available to real-time rainfall prediction. The accurate and more timely rainfall prediction can strongly support flooding disaster relief decision.We focus on the short-term weather variation of Wuhan. It is assumed that the observed sensor time series have trend, seasonal, and residual components. Trend component reflects the progression of the time series, while seasonal component represents the seasonal variation. The original observed data cannot exhibit the trend because of the stochastic error. According to Alexandrov et al. [7], Loess filter behaves well in capturing the details of the trends. Seasonal trend decomposition using Loess (STL) is a filtering procedure that was developed to decompose the time series into seasonal, trend, and remainder components [8]. STL has been demonstrated that it is a robust estimation of the trend and seasonal components. More importantly, STL is able to decompose the time series with missing values, which is the inevitable cases for the wireless sensor network (WSN) due to the interruption of communication link or power-off. Therefore, we applied STL to extract the trend of the observed data and that of the published weather data. The referenced weather data were downloaded from the website (https://rp5.ru/). The validity of the observed time series is proved by calculating the similarity parameters, Euclidean distance (ED), and cosine similarity (CS), between the two trends.Rainfall is a complex meteorological phenomenon. Accurate and real-time rainfall prediction remains challenging for many decades because of its stochastic and nonlinear nature. The proposed methods for rainfall prediction can be roughly divided into two categories, classic algorithms and machine learning algorithms. The model-based approaches, singular spectrum analysis, and wavelet are the typical classic algorithms. Autoregressive and moving average (ARMA) model is the common time series model for rainfall prediction [9]. The wavelet decomposition uses a pair of filters to decompose the original time series iteratively. The trend is separated from noise at each scale domains. Because wavelet decomposition is usually dependent on other parameter estimation models, its application is less than the ARMA model. We select the ARMA model as the representative of classic algorithms.In recent years, artificial intelligence (AI) develops rapidly. A great deal of machine learning and deep learning algorithms have been proposed for time series analysis. The models of machine learning algorithms have been applied to solve the real-time rainfall prediction problem. Support vector machine (SVM) shows better performance than random forest (RF) in 2 and 3 h ahead prediction [10]. Artificial neural networks (ANNs), such as radial basic function neural networks (RBFNNs) and back propagation neural networks (BPNNs), also perform satisfactorily in some cases. The best algorithm is difficult to choose, because the data used by the models are different. Recurrent neural networks (RNNs) have been proved well in time series prediction [11]. However, with the vanishing and exploding gradient problems, RNNs are not capable of solving the long-term dependency rainfall sequence. The long short-term memory (LSTM) was proposed in 1997 by Hochreiter and Schmidhuber [12] and was improved in 2000 by Gers et al. [13] to overcome the shortage of RNN. LSTM has been widely acknowledged as the current state-of-art prediction models for time series [14]. We choose the LSTM to predict real-time rainfall based on the observed sensor data at Wuhan University. The experiment results show that LSTM is better to describe the seasonal rainfall process than ARMA, RF, SVM, and BPNNs. LSTM is also found more suitable for the sensor time series that usually have missing data.This paper has two main contributions. (i) The weather time series sampled by WSN with 5-minute interval have been proved to be effective and valuable in local meteorological monitoring. (ii) The real-time rainfall can be well predicted by LSTM.The rest of this paper is organized as follows. In Section2, the WSN for local weather parameter sampling is introduced. The validity of the observed time series is demonstrated in Section 3. Real-time rainfall prediction using LSTM is presented in Section 4. The results of prediction are shown in Section 5. Conclusion is given in Section 6.


## 2. Weather Data Observed by a Wireless Sensor Network

### 2.1. WSN for Weather Observation

The WSN for local weather monitoring was built from December 2014 to July 2015. The star topology sensor network shown in Figure1 is composed of one server and six automatic meteorological monitoring stations that are called sensor nodes. One node powered by electricity was set on the roof of Wuhan University. Another node powered by solar energy was set at Baoxie, suburb of Wuhan. The other four nodes that were deployed around Erhai Lake are all powered by electricity. All the nodes communicate with the server by GPRS (General Packet Radio Service) modules through the China Mobile’s network. The server can send command to adjust the operation of each node. Weather data transmitted from nodes are all saved in the server. Besides, the server provides data services, such as publishing the real-time data on the website or providing data services to specific users. Figure 2 shows the webpage screenshot of our website.Figure 1
Star topology of a wireless sensor network.Figure 2
Webpage screenshot of the server.Each sensor node is composed of seven sensors, one Globe Positioning Systems’ (GPS) receiver module, and one GPRS module. Each measurement includes not only the values of the seven sensors but also the corresponding time and the geographical location information (longitude, latitude, and height). The default observation interval is 5 minutes. The repeating measurement cycle can be reset through the command issued from the server to the sensor node.


### 2.2. Performance of the MEMS Weather Sensors

The performance of each sensor is shown in Table1. The measuring range and resolution can meet the requirement for weather observation, but the accuracy shows that the deviation is relatively high. Moreover, stochastic error exists in each measurement. Whether the time series observed by WSN is available needs to be proven.Table 1
Performance of weather sensors.
Sensors
Unit
Range
Resolution
Accuracy
Working condition
Wind speed
m/s
0∼100
0.1
±0.3
−40°C∼50°C; ≤100%RH
Wind direction
°
0∼360
1
±3
−40°C∼50°C; ≤100%RH
Temperature
°C
−50∼70
0.1
±0.2
−50°C∼80°C
Humidity
%RH
0∼100
0.1
±3
−40°C∼50°C; ≤100%RH
Pressure
hPa
500∼1100
0.1
±0.3
−50°C∼80°C
Rainfall
mm
0∼4
0.1
±4%
0°C∼50°C
Radiation
W/m2
0∼2000
0.1
±2%
−50°C∼85°C; ≤100%RH


### 2.3. Fault of the Time Series

There is another problem in the observed time series. The interval between consecutive measurements is not strictly in accordance with the set period. Missing data happened sometime. The reasons include out of power, interruption of communication connection, the system onboard rebooting, or attack on server by a hacker. Therefore, processing the observed weather data may encounter more difficulties than analyzing the authoritative released weather data.


## 2.1. WSN for Weather Observation

The WSN for local weather monitoring was built from December 2014 to July 2015. The star topology sensor network shown in Figure1 is composed of one server and six automatic meteorological monitoring stations that are called sensor nodes. One node powered by electricity was set on the roof of Wuhan University. Another node powered by solar energy was set at Baoxie, suburb of Wuhan. The other four nodes that were deployed around Erhai Lake are all powered by electricity. All the nodes communicate with the server by GPRS (General Packet Radio Service) modules through the China Mobile’s network. The server can send command to adjust the operation of each node. Weather data transmitted from nodes are all saved in the server. Besides, the server provides data services, such as publishing the real-time data on the website or providing data services to specific users. Figure 2 shows the webpage screenshot of our website.Figure 1
Star topology of a wireless sensor network.Figure 2
Webpage screenshot of the server.Each sensor node is composed of seven sensors, one Globe Positioning Systems’ (GPS) receiver module, and one GPRS module. Each measurement includes not only the values of the seven sensors but also the corresponding time and the geographical location information (longitude, latitude, and height). The default observation interval is 5 minutes. The repeating measurement cycle can be reset through the command issued from the server to the sensor node.


## 2.2. Performance of the MEMS Weather Sensors

The performance of each sensor is shown in Table1. The measuring range and resolution can meet the requirement for weather observation, but the accuracy shows that the deviation is relatively high. Moreover, stochastic error exists in each measurement. Whether the time series observed by WSN is available needs to be proven.Table 1
Performance of weather sensors.
Sensors
Unit
Range
Resolution
Accuracy
Working condition
Wind speed
m/s
0∼100
0.1
±0.3
−40°C∼50°C; ≤100%RH
Wind direction
°
0∼360
1
±3
−40°C∼50°C; ≤100%RH
Temperature
°C
−50∼70
0.1
±0.2
−50°C∼80°C
Humidity
%RH
0∼100
0.1
±3
−40°C∼50°C; ≤100%RH
Pressure
hPa
500∼1100
0.1
±0.3
−50°C∼80°C
Rainfall
mm
0∼4
0.1
±4%
0°C∼50°C
Radiation
W/m2
0∼2000
0.1
±2%
−50°C∼85°C; ≤100%RH


## 2.3. Fault of the Time Series

There is another problem in the observed time series. The interval between consecutive measurements is not strictly in accordance with the set period. Missing data happened sometime. The reasons include out of power, interruption of communication connection, the system onboard rebooting, or attack on server by a hacker. Therefore, processing the observed weather data may encounter more difficulties than analyzing the authoritative released weather data.


## 3. Proof of Validity of the Observed Time Series

To prove the validity of the sensor data, we downloaded the weather data of Wuhan City from the website (https://rp5.ru/) as authoritative reference. The downloaded data are provided by the ground stations certified by National Oceanic and Atmospheric Administrator (NOAA). The station locates near Wuhan Tianhe International Airport. Although the station is about 35 kilometers away from our weather sensor node at Wuhan University, both time series reflect the Wuhan weather. Therefore, it is assumed that if the trend of the observed time series resembles closely the trend of the downloaded time series, the observation of the sensor nodes can be applied to weather research.


### 3.1. Weather Trend Extraction by STL

STL is a filtering procedure for decomposing a time series into three components: trend, seasonal, and remainder components. It is supposed that the weather time seriesDv, such as atmospheric temperature, are composed of trend, seasonal, and remainder components, which are denoted by Tv, Sv, and Rv, respectively, for v=1,…,N. Then,
(1)Dv=Tv+Sv+Rv.Tv is the trend data that are extracted from the observed time series and the downloaded time series.Key to the STL approach is the locally weighted scatterplot smoothing (Loess) process, in which the closest point is assigned to the biggest weight. Supposeyi for i=1,…,N is the observed time series, and the regression result y^i is the smoothing yi of given xi. q points that are closest to x are used in the regression. The observed time series by WSN were resampled to match the 3-hour interval of the downloaded time series. Considering the 24 hours each day, we set q to be 8 with the interval of 3 hours. The weight function W is described in the following formula:
(2)Wu=1−u33for0≤u<1,0foru≥1.Thus, the weights ofq selected points are computed according to the distance from x, as shown in the following formula:
(3)Wix=Wxi−xdq,where dq is the distance between the qth farthest point xi and x.Weight of the pointxi decreases with the increasing distance between xi and x. Weight of the qth farthest point comes to zero. Then, we can get the regression result y^ using polynomial regression with the weights based on least squares methods (LSM). The polynomial degree is usually set to be 1 or 2, corresponding to linear regression or quadratic regression separately. We chose the quadratic regression. With the smoother Loess, data is divided into trend component of low frequency, seasonal component of high frequency, and remainder component of random variation.We applied STL to extract the trends of both observed weather data and downloaded weather data. The observed time series started in June 2015 at Wuhan University. Correspondingly, the downloaded weather data also started on the same date. Take atmospheric temperature data in spring 2016, for example, the result of STL decomposition on the observed time series is shown in Figure3. The result of STL decomposition on the downloaded atmospheric temperature data in 2016 is shown in Figure 4. The falling peak in Figure 4 represents the missing data on 16 July 2016. Because of the robustness of STL, trend has not been affected.Figure 3
STL decomposition of observed atmospheric temperature data in spring 2016.Figure 4
STL decomposition of downloaded atmospheric temperature data in 2016.


### 3.2. Similarity Comparison

The paper [15] contributes to presenting an overview of nine similarity measurements for time series data. ED, dynamic time warping (DTW), and CS are widely used to measure the similarity of numerical time series. ED is straightforward for intuitive understanding and easy to implement. In particular, when the length of time series is relatively large, ED is an ideal choice [15]. DTW is designed to handle the time-warping series or the time series in which lengths do not matched [16]. CS is a similarity measure for orientation rather than magnitude. In CS, the cosine of the angle between two vectors is calculated. If the value of CS is equal to 1, the two vectors are in the same direction.We chose ED and CS to measure the similarity of two trends, ED for magnitude and CS for orientation. Each year, the two types of dataset are divided into four subdatasets according to the seasonal partition of Wuhan [17]. The seasonal division is shown in Table 2. The results of ED and CS in 2016 are presented in Table 3. To make the similarity comparison more visible, two trends of temperature in spring 2016 and their subtraction are shown in Figure 5.Table 2
Seasonal partition of Wuhan.
Spring
Summer
Autumn
Winter
March 17–May 16
May 17–Sept 25
Sep 26–Nov 22
Nov 23–March 16Table 3
Results of similarity comparison in four seasons.
(a)
Spring
Temperature
Humidity
Wind speed
Pressure
Rainfall
ED
0.055
0.831
0.059
0.087
0.054
CS
0.998
0.997
0.953
0.999
0.805
(b)
Summer
Temperature
Humidity
Wind speed
Pressure
Rainfall
ED
0.048
0.676
0.038
0.053
0.085
CS
0.999
0.998
0.948
0.999
0.814
(c)
Autumn
Temperature
Humidity
Wind speed
Pressure
Rainfall
ED
0.036
0.791
0.074
0.105
0.033
CS
0.999
0.999
0.970
0.999
0.843
(d)
Winter
Temperature
Humidity
Wind speed
Pressure
Rainfall
ED
0.052
0.662
0.035
0.419
0.007
CS
0.994
0.994
0.965
0.999
0.962Figure 5
Comparison of the trends of the observed and downloaded temperature in spring 2016.Table3 exhibits that the trend of the observed time series is similar to that of the downloaded series in terms of atmospheric temperature, atmospheric humidity, atmospheric pressure, wind speed, and rainfall. The reason that the comparison of wind direction was not done is that the downloaded wind direction data is in word description, but the observed wind direction data is in degree number. Table 3 demonstrates that the weather parameters measured by the MEMS sensors can be used for local weather observation and climate research.


## 3.1. Weather Trend Extraction by STL

STL is a filtering procedure for decomposing a time series into three components: trend, seasonal, and remainder components. It is supposed that the weather time seriesDv, such as atmospheric temperature, are composed of trend, seasonal, and remainder components, which are denoted by Tv, Sv, and Rv, respectively, for v=1,…,N. Then,
(1)Dv=Tv+Sv+Rv.Tv is the trend data that are extracted from the observed time series and the downloaded time series.Key to the STL approach is the locally weighted scatterplot smoothing (Loess) process, in which the closest point is assigned to the biggest weight. Supposeyi for i=1,…,N is the observed time series, and the regression result y^i is the smoothing yi of given xi. q points that are closest to x are used in the regression. The observed time series by WSN were resampled to match the 3-hour interval of the downloaded time series. Considering the 24 hours each day, we set q to be 8 with the interval of 3 hours. The weight function W is described in the following formula:
(2)Wu=1−u33for0≤u<1,0foru≥1.Thus, the weights ofq selected points are computed according to the distance from x, as shown in the following formula:
(3)Wix=Wxi−xdq,where dq is the distance between the qth farthest point xi and x.Weight of the pointxi decreases with the increasing distance between xi and x. Weight of the qth farthest point comes to zero. Then, we can get the regression result y^ using polynomial regression with the weights based on least squares methods (LSM). The polynomial degree is usually set to be 1 or 2, corresponding to linear regression or quadratic regression separately. We chose the quadratic regression. With the smoother Loess, data is divided into trend component of low frequency, seasonal component of high frequency, and remainder component of random variation.We applied STL to extract the trends of both observed weather data and downloaded weather data. The observed time series started in June 2015 at Wuhan University. Correspondingly, the downloaded weather data also started on the same date. Take atmospheric temperature data in spring 2016, for example, the result of STL decomposition on the observed time series is shown in Figure3. The result of STL decomposition on the downloaded atmospheric temperature data in 2016 is shown in Figure 4. The falling peak in Figure 4 represents the missing data on 16 July 2016. Because of the robustness of STL, trend has not been affected.Figure 3
STL decomposition of observed atmospheric temperature data in spring 2016.Figure 4
STL decomposition of downloaded atmospheric temperature data in 2016.


## 3.2. Similarity Comparison

The paper [15] contributes to presenting an overview of nine similarity measurements for time series data. ED, dynamic time warping (DTW), and CS are widely used to measure the similarity of numerical time series. ED is straightforward for intuitive understanding and easy to implement. In particular, when the length of time series is relatively large, ED is an ideal choice [15]. DTW is designed to handle the time-warping series or the time series in which lengths do not matched [16]. CS is a similarity measure for orientation rather than magnitude. In CS, the cosine of the angle between two vectors is calculated. If the value of CS is equal to 1, the two vectors are in the same direction.We chose ED and CS to measure the similarity of two trends, ED for magnitude and CS for orientation. Each year, the two types of dataset are divided into four subdatasets according to the seasonal partition of Wuhan [17]. The seasonal division is shown in Table 2. The results of ED and CS in 2016 are presented in Table 3. To make the similarity comparison more visible, two trends of temperature in spring 2016 and their subtraction are shown in Figure 5.Table 2
Seasonal partition of Wuhan.
Spring
Summer
Autumn
Winter
March 17–May 16
May 17–Sept 25
Sep 26–Nov 22
Nov 23–March 16Table 3
Results of similarity comparison in four seasons.
(a)
Spring
Temperature
Humidity
Wind speed
Pressure
Rainfall
ED
0.055
0.831
0.059
0.087
0.054
CS
0.998
0.997
0.953
0.999
0.805
(b)
Summer
Temperature
Humidity
Wind speed
Pressure
Rainfall
ED
0.048
0.676
0.038
0.053
0.085
CS
0.999
0.998
0.948
0.999
0.814
(c)
Autumn
Temperature
Humidity
Wind speed
Pressure
Rainfall
ED
0.036
0.791
0.074
0.105
0.033
CS
0.999
0.999
0.970
0.999
0.843
(d)
Winter
Temperature
Humidity
Wind speed
Pressure
Rainfall
ED
0.052
0.662
0.035
0.419
0.007
CS
0.994
0.994
0.965
0.999
0.962Figure 5
Comparison of the trends of the observed and downloaded temperature in spring 2016.Table3 exhibits that the trend of the observed time series is similar to that of the downloaded series in terms of atmospheric temperature, atmospheric humidity, atmospheric pressure, wind speed, and rainfall. The reason that the comparison of wind direction was not done is that the downloaded wind direction data is in word description, but the observed wind direction data is in degree number. Table 3 demonstrates that the weather parameters measured by the MEMS sensors can be used for local weather observation and climate research.


## 4. Local Real-Time Rainfall Prediction with LSTM

Our weather observation node may reflect the weather change of an area around Wuhan University. Real-time rainfall prediction information can attract students’ more attention than the published one-hour forecasting, especially during a thunderstorm. They can decide whether to take an umbrella, whether to go outside, or whether their laboratory has the risk of inundation.We set the observed time seriesx=x1,…,xT as the input of LSTM. xt∈Rd represents the weather vector observed at time step t. According to the correlation analysis of observed weather parameters, atmospheric temperature, atmospheric humidity, atmospheric pressure, and rainfall data are selected as the input vector xt. Then, the dimension of input data d equals to 4. T is the length of the observed time series. The output of LSTM is the predicted rainfall data at time step t+1, denoted as y^t. The dimension of output data equals to 1. The actual rainfall value is denoted as yt. Each time step is set to 5 minutes. It means that LSTM can be used to predict next 5-minute rainfall. We also adjust the interval of each time step to predict 10- or 15-minute rainfall.The basic unit in the hidden layer of an LSTM network is the memory block. Memory block contains one or more memory cells and three adaptive and multiplicative units [13]. These units are called gates, including input gate, forget gate, and output gate. The structure and data flow of memory block is shown in Figure 6. The symbols i, f, and o, respectively, refer to the input gate, forget gate, and output gate. The symbols g and h are the memory cell input and cell output activation function, respectively. At each time step t, input sequence xt can be propagated to the memory cell, if the input gate i is activated. Forget gate f controls whether the past memory cell status Ct−1 can be added as the input to the current memory cell. The updated status of memory cell will be propagated to the output based on the activation of the output gate o [18]. The overall data flow can be described with the following mathematical formulas:
(4)it=σWi⋅ht−1,xt+bi,ft=σWf⋅ht1,xt+bf,gt=tanhWc⋅ht−1,xt+bc,Ct=ft∗Ct−1+it∗gt,ot=σWo⋅ht−1,xt+bo,ht=ot∗tanhCt,where xt denote the input of memory block, and ht denotes the output of memory block. W denotes weight matrices and b denotes biases’ vector, which are both shared in all time steps and learned during the phase of training. σ represents the sigmoid activation function [19]. At each time step t, the output of memory block ht is updated by input sequence xt, input gate it, forget gate ft, output gate ot, memory cell status, output ht−1, and Ct−1 at previous time step t−1. The predicted rainfall data y^t is the output of LSTM output layer with the ht as the input.Figure 6
Structure and data flow of memory block.


## 5. Results

The LSTM was used by two manners to predict rainfall. One is called real-time prediction. The other is called seasonal real-time prediction. Real-time prediction means to predict the rainfall based on the previous adjacent time sequence. Seasonal real-time prediction means to predict the rainfall based on the rules extracted by LSTM from the same season data of the previous year.We have conducted real-time rainfall prediction by LSTM for 5 minutes, 10 minutes, and 15 minutes based on observations. Considering the weather characteristics of Wuhan, rainy days are much less than nonrainy days in the whole year. A great deal of observed rainfall is equal to zero. Assuming the observed rainfall as positive samples, to balance the positive and negative samples, we select the observations from March 2016 to July 2016 in Wuhan University. This period is called the rainy season of Wuhan. In addition, we select ARMA as the representative of classic algorithms and RF, SVM, and BPNNs as the representatives of machine learning algorithms for performance comparison.Seasonal real-time rainfall was predicted for 5 minutes, 10 minutes, and 15 minutes in autumn 2016 based on the rules obtained in autumn 2015. ARMA is not suitable for seasonal real-time prediction because it predicts rainfall step by step. We used RF, SVM, BPNNs, and LSTM, respectively, to make seasonal real-time prediction.


### 5.1. Evaluation Metrics

For numeric weather prediction (NWP), several evaluation metrics have been defined to evaluate prediction performance in the paper [20]. We chose the mean absolute error (MAE) and root mean square error (RMSE) as the evaluation metrics, which are described in the following formulas:
(5)MAE=1T∑t=1Ty^t−yt,RMSE=1T∑t=1Ty^t−yt2,where T is the length of test set, yt denotes the actual rainfall data, and y^t is the predicted value at the given time t.


### 5.2. Experimental Results

The real-time rainfall prediction results by LSTM for 5 minutes is shown in Figure7. Five minutes, 10 minutes, and 15 minutes real-time rainfall are all predicted by five models. The prediction performance are shown in Table 4. Except for SVM, the performances of other algorithms are quite near. LSTM has better performance than the other machine learning models. LSTM has similar performance with ARMA in real-time rainfall prediction. This phenomenon may be inconsistent with the conclusions that LSTM much outperforms classic models in time series prediction. However, it meets the conclusion that machine learning methods such as neural networks (NNs) do not often outperform simple methods for short individual series in the paper [21].Figure 7
Five-minute rainfall prediction by LSTM.Table 4
Prediction performance of the five models.
Model
5 min
10 min
15 min
MAE
RMSE
MAE
RMSE
MAE
RMSE
ARMA
0.0280
0.0936
0.0544
0.1677
0.0849
0.2469
RF
0.0330
0.1061
0.0634
0.1879
0.0984
0.2829
SVM
0.1262
0.1421
0.2452
0.2728
0.3548
0.3965
BPNNs
0.0351
0.1040
0.0655
0.1833
0.1023
0.2832
LSTM
0.0232
0.0964
0.0450
0.1756
0.0720
0.2525The seasonal real-time rainfall prediction results for 5 minutes in autumn 2016 based on the previous seasonal rules with LSTM are shown in Figure8. The prediction performance of the four models is shown in Table 5. LSTM outperforms the other models in seasonal rainfall prediction. If the seasonal prediction exhibits large deviation, it may mean that the abnormal rainfall happens. It can be concluded that LSTM not only performs well in real-time rainfall prediction but also works well in seasonal rainfall pattern detection as shown in Tables 4 and 5.Figure 8
Five-minute rainfall prediction based on seasonal rules by LSTM.Table 5
Prediction performance based on seasonal rules by the four models.
Model
5 min
10 min
15 min
MAE
RMSE
MAE
RMSE
MAE
RMSE
RF
0.0127
0.0453
0.0239
0.0758
0.0376
0.1098
SVM
0.0776
0.0825
0.1222
0.1313
0.1619
0.1778
BPNNs
0.0146
0.0476
0.0285
0.0815
0.0418
0.1157
LSTM
0.0096
0.0430
0.0161
0.0725
0.0233
0.1027


## 5.1. Evaluation Metrics

For numeric weather prediction (NWP), several evaluation metrics have been defined to evaluate prediction performance in the paper [20]. We chose the mean absolute error (MAE) and root mean square error (RMSE) as the evaluation metrics, which are described in the following formulas:
(5)MAE=1T∑t=1Ty^t−yt,RMSE=1T∑t=1Ty^t−yt2,where T is the length of test set, yt denotes the actual rainfall data, and y^t is the predicted value at the given time t.


## 5.2. Experimental Results

The real-time rainfall prediction results by LSTM for 5 minutes is shown in Figure7. Five minutes, 10 minutes, and 15 minutes real-time rainfall are all predicted by five models. The prediction performance are shown in Table 4. Except for SVM, the performances of other algorithms are quite near. LSTM has better performance than the other machine learning models. LSTM has similar performance with ARMA in real-time rainfall prediction. This phenomenon may be inconsistent with the conclusions that LSTM much outperforms classic models in time series prediction. However, it meets the conclusion that machine learning methods such as neural networks (NNs) do not often outperform simple methods for short individual series in the paper [21].Figure 7
Five-minute rainfall prediction by LSTM.Table 4
Prediction performance of the five models.
Model
5 min
10 min
15 min
MAE
RMSE
MAE
RMSE
MAE
RMSE
ARMA
0.0280
0.0936
0.0544
0.1677
0.0849
0.2469
RF
0.0330
0.1061
0.0634
0.1879
0.0984
0.2829
SVM
0.1262
0.1421
0.2452
0.2728
0.3548
0.3965
BPNNs
0.0351
0.1040
0.0655
0.1833
0.1023
0.2832
LSTM
0.0232
0.0964
0.0450
0.1756
0.0720
0.2525The seasonal real-time rainfall prediction results for 5 minutes in autumn 2016 based on the previous seasonal rules with LSTM are shown in Figure8. The prediction performance of the four models is shown in Table 5. LSTM outperforms the other models in seasonal rainfall prediction. If the seasonal prediction exhibits large deviation, it may mean that the abnormal rainfall happens. It can be concluded that LSTM not only performs well in real-time rainfall prediction but also works well in seasonal rainfall pattern detection as shown in Tables 4 and 5.Figure 8
Five-minute rainfall prediction based on seasonal rules by LSTM.Table 5
Prediction performance based on seasonal rules by the four models.
Model
5 min
10 min
15 min
MAE
RMSE
MAE
RMSE
MAE
RMSE
RF
0.0127
0.0453
0.0239
0.0758
0.0376
0.1098
SVM
0.0776
0.0825
0.1222
0.1313
0.1619
0.1778
BPNNs
0.0146
0.0476
0.0285
0.0815
0.0418
0.1157
LSTM
0.0096
0.0430
0.0161
0.0725
0.0233
0.1027


## 6. Conclusion

The developed automatic meteorological stations based on MEMS sensors can provide high time resolution and spatial resolution weather monitoring. However, MEMS sensors suffer from stochastic error. In order to demonstrate the observed time series by MEMS sensors, STL is utilized to extract trends from the time series observed at Wuhan University. The similarity between the trend of the observed series and the trend extracted from the downloaded authoritative time series with the same weather parameter is computed according to ED and CS. High similarity illustrates that the MEMS sensors of weather can be applied to meteorological research, and their measurement is believable. LSTM is used in two manners for rainfall prediction. Real-time prediction uses the previous sequence to predict the next 5-, 10-, and 15-minute rainfall. Seasonal real-time prediction applies the rule obtained from the previous season to predict the next same season rainfall. Evaluated by MAE and RMSE, LSTM is similar to ARMA but outperforms RF, SVM, and BPNNs in the real-time prediction. LSTM also outperforms RF, SVM, and BPNNs in the seasonal real-time prediction, while ARMA cannot work. Experiment results demonstrate that LSTM is powerful in the extraction of the change rules of seasonal rainfall. Application of LSTM to the time series observed by MEMS weather sensors will provide accurate and timely rainfall prediction to support local heavy rain emergency response.



---

*Source: 6184713-2018-06-26.xml*