# Real-Time Analysis of a Sensor’s Data for Automated Decision Making in an IoT-Based Smart Home

^{1}

^{2}

^{*}

## Abstract

**:**

## 1. Introduction

#### Target Scenario

## 2. Background and Preliminary Analysis

#### 2.1. Technical Background

#### 2.1.1. MIMO

#### 2.1.2. MISO

#### 2.1.3. RNN

#### 2.2. Literature Review

#### 2.3. Preliminary Analysis Using Synthetic Data

## 3. System Model

#### 3.1. Overall System Description

_{f}, needed to be selected because the decision model, s$\left(t\right),$ is based on its value. The criteria used in s$\left(t\right)$ were as follows: if all three predicted values are below ${T}_{f}$, then the decision is to turn the pump OFF, else, it is left ON for the next reading, as given in the equation below.

#### 3.2. ANN Model

_{h}) is selected by the rule of thumb, which states that the number of hidden neurons should be in the range of the number of output neurons (N

_{o}) and the number of input neurons (N

_{i}) [22]. This was further confirmed in separate experiments when the model was over-fitted with a higher number of hidden neurons and under-fitted with a lesser number. Hence, we can calculate the number of hidden neurons according to Equation (6). The number of hidden neurons calculated for each value of p is given in Table 2.

## 4. Experiments, Results, and Discussion

_{f}) value, then the pump would be turned OFF; otherwise, it would be kept ON until the next reading. The same procedure will be repeated for every reading until the pump is turned OFF by the system or by an external source. To evaluate the performance of this system, 100 cases from the flowmeter data series are extracted. The series exhibit four distinct types of behaviours, labelled as categories, which are listed in Table 4. The count of each case is also shown. Please note that the count of each category does not necessarily reflect the frequency of occurrence of each category and this factor is not relevant to the result.

_{f}which needs to be determined. The most appropriate value of (T

_{f}) was based on a combination of two factors: (i) a judgment of what is an appropriate level of flow; and (ii) determination of the accuracy of the decision support system for which several values were tested, including 0.01, 0.025, 0.05, 0.075, and 0.1. For each value of T

_{f}, the corresponding accuracies are given in Table 5. After an analysis of these two factors, it was found that the most appropriate value of T

_{f}was 0.075, which further can be confirmed by Table 5, as it gives the maximum accuracy. Next, the performances of all the models using T

_{f}= 0.075 are given in Table 6.

## 5. Conclusions

## Author Contributions

## Funding

## Conflicts of Interest

## References

- Singh, K.J.; Kapoor, D.S. Create Your Own Internet of Things: A survey of IoT platforms. IEEE Consum. Electron. Mag.
**2017**, 6, 57–68. [Google Scholar] [CrossRef] - Ivanović, M.; Kurbalija, V. Time Series Analysis and Possible Applications. In Proceedings of the 2016 39th International Convention on Information and Communication Technology, Electronics and Microelectronics (MIPRO), Opatija, Croatia, 30 May–3 June 2016. [Google Scholar]
- Mahalakshmi, G.; Sridevi, S.; Rajaram, S. A Survey on Forecasting of Time Series Data. In Proceedings of the International Conference on Computing Technologies and Intelligent Data Engineering (ICCTIDE), Kovilpatti, India, 7–9 January 2016. [Google Scholar]
- Zhang, G.; Patuwo, B.E.; Hu, M.Y. Forecasting with artificial neural networks: The state of the art. Int. J. Forecast.
**1998**, 14, 35–62. [Google Scholar] [CrossRef] - Chang, F.-J.; Chiang, Y.-M.; Chang, L.-C. Multi-step-ahead neural networks for flood forecasting. Hydrol. Sci. J.
**2007**, 52, 114–130. [Google Scholar] [CrossRef] - Campolo, M.; Soldati, A.; Andreussi, P. Artificial neural network approach to flood forecasting in the River Arno. Hydrol. Sci. J.
**2003**, 48, 381–398. [Google Scholar] [CrossRef] - Chang, L.-C.; Chang, F.-J. An efficient parallel algorithm for LISSOM neural network. Parallel Comput.
**2002**, 28, 1611–1633. [Google Scholar] [CrossRef] - Box, G.E.; Tiao, G.C. Intervention analysis with applications to economic and environmental problems. J. Am. Stat. Assoc.
**1975**, 70, 70–79. [Google Scholar] [CrossRef] - Zhang, G.P. Time series forecasting using a hybrid ARIMA and neural network model. Neurocomputing
**2003**, 50, 159–175. [Google Scholar] [CrossRef] - Hsu, K.-L.; Gupta, H.V.; Sorooshian, S. Artificial Neural Network Modeling of the Rainfall-Runoff Process. Water Resour. Res.
**1995**, 31, 2517–2530. [Google Scholar] [CrossRef] - Allende, H.; Moraga, C.; Salas, R. Artificial neural networks in time series forecasting: A comparative analysis. Kybernetika
**2002**, 38, 685–707. [Google Scholar] - Ghofrani, M.; Carson, D.; Ghayekhloo, M. Hybrid Clustering-Time Series-Bayesian Neural Network Short-Term Load Forecasting Method. In Proceedings of the North American Power Symposium (NAPS), Denver, CO, USA, 18–20 September 2016. [Google Scholar]
- Huang, Q.; Li, Y.; Liu, S. Hourly Load Forecasting Model Based on Real-Time Meteorological Analysis. In Proceedings of the 2016 8th International Conference on Computational Intelligence and Communication Networks (CICN), Tehri, India, 23–25 December 2016. [Google Scholar]
- Niu, D.; Shi, H.; Li, J. Research on Short-Term Power Load Time Series Forecasting Model Based on BP Neural Network. In Proceedings of the 2010 2nd International Conference on Advanced Computer Control (ICACC), Shenyang, China, 27–29 March 2010. [Google Scholar]
- Guo, X.; Liang, X.; Li, X. A Stock Pattern Recognition Algorithm Based on Neural Networks. In Proceedings of the Third International Conference on Natural Computation 2007 (ICNC 2007), Haikou, China, 24–27 August 2007. [Google Scholar]
- Rathnayaka, R.M.K.T.; Seneviratna, D.; Jianguo, W. A Hybrid Statistical Approach for Stock Market Forecasting Based on Artificial Neural Network and ARIMA Time Series Models. In Proceedings of the 2015 International Conference on Behavioral, Economic and Socio-cultural Computing (BESC), Nanjing, China, 30 October–1 November 2015. [Google Scholar]
- Kanchymalay, K.; Sallehuddin, R.; Salim, N. Time Series Based Forecasting for Crude Palm Oil Price Utilizing Neural Network Algorithms. In Proceedings of the 2017 6th ICT International Student Project Conference (ICT-ISPC), Skudai, Malaysia, 23–24 May 2017. [Google Scholar]
- Dash, P.K.; Ramakrishna, G.; Liew, A.C.; Rahman, S. Fuzzy neural networks for time-series forecasting of electric load. IEE Proc. Gener. Transm. Distrib.
**1995**, 142, 535–544. [Google Scholar] [CrossRef] - Horelu, A.; Leordeanu, C.; Apostol, E.; Huru, D.; Mocanu, M.; Cristea, V. Forecasting Techniques for Time Series from Sensor Data. In Proceedings of the 2015 17th International Symposium on Symbolic and Numeric Algorithms for Scientific Computing (SYNASC), Timisoara, Romania, 21–24 September 2015. [Google Scholar]
- Raeesi, M.; Mesgari, M.S.; Mahmoudi, P. Traffic Time Series Forecasting by Feedforward Neural Network: a Case Study Based on Traffic Data of Monroe. Int. Arch. Photogramm. Remote Sens. Spat. Inf. Sci.
**2014**, 40, 219–223. [Google Scholar] [CrossRef] - Attoue, N.; Shahrour, I.; Younes, R. Smart Building: Use of the Artificial Neural Network Approach for Indoor Temperature Forecasting. Energies
**2018**, 11, 395. [Google Scholar] - Panchal, G.A.G.; Kosta, Y.P.; Panchal, D. Review on methods of selecting number of hidden nodes in artificial neural network. Int. J. Comput. Theory Eng.
**2011**, 3, 332–337. [Google Scholar] [CrossRef] - Sharma, B.; Venugopalan, P.K. Comparison of neural network training functions for hematoma classification in brain CT images. IOSR J. Comput. Eng.
**2014**, 16, 31–35. [Google Scholar] [CrossRef] - Yadav, S.; Shukla, S. Analysis of k-Fold Cross-Validation over Hold-Out Validation on Colossal Datasets for Quality Classification. In Proceedings of the 2016 IEEE 6th International Conference on Advanced Computing (IACC), Bhimavaram, India, 27–28 February 2016. [Google Scholar]
- Seni, G.; Elder, J.F. Ensemble Methods in Data Mining: Improving Accuracy through Combining Predictions; Morgan & Claypool Publishers: San Rafael, CA, USA, 2010. [Google Scholar]
- Frayman, Y.; Rolfe, B.F.; Webb, G.I. Solving Regression Problems Using Competitive Ensemble Models. In Australian Joint Conference on Artificial Intelligence; Springer: Berlin/Heidelberg, Germany, 2002. [Google Scholar]
- Wichard, J.D.; Ogorzałek, M. Time Series Prediction with Ensemble Models. In Proceedings of the 2004 IEEE International Joint Conference on Neural Networks, Budapest, Hungary, 25–29 July 2004. [Google Scholar]

**Figure 12.**(

**a**) MISO for three outputs; (

**b**) MIMO with three outputs; (

**c**) RNN model (unrolled) for three outputs.

**Figure 15.**Actual vs. Predicted plot for (

**a**) one-step-ahead forecasting; (

**b**) two-step-ahead forecasting; and (

**c**) three-step-ahead forecasting.

**Figure 17.**A representative case of each (

**a**) TP (Actual & predicted decisions are ON); (

**b**) TN (Actual & predicted decisions are OFF); (

**c**) FP (Actual decision is OFF & predicted decision is ON); and (

**d**) (Actual decision is ON & predicted decision is OFF) FN are shown where X1, X2, X3, X4, and X5 are the inputs; A1, A2, A3 are actual values; and P1, P2, P3 are the three-step-ahead predicted outputs. The dotted straight line at 0.075 is the T

_{f}for decision.

Stages | MSE |
---|---|

Stage A | 0.010358 |

Stage B | 0.102454 |

Stage C | 0.009227 |

p (Lags/Number of Inputs) | N_{h} (Number of Hidden Neurons) |
---|---|

2 | 3 |

3 | 3 |

4 | 4 |

5 | 4 |

6 | 5 |

7 | 5 |

8 | 6 |

9 | 6 |

10 | 7 |

11 | 7 |

12 | 8 |

p | MSE(MISO) | MSE(MIMO) | MSE(RNN) | Average MSE | Change in Percentage |
---|---|---|---|---|---|

2 | 0.009312 | 0.009648 | 0.009143 | 0.009368 | --- |

3 | 0.008903 | 0.009359 | 0.009082 | 0.009114 | 2.71% |

4 | 0.008661 | 0.008836 | 0.008719 | 0.008739 | 4.12% |

5 | 0.008521 | 0.008615 | 0.008561 | 0.008566 | 1.98% |

6 | 0.008381 | 0.008543 | 0.008456 | 0.00846 | 1.23% |

7 | 0.008387 | 0.008443 | 0.008449 | 0.008426 | 0.39% |

8 | 0.008138 | 0.008456 | 0.008274 | 0.008289 | 1.6% |

9 | 0.008196 | 0.008458 | 0.008324 | 0.008326 | −0.44% |

10 | 0.008211 | 0.008202 | 0.008222 | 0.008212 | 1.37% |

11 | 0.008202 | 0.008131 | 0.008273 | 0.008202 | 0.12% |

12 | 0.008133 | 0.007735 | 0.008216 | 0.008028 | 2.12% |

Categories | Description | Count | Correct Decision |
---|---|---|---|

Category 1 | The cases where the EM was observed and water flow stopped. (The correct decision should be to shut off the pump). | 49 | OFF |

Category 2 | The cases where the data had a similar type of EM but the water flow did not stop. (The correct decision should be to keep the pump ON). | 18 | ON |

Category 3 | The cases where the EM was not observed at all and water flow had random fluctuations. (The correct decision should be to keep the pump ON). | 23 | ON |

Category 4 | The cases where the EM was not observed but water flow stopped anyway. (The correct decision should be to shut off the pump). | 10 | OFF |

Total | 100 |

T_{f} | Accuracy |
---|---|

0.01 | 42.00% |

0.025 | 42.00% |

0.05 | 81.00% |

0.075 | 86.00% |

0.1 | 82.00% |

Models | Accuracy | Precision | Recall | F-Measure |
---|---|---|---|---|

MIMO | 82% | 85.30% | 69.05% | 76.32% |

MISO | 82% | 83.33% | 71.43% | 76.92% |

RNN | 86% | 91.20% | 73.81% | 81.58% |

Ensemble | 84% | 88.24% | 71.43% | 79% |

Best | 86%(RNN) | 91%(RNN) | 74%(RNN) | 82%(RNN) |

Category | No. of Cases | No. of Correct Decisions | No. of Incorrect Decisions | Percentage of Correct Decision |
---|---|---|---|---|

1 | 49 | 48 | 1 | 97.95% |

2 | 18 | 10 | 8 | 55.56% |

3 | 23 | 21 | 2 | 91.67% |

4 | 10 | 7 | 3 | 70% |

Total | 100 | 86 | 14 | |

Percentage | 86% | 14% |

© 2018 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Khan, N.S.; Ghani, S.; Haider, S.
Real-Time Analysis of a Sensor’s Data for Automated Decision Making in an IoT-Based Smart Home. *Sensors* **2018**, *18*, 1711.
https://doi.org/10.3390/s18061711

**AMA Style**

Khan NS, Ghani S, Haider S.
Real-Time Analysis of a Sensor’s Data for Automated Decision Making in an IoT-Based Smart Home. *Sensors*. 2018; 18(6):1711.
https://doi.org/10.3390/s18061711

**Chicago/Turabian Style**

Khan, Nida Saddaf, Sayeed Ghani, and Sajjad Haider.
2018. "Real-Time Analysis of a Sensor’s Data for Automated Decision Making in an IoT-Based Smart Home" *Sensors* 18, no. 6: 1711.
https://doi.org/10.3390/s18061711