Fuzzy Inference System for Weather Prediction Riyaz P A Sandeep Kartha Computer Science and Engineering Mar Athanasius College of Engineering Kothamangalam, Kochi, India riyazaahil@gmail.com Computer Science and Engineering Mar Athanasius College of Engineering Kothamangalam, Kochi, India sandu999@gmail.com Gurusamy P Surekha Mariam Varghese Computer Science and Engineering Mar Athanasius College of Engineering Kothamangalam, Kochi, India gurumprp@gmail.com Computer Science and Engineering Mar Athanasius College of Engineering Kothamangalam, Kochi, India surekha@mace.ac.in Abstract—Climate change is one of the most serious environmental threats faced by mankind nowadays. It affects the livelihood of people mainly through its impact on agricultural productivity, including its direct impact on food production. Also it significantly reduces the growth rate of a faster developing country like India, where agriculture is the primary occupation of many. Among them, majorities are illiterate and deprived of computer literacy. In this context, if we are able to develop a system, which automatically predicts the rainfall for the benefit of farmers, will be very useful. The weather data, being inherently fuzzy in nature, requires highly complex processing based on human observations, satellite photography, or radar followed by computer simulations. This paper describes the idea of developing a weather prediction tool for Kerala using fuzzy inference rule based system. Keywords—Fuzzy Logic; Rainfall; Inference system;Kerala; Weather; prediction I. INTRODUCTION A weather forecast is a scientific estimate of the future state of the atmosphere where state of Weather forecast is based on a number of weather parameters. Number of parameters and their significance vary from place to place and between seasons [1]. In Kerala, the weather parameters with significant variation for weather forecasting are cloud cover, wind, temperature, humidity, pressure and precipitation. Weather prediction is very complex as it depends on various factors. In weather forecasting, a Meteorologist must know about the existing weather condition over a large area before he can make a reliable forecast. The accuracy of his forecast depends largely upon his knowledge of the prevailing weather conditions over a very wide area. The forecast decision is based on various forecasting tools. The basic tool of a weather forecaster is the Weather MAP. The weather map depicts the distribution patterns of atmospheric pressure, wind, temperature and humidity at the different levels of the atmosphere. There are two types of the basic weather map namely, the surface map and the upper-air maps. There are five standard levels of the upperair maps that are constructed twice daily at twelve-hourly interval. The surface maps are made four times daily at sixhourly intervals. II. FUZZY LOGIC Fuzzy Logic is a very powerful method to model complex and imprecise systems and is very useful for knowledge-based systems and linguistically communicated systems. Fuzzy models are very effective for representing both objective and subjective knowledge such as definitional, causal, statistical, and heuristic knowledge. Fuzzy system is very suitable for representing the weather data, which is inherently fuzzy in nature. The weather prediction statements are represented in the form of if premises then conclusion rule forms, and output is taken by using fuzzy approximate reasoning methods. Considering all these conditions, fuzzy set theory helps to manage complexity and uncertainties and gives a user- friendly visualization of the system construction and working model. Even though, there are many weather forecasting systems available, it is important to have weather prediction tool for the benefit of Kerala farmers. A general fuzzy system has basically four components: fuzzification, fuzzy rule base, fuzzy output engine, and defuzzification (Fig. 1). Fuzzification converts each piece of input data to degrees of membership by a look-up in one or more several membership functions. The key idea in fuzzy logic, in fact, is the allowance of partial belongings of any object to different subsets of the universal set instead of belonging to a single set completely. Partial belonging to a set can be described numerically by a membership function, which takes on values between 0 and 1 inclusive. Intuition, inference, rank ordering, angular fuzzy sets, neural networks, genetic algorithms, and inductive reasoning can be among many ways to assign membership values or functions to fuzzy variables. This intuitive approach is used rather commonly because it is simple and derived from the innate intelligence and understanding of human beings. Fuzzy membership functions may take on many forms, but in practical applications simple linear functions, such as triangular ones, are preferable. We used triangular membership function, trapezoidal membership function and pi membership function for our system. Fig. 1. Schematic Representation of Fuzzy Inference System The fuzzy rule base contains rules that include all possible fuzzy relations between inputs and outputs. These rules are expressed in the IF–THEN format. In the fuzzy approach, there are no mathematical equations and model parameters. All the uncertainties, nonlinear relationships, or model complications are included in the descriptive fuzzy inference procedure in the form of IF–THEN statements. There are basically two types of rule systems, namely, Mamdani and Sugeno [3]. Depending upon a problem under consideration, a user can choose the appropriate rule system. According to the Sugeno rule system, the consequent part of the fuzzy rule is expressed as a mathematical function of the input variable and such a system is more appropriate for neurofuzzy systems [4]. In the Mamdani rule system, however, the consequent part of the fuzzy rule is also expressed as verbally. Mamdani model is used for this system. Defuzzification converts the resulting fuzzy outputs from the fuzzy inference engine to a number. There are many defuzzification methods, such as COG, bisector of area (BOA), mean of maxima (MOM), left-most maximum (LM), and rightmost maximum (RM), etc. [3]; [6]. The MOM, LM, and RM methods disregard the shape of the fuzzy set and hence they are employed in particular problems [3]. The BOA method picks the abscissa of the vertical line that divides the area of the combined output fuzzy subset in two equal halves. In the COG method the crisp output value is the abscissa under the center of gravity of the combined output fuzzy subset. The COG method is the most commonly used defuzzification method [3]. III. RELATED WORK Weather is naturally ambiguous and uncertain in nature and historically weather data has been used as an indicator to analyze the impact of climate on human activity and vice versa. Weather event predictions are performed on weather data generally for farmers, flood, drought, traffic control and cyclone updates, etc. to help all stakeholders avoid losses and gain financial benefits. Case-based reasoning has been employed to forecast airport weather. A rough set based fuzzy inference system has been used to perform weather prediction. Association rules have been extracted to discover the abnormal weather phenomena as well as to make weather prediction. Fuzzy Logic approach has been adopted to predict weather. Weather prediction has been used for traffic controlling applications. Fuzzy expert systems have been employed to forecast winds and predict weather. Forecasts for the present case can be based on similar past cases using the analog method. Many researchers have applied fuzzy logic for more accurate prediction of weather conditions such as lightning [18], temperature [19], solar radiation [19], cloud ceiling heights and horizontal visibility [18], flood [20], thunderstorm [21], drought [24], traffic control [25] and cyclone [22] etc. Many of them are focused on specific areas such as lightning prediction for South Korea [18], cloud visibility at the airports of Canada [19], temperature prediction for Bombay city [18] used fuzzy logic based rule based reasoning based on five parameters relative humidity, total cloud cover, wind direction, temperature and surface pressure to predict rainfall events for two Egyptian meteorological stations. These researches prove that fuzzy logic is desirable to merge the experiences of forecasters and theoretical studies with efficiency and the accuracy of the computer systems. [19]. All these systems have used fuzzy system as a viable alternative to the classical complex; costly and time-consuming weather prediction techniques. Other soft computing techniques are also used for rainfall prediction. Guhathakurta has used ANN for monsoon rainfall prediction in different districts of Kerala [23]. IV. METHODOLOGY This system is based on modeling, analysis, synthesis and simulation of various weather factors. Main component of this weather prediction is fuzzy model implemented in the MATLAB 2009b software. First the input variables are defined, then the model calculates the value from these input variables based on the defined rules and returns output variable called Rainfall. This variable is useful for farmers. In order to keep the model as simple as possible only three attributes were used for each variable – low, medium and high except for seasons. These rules record the basic relationships that have been determined from the analysis of the past data and from the values of input variables in the key past situations. We were looking for a simple algorithm or method that could be used by farmers who are not skilled enough to use complicated weather prediction system. Many of the decision support methods were not reliable or simple enough. That led us to do this research where a simple model with several input variables. After the rules have been defined the surface viewer can be used to visualize the dependency between input variables and the output variable. Fig. 2. Fuzzy Inference System (FIS) Editor with Input and Output Variables of Weather Prediction System A. Data Collection The weather details of Kochi from January 2012 to December 2012 are collected. This collection includes the temperature, humidity, wind speed, total cloud and monsoon details. The data is collected from India Meteorological Department [14]. 2. The input variable humidity has three linguistic variables low, medium and high(Fig 4). The minimum is taken as 0 % and maximum is taken as 100 %. Low linguistic variable using TrapMF and other variables using TriMF. B. Data Analysis The collected data is analyzed to find the range of low, medium and high values of temperature, humidity, wind speed and total cloud. C. Fuzzification of Input/Output parameters There are different kinds of membership functions are available in Fuzzy Inference System. Using linguistic variables represents the variables of FIS. Three linguistic variables namely “low”, “medium” and “high” are used in this system. There are five input variables and one output variable for our system. Input variables are Temperature, Humidity, Wind speed, Total cloud and Seasons. Output variable is Rainfall and shown in Fig.2. Fig. 4. Membership Function Plots of Input Variable Humidity. 3. The input variable wind speed has three linguistic variables low, medium and high. The minimum numerical value is taken as 0 kmph and maximum numeric value is taken as 50 kmph. All linguistic variables are using TriMF. 1. The input variable temperature has three linguistic variables low, medium and high (Fig 3). The minimum numeric value is taken as -10◦C and maximum numeric value is taken as 50◦C. All linguistic variables are using TriMF. Fig. 5. Membership Function Plots of Input Variable Wind Speed. 4. The input variable total cloud has three linguistic variables low, medium and high. The minimum numerical value is taken as 0 octa and maximum numeric value is taken as 15 octa. All linguistic variables using TriMF. Fig. 3. Membership Function Plots of Input Variable Temperature. E. Inferencing This prediction system is using the mamdani inference model. Mamdani type inference, expects the output membership functions to be fuzzy sets. After the aggregation process, there is a fuzzy set for each output variable that needs defuzzification. A common and useful defuzzification technique is Centre of gravity (COG) method. A sample fuzzy rule developed is Fig. 6. Membership Function Plots of Input Variable Total Cloud. 5. The input variable seasons have four variables winter, summer, southwest monsoon and northeast monsoon. All variables are using PiMF. There are 4 seasons in a year in Kerala. E.g.: IF ((Temperature is LOW) AND (Humidity is HIGH) AND (Wind Speed is HIGH) AND (Total Cloud is HIGH) AND (Seasons is Southwest monsoon) THEN (Rainfall is HIGH). V. IMPLEMENTATION AND RESULT This system is implemented in MATLAB 2009b. The specific and generic rules are inserted via rules editor. The input to the system is automatically taken, that’s why the system named as automated. The system date is converting into the seasons input. The surface view of interaction between two input variables with the output variable rainfall is shown below. Fig. 7. Membership Function Plots of Input Variable Seasons. 6. The output variable rainfall has four linguistic variables no rain, low, medium and high. All variables are using TriMF. Fig. 9. Interaction of Total Cloud and Humidity. Fig. 8. Membership Function Plots of Output Variable Rainfall. D. Rule Generation Analyzing the collected data from the Internet, books and newspaper and we develop the rules for this fuzzy inference system. Insert the rules into FIS via rules editor in MATLAB. Different research papers are analyzed for the weather prediction system. There are two types of rules - generic and specific rules. In this system, a variety of rules are using for more accurate output. Fig. 10. Interaction of Seasons and Total Cloud. Fig. 11. Interaction of Seasons and Humidity. Fig. 14. Performance of our system.The Y-axis represents the amount of rainfall in mm and X-axis represents the days in june 2014. some days small variations are occurred. Overall, the performance of our system is good. VII. FUTURE WORK Now a days smartphones have different kinds of sensors like temperature sensor, humidity sensor etc. Make this system better by leveraging the smartphones. Weather prediction is influence by lot of factors. The height of place is one of the important factors. Adding more input factors to the system will provide more accurate results. Fig. 12. Interaction of Temperature and Total Cloud. VIII. CONCLUSION Fuzzy inference system will be useful for farmers in Kerala to know about the rainfall. Rainfall has a dramatic effect on agriculture. Different plants need varying amount of rainfall to survive. The amount of rainfall is dependent on number of factors. The fuzzy inference system incorporates the different aspects and ambiguities in these factors for accurate prediction of rainfall. It is observed that the incorporation of fuzzy improved the accuracy of the system to a great extent. REFERENCES Fig. 13. Interaction of Wind speed and Total Cloud. VI. [1] PERFORMANCE EVALUATION The rainfall data of Kochi is collected from IMD website of June 6 to June 12 in 2014. The performance our system with the actual data is shown as a Line graph in Fig.14. We compare our result with the actual result from the IMD Thiruvanthapuram results.Fig.14 illustrates the evaluation. In [2] [3] [4] Riyaz P.A., Sandeep Kartha, Gurusamy P., Surekha Mariam Varghese. “Automated Fuzzy Logic Weather Prediction System”, proceedings of National Conference on New trends in Electronics, Computing and Communication(NTECC 2014), April, 2014. Agboola A.H., Gabriel A.J., Aliyu E.O., Alese B.K. “Development of a Fuzzy Logic Based Rainfall Prediction Model”, International Journal of Engineering and Technology Volume 3 No. 4, April, 2013. Gokmen Tayfur and Vijay P Singh, “ANN and Fuzzy Logic Models for Simulating Event-Based Rainfall-Runoff”, Journal of Hydraulic Engineering, ASCE, Vol. 132, No. 12, December 1, 2006. Sen, Z. “Fuzzy modelling in engineering.” Class notes, Civil Engineering Faculty, Istanbul Technical Univ., Istanbul, Turkey in Turkish, 1999 [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] Chang, L. C., Chang, F. J. & Tsai, Y. H.,Fuzzy exemplar-based inference system for flood forecasting. Water Resour. Res. 41, W02005, doi:10.1029/2004WR003037, 2005 Benmiloud T, “Improved adaptive neuro-fuzzy inference system”. Neural Comput Appl 21:575–582, 2012 L. A. Zadeh, “Fuzzy sets”, Information and Control, vol. 8, no. 3, (1965), pp. 338–353 Matlab: v7.9.0 (R2009b), 2009. Documentation, the MathWorks, Inc. Mamdani E.H. and Assilian S. ,"An experiment in linguistic synthesis with a fuzzy logic controller" International Journal of Man-Machine Studies, Vol. 7, No. 1, pp. 1-13., 1975 Mitra, A.K., Nath, Sankar, Sharma, A.K.,“Fog forecasting using rulebasedfuzzy inference system.” Journal of the Indian Society of Remote Sensing, 36, 243–253., 2008 Arnaud, P., Fine, J.A., Lavabre, J.,. “An hourly rainfall generation model applicable to all types of climate.” Atmospheric Research 85, 230–242., 2007 Edvin and Yudha, “Application of Multivariate ANFIS for Daily Rainfall Prediction: Influences Of Training Data Size”: Makara, Sains, Volume 12, No. 1, April 2008: 7-14 7. B.K.Hansen,Weatherpredictionusingcasebasedreasoningandfuzzysettheory, Master of Computer Science Thesis, Technical University of Nova Scotia, Canada, 2000. India Meteorological Department’s web-site :www.imd.gov.in Wong, K.W., Wong P.M., Gedeon T.D. and Fung C.C., “Rainfall prediction model using soft computing technique”: Soft Comput. Fusion Foundat. Methodol. Appli.7:434-438, 2003 T.J. Ross, Fuzzy Logic with Engineering Applications, 2nd edition, Wiley Black- well, 2004. Kuk, Bongjae, Hongil Kim, Jongsung Ha, Hyokeun Lee, Gyuwon Lee, A Fuzzy Logic Method for Lightning Prediction Using Thermodynamic and Kinematic Parameters from Radio Sounding Observations in South Korea, Weather and Forecasting, Volume 27, 205–217, Feb 2012. [18] Dipi A. Patel and R.A. Christian, Proposed Framework of Temperature Prediction Using Clustering Based Fuzzy Logic, Global Journal of Engg. & Appl. Sciences, 3 (1), pp:1-3 , 2013 [19] Bjarne Hansen, A Fuzzy Logic–Based Analog Forecasting System for Ceiling and Visibility, pp:1319- 1330, weather and forecasting, Volume 22, December 2007. [20] Shu, C., Ouarda, T.B.M.J., 2008. Regional flood frequency analysis at ungauged sites using the adaptive neuro-fuzzy inference system, Journal of Hydrology, Volume 349, pp: 31–43, January 2008. [21] Pin-Fang Lin, Pao-Liang Chang, Ben Jong-Dao Jou, James W. Wilson, Rita D. Roberts. (2012) Objective Prediction of Warm Season Afternoon Thunderstorms in Northern Taiwan Using a Fuzzy Logic Approach. Weather and Forecasting 27:5, 1178-1197, October 2012 [22] D. Sarewitz, A.R. Pielke, R. Byerly,Prediction: Science, Decision Making and the Future of Nature,Island Press (2000) [23] Guhathakurta, P., Long-range monsoon rainfall prediction of 2005 for the districts and sub-division Kerala with artificial neural network,Current Science 90, 773–779, 2006 [24] W.H. Quinn, D.O. Zopf, K.S. Short, R.T.W. Kuo-Yang, Historical trends and statistics of the southern oscillation, El Nino, and Indonesian droughts Fishery Bulletin, 76(3) , pp. 663-677, 1978. [25] B. Krause, C. von Altrock, M. Pozybill,Fuzzy logic data analysis of environmental data for traffic control, Proceedings of the Sixth IEEE International Conference on Fuzzy Systems, vol. 2 , pp. 835–838, 1997. [26] Somia A. Asklamy, Khaled Elhelow, I.K Youssef, M.Abd El-Wahab, Rainfall events prediction using rule-based fuzzy inference system, Atmospheric Research , pp: 228–236, Elsevier, 2011. [27] Malik Shahzad Kaleem Awan, Mian Muhammad Awais, “Predicting weather events using fuzzy rule based system”,Applied Soft Computing 11 (2011) 56–63, Elsevier [28] Jantzen, J. “Design of fuzzy controllers.” Technical Rep. No.98-E864, Dept. of Automation, Technical Univ. of Denmark,Denmark, 1999.