Traffic Density Prediction using IoT-based Double Exponential Smoothing

ABSTRACT

The number of vehicles and currents that tend to increase causes traffic density. A system is proposed to calculate the number of vehicles and predict real-time traffic density. This research uses Haar Cascade to detect the number of cars and motorcycles and the Double Exponential Smoothing (DES) for forecasting the number of vehicles on the road. MAPE describes forecasting accuracy as a base for selecting the best smoothing constant (Alpha). The best test results from June 13 to 20, 2020, are cars on June 14, 2020 (alpha 0.5, MAPE 0%) and Motorcylecycles on June 18, 2020 (alpha 0.5, MAPE 0.1134% ). The most significant MAPE results of the car were on June 15, 2020, with alpha 0.5 and MAPE 2.1073%. The 3 minutes haar cascade detects 72.58% of cars and 81.90% of motorcycles. weights given to the most recent observations progressively lower as they move toward the oldest observations [17]. The more time has passed since the data was collected, the less importance (weight it is assigned [18]. The more recent data is given greater weight since it is considered more relevant [19]. The smoothing settings determine the weights assigned to observations [20]. Based on previous findings, When dealing with data that exhibit patterns, the single technique is often less trustworthy than the double procedure when managing the data. Therefore, this study promotes Double Exponential Smoothing (DES) as IoT based prediction system. This strategy is beneficial for predicting short-term and medium-term particularly when many outcomes are required. Data that follows a linear trend might provide support for this strategy. A system for predicting traffic density may be designed using the DES approach. In the future, this factor may decide whether the traffic density will increase or decrease. Using this forecasting technique, overcoming these challenges and roadblocks will be possible.

II. Method
The stages of research in designing a traffic density prediction system using the IoT-based double exponential smoothing method can be seen in Figure 1.

A. Data Collection
Data collection was carried out according to the source and type required. Data collection in this study was carried out using quantitative variables/data instruments. Namely, the data obtained was regularly until the end of the study. Collecting data on the number of vehicles per 3 seconds is taken by observing the Raspberry Pi test in the field as a data parameter. This 3 second timeframe are taken to handle the computation needed for the raspberry Pi. In making the haar cascade training data, the writer recorded the traffic flow through the webcam according to the test hours, then took the object of the motorcycle, bike, and car through the video frame. The results of data training were carried out on as many as 7x cars and 3x motorcycle bikes.
In this study, an application will be made to detect and count the number of vehicles per 3 seconds and display data in the form of forecasting charts on the website. The data used as training and test data are obtained in application testing during the traffic determination process and observations at the research site. The input variables used are webcam coordinates, ROI coordinates, trigger line coordinates, and alpha values.
The training data collection aims to obtain the types and patterns of vehicle objects at the test site with a ratio of 100: 1000, namely 100 positive and 1000 negative objects. The haar cascade training data results are in the form of XML files for motorcycles, bikes, and cars. Several stages of object training in this research are: • Take a positive image through the video frame

B. Haar Cascade Classifier
Haar-like feature, also known as Haar Cascade Classifier, is a rectangular (square) feature that gives a specific indication of an image [21]. The Haar cascade classifier comes from the idea of Paul Viola and Michael Jhon, hence the name Viola & Jhon method [22]. The idea of the Haar-like feature is to recognize objects based on the simple value of the feature but not the pixel value of the object's image [23]. This method has the advantage of being high-speed computation because it only depends on the number of pixels in a square, not every pixel value of an image [24]. This method is a method that uses a statistical model (classifier). The approach to detecting objects in images combines four primary keys, namely Haar-like feature, Integral Image, Adaboost learning, and Cascade Classification can be seen in Figure 5. The haar cascade process can be seen in Figure 6. The haar method requires two types of object images in the training process to detect an object. Positive samples contain the image of the object you want to detect. Positive samples contain a knife image if you want to detect a knife. Negative samples contain images other than the object that you want to recognize. Negative samples are generally in the form of background images such as walls and scenery. The resolution for the negative sample is recommended to have a camera resolution. The Haar method training uses those two types of samples [25]. The information from the training is then converted into a statistical model parameter. A Cascade classifier is a chain of stage classifiers, where each stage classifier is used to detect an object of interest in the image sub-window.

C. Double Exponential Smoothing
Double exponential smoothing (DES) is the improvement of the exponential smoothing (ES) method. The ES (Makridakis, 1999) is a continuous procedure focused on the exponential descent of priority to older objects of observation [26]. The DES method is a linear model invented by Brown. This method performs a twice-smoothing process. The DES method is usually used to predict data with trends. Moreover, data patterns are likely to rise. DES method can more efficiently model trends and levels from a time series than other methods. DES requires fewer data and uses one parameter to simplify it. However, DES requires parameter optimization, finding the most optimal α (Alpha) that takes time [27]. The steps in calculating using the DES method are as follows. Determine the First Smoothing Value ( ) as in (1).
Determine the Second Smoothing Value ( ) as in (2).
where is forecast value for period , is exponential weighting constant, is actual value of period , −1 is forecast value for period − 1, is value of DES period , −1 is value of DES -1.
Specifying a constant value (a ) as in (3).
Determining forecasting value as in (5).
where F +1 is forecasting value, and is predicted future period.

D. System Design of the Internet of Things (IoT)
Internet of Things (IoT) is a computing concept that describes the idea of everyday physical objects connected to the internet and can identify themselves to other devices [28]. IoT is significant because an object can be presented digitally as more extensive than the object itself [29]. The object is no longer only related to the user; now, it is connected to the object and its surrounding database data. In this research, the system has three stages: monitoring, process automation, and controlling.
In the monitoring process, the system will recognize the vehicle object using the haar cascade detection via a webcam installed on the Raspberry PI to determine the number of vehicles per 3 seconds. Then the data will be transferred to the database on the MySQL server via the network. Then at the Automation stage, the data in the MySQL server is taken to carry out the forecasting process using the Double Exponential Smoothing method to produce forecasting or output values on the website. The final stage is Controlling, a control system that the user can manage to make arrangements as expected of the system, anticipating the automation system if there is no traffic as desired by the user. For the software and hardware used in this system can be seen in Table 1 and  Table 2 respectively. Python IDE An application for writing unique program code for python programming language. 7 Library OpenCV A software library aimed at real-time dynamic image processing.  (6) and (7).
where is period value, is true value in period 1, and is the forecast value in the 1st period.

III. Results and Discussion
This system testing is carried out to provide an accurate system in automation and quick and easy settings for users of these systems and applications. In implementing the system, it has been tested at the place it is implemented, namely at the crossing bridge Jl. Basuki Rahmat Klojen, Malang City starting from 10:00 to 10:30 am. The system can detect cars and motorcycle bikes and inform data per 3 seconds on the website in real time. Monitoring the number of vehicles can also be done on the website application in real time, as seen in Figure 7. The detection test on the haar cascade is carried out by comparing the application calculation and manual calculations for eight days of experiment with a period of 3 minutes to obtain a comparison and an estimate of the accuracy of the calculation. Table 3 is a detection test analysis.  Table 3 shows that the manual calculation and haar cascade on June 13 to 20, 2020, takes eight days and has similar patterns. It can be concluded that car vehicle detection is outnumbered by motorcycle detection. The total of the detected car is 135, while the total of manually calculated cars is 186. Similarly, the number of motorcycles is 371 for the detected and 453 for manual calculations.
Data communication testing is done by comparing the delivery time on the Raspberry Pi with the website application to determine the accuracy of data transmission times per 3 seconds. Can be seen in Table 4.  Table 5 shows the results of the FPS test on the Raspberry Pi. The result determines the computing capabilities of the Raspberry Pi and the webcam with a resolution of 427 x 2 40. The FPS test in Table 5 is obtained every 3 seconds. The highest FPS for sending data is 17, while the lowest is 13. This experiment is carried out by comparing the classification results on each vehicle. Can be seen in Table 6.  Table 7 determines the suitability and accuracy of forecasting cars and motorbikes based on MAPE. In discussing and testing the best Alpha recommendations, we will discuss the field test result data with the best Alpha recommendations in the application to obtain a small percentage of errors in real time on cars and motorbikes. Can be seen in Table 8. In Table 8, the application recommends the best Alpha to get the smallest PE real-time value. The smallest PE car was on Sunday, June 14, 2020, at alpha 0.5 with a PE value of 0; on Friday, June 18, 2020, at alpha 0.5 with a 0.1134.
After conducting tests and trials to compare the calculation results of the system with manual calculations, the DES method has been successfully applied to the real-time traffic density detection system. It can be used as information for service planning in overcoming traffic congestion by other related parties. Prediction results of the number of vehicles detected per 3 seconds and the number of times per 10 minutes with the category of cars and motorbikes on June 13 to 20, 2020, in the direction of alun-alun malang, get the best prediction results, including cars on June 14, 2020, with alpha 0.5, MAPE 0% (perfect prediction), and motorcycles on June 18, 2020, with alpha 0.5, MAPE 0.1134% (Perfect prediction). Then the most significant MAPE results for cars were on June 15, 2020, with alpha 0.5, MAPE 2.1073% (perfect prediction), and motorbikes on June 14, 2020, with alpha 0.4, MAPE 8.5205% (predictions are perfect). In the test results, the detection of haar cascade by comparing the application and manual calculations during the test is car detection at 72.58% and motorbike detection at 81.90%. This research results give good performance and can be used for traffic prediction systems in low-specification computers such as Raspberry Pi [31] or other single-board computers.

IV. Conclusion
The findings indicate that real-time traffic density detection based on an IoT system can benefit from the application of the Haar Cascade Classifier with the DES technique. Implementation and testing of a system for detecting and monitoring vehicles at a specific location in real-time using a webcam and Raspberry Pi. The results of the detection test showed that the haar cascade algorithm was effective in detecting vehicles, but motorcycle detection was better than car detection. The data communication testing showed that the system can transmit data accurately every 3 seconds. The FPS test on Raspberry Pi demonstrated that the system's computing capabilities were sufficient for processing data in real time. The forecasting application results showed that the system's accuracy in predicting vehicles was acceptable, with some small percentage errors. The study recommends using alpha values of 0.9 for cars and 0.6 for motorcycles to reduce the percentage error in real-time monitoring of vehicles. For future research can implement another exponential smoothing like holtwinters or triple exponential smoothing method.