{'fraction_non_alphanumeric': 0.02323825955680164, 'fraction_numerical': 0.016660376341187253, 'mean_word_length': 4.476232654266313, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
A Weighted Fuzzy Time Series Forecasting Model

In this paper we describe a new automatic partitioning method and a first order weighted fuzzy time series forecast ing model. First, we show that our automatic fuzzy partitioning method provides an accurate approximation to the original time series. The fuzzy sets extracted from our partitioning are grouped to create a rule-base that will be used in forecasting. We found that the accuracy of our first order model is improved when an ordered weight ing averaging operator is applied. The model presented in this paper does not attempt to produce the most accurate forecasting results, when compared with other more complex higher order models. Our goal is to show that there is still space for improvement when simple first order forecasting models are used. Our results show that the combination of a simple partitioning method, a first order model, and an averaging operator is still capable of out performing not only the first order models that have proposed in the literature but also other higher order models.


Introduction
Forecasting is essential in decision making for domains such as financial markets, planning for energy production to satisfy future electricity demand and other economic and engineering applications. The current forecasting models include those based on optimization and statistics such as auto regression and hidden Markov chains and the methods based on computational intelligence techniques. Among these are artificial neural networks (ANN), support vector regression, evolutionary computing and fuzzy logic. The forecasting models vary in features, complexity, accuracy and applicability.
Among these methods ANN have shown very accurate results 1 .
This paper is about fuzzy time series forecasting. Forecasting models based on fuzzy logic, employ rules, relations, or operators 2 to create mathematical or com-Indian Journal of Science and Technology, Vol 11(27) putational models capable of forecasting approximately future events, based on its past history. Fuzzy forecasting models have been applied in many domains such as: predicting university enrollments 3-10 , stock market indexes 11 , temperature prediction 12 and energy demand 13 .
The idea of using fuzzy time series in forecasting, was originally proposed by Song and Chissom 3 . The timevariant and time-invariant models described in their series works were tested on the problem of forecasting student enrollments at the University of Alabama.
Chen in 5 introduced a simplified procedure aimed at reducing the high computational overhead of his previous work and proposed a high order fuzzy time series model that showed significantly better results than its first order counterpart described in 4 .
The literature on fuzzy time series has recognized that some of the main factors that affect a model's performance are the number and length of the fuzzy intervals Keywords: Aggregation Operators, Fuzzy Logic, Time Series Forecasting and the content of the rules used. To address with these issues, Chen and Chung in 7 proposed a high order fuzzy time series model that uses genetic algorithms to optimize the fuzzy interval lengths. A similar procedure was proposed by Kuo et al. in 9 , using particle swarm optimization (PSO). A more recent research described in 14 employs also PSO to adjust and optimize the lengths of intervals in the universe of discourse.
More recently 15 , proposed to use clustering techniques to determine the optimal number and length of the intervals. In 16 a method based on intuitionist fuzzy sets is proposed to deal with the uncertainty in non-deterministic time series. All previous models require the use of more sophisticated rule production and selection methods, the use of optimization techniques or of extensive training and tuning to achieve the highest performance in prediction.
In this paper we propose a Weighted Fuzzy Time Series Forecasting model (WFTSF). First, we describe a simple automatic method to partition the time series into fuzzy intervals. Next, we discuss rule extraction and forecasting and explain how an Order Weighted Average (OWA) operator can improve our model.
Our experimental results show that in spite of its simplicity, our WFTSF model is capable of outperforming some of the more complex models reported in the literature.
Our model was tested using three datasets: the Alabama enrollment dataset 4 (with 22 entries), an energy demand dataset (with 12 entries) described in 13 and SBI, a stock market time series described in 6 . Our model was implemented using R programming language.
The rest of the paper is organized as follows. Section 2 provides an overall description of our proposed algorithm. Section 3 demonstrates how the proposed algorithm is used to extract and weight the forecasting rules. Section 4 presents experimental results. Finally, in section 5, we provide our conclusion.

Algorithm Overview
Our fuzzy time series model takes as input the time series datasets and provides as output the forecasts.
The algorithm is divided into two main components: fuzzification and rule forecasting.
The fuzzification component consists of six steps, where the first four steps are for data preprocessing and the last two comprise the fuzzification process itself. The ultimate goal of fuzzification is to generate a series of fuzzy sets or interval partitions and to establish associations between the fuzzy sets and the values in the dataset.
After the fuzzification process is completed, data is further processed by the rule forecasting component. In this stage, fuzzy sets are grouped into patterns and then transformed into forecasting rules. Finally, the rules are defuzzified and the forecasting is performed.
To compare forecasting performance with other models, we used the mean squared error (MSE) and mean absolute percentage error (MAPE). These measures are defined by the equations:

MSE MAPE
where A i and F i denote the actual output and forecast output at t i , respectively.
The following sections explain in detail the fuzzification and rule forecasting processes performed by our algorithm.

Fuzzifying Data
The proposed procedure for fuzzification can be described as the following six step process: • Sort the values in ascending order.
• Compute the average distance between any two consecutive element values • Eliminate outliers.
• Recalculate the new average distance between any two remaining consecutive values.
First, the values in the historical dataset are sorted in ascending order to ease processing. Then the average distance between any two consecutive element values in the sorted dataset is computed. The average distance is obtained by the following equation: , where p is a permutation that sorts the values in ascendant order i.e.
The standard deviation is computed as: . ( Both the average distance and standard deviation are used in step 3 of our method to detect possible outlier values in the sorted dataset. The goal of this step is to eliminate these values from the calculation of the average distance. We defined arbitrarily an outlier as a value that is less than or larger than one standard deviation from the average i.e all values not in value−σ ≤ average ≤ value + σ.
After the elimination of outliers, the average distance value is recalculated using the values remaining in the sorted dataset. This is the step 4 of the fuzzification process. The recalculated average distance is used in steps 5 and 6 to partition the universe of discourse into a series of trapezoidal fuzzy sets.
In step 3, the universe of discourse is defined by finding its lower and upper bounds, i.e. locating the largest and lowest values in the dataset. These values are subsequently adjusted by: (1) subtracting the average distance from the lowest value and (2) adding the average distance to the highest value.
More formally, if D max and D min are the highest and lowest values in the dataset, respectively, and AD is the average distance, the universe of discourse, U, is defined as: Once U has been determined, the fuzzy sets can be defined with symmetrical trapezoidal functions defined by points (a 1 ,a 2 ,a 3 ,a 4 ). In symmetrical trapezoidal functions the distance between any pair of adjacent points in the core and support of the membership function has the same length e.g. a 2 −a 1 = a 3 −a 2 =a 4 −a 3 .
The trapezoidal membership function µ A of a given fuzzy set A is obtained with the following equation: The range R is computed as: where UB and LB denote the upper bound and lower bound of U respectively.
All generated trapezoidal membership functions have the same segment lengths AD. Therefore, using this average distance ls = AD,c= AD and rs= AD, as is shown in Figure 1.
To calculate the number of fuzzy sets n defined over U we employ: The trapezoidal membership function procedure we have described is similar to the one in 8 . However, there are some important differences with our approach. For instance, in 8 , the number of sets is fixed and the segment length S is calculated solving equation 6 for S. Contrarily, in our approach we calculate the number of sets that will be needed in the problem with Equation 6 and use, as the segment length S, the recalculated average distance.
Finally, instead of using the standard deviation to find the universe of discourse, as is done in 8 , we use the recalculated average distance as is shown in Equation 3.

Fuzzification Example
In the following example we will fuzzify the first four years (1971 -1974) of student enrollment at the University of Alabama, to illustrate how the fuzzification process is performed by our method. The values to be fuzzified are 13055, 13563, 13867 and 14696.
First, since the sequence of these values is already in ascending order, the sorting step is omitted. The average distance and the standard deviation for this data set are calculated as: and Next, outliers i.e. values that are less than or larger than one standard deviation from AD, are discarded. In our example only values satisfying the condition: 547 −216 ≤ x ≤ 547 + 216 are used to recalculate a new average distance. In this example, the only value that satisfies the above condition is 508. Thus the recomputed average distance AD R , and the segment length S, are both set to 508. The idea of eliminating outliers is to avoid that the fuzzy partitions could be skewed by these values.
At   Once the universe of discourse and the parameters n, R and S are determined, we generate the fuzzy sets as shown in Table 1 and Figure 2.
As shown in Table 1, points a 1 , a 2 , a 3 and a 4 are used to represent the trapezoidal fuzzy sets A 1 and A 2 . Note that the difference between the pairs of points |a 1 −a 2 |, |a 2 −a 3 | and |a 3 −a 4 |, representing the three segments of a trapezoidal fuzzy sets in Table 1 and Figure 2, is not exactly 508. This is because our algorithm adapts the segment length so that the lowest value in the dataset always appears as the left bound of the crisp interval, and the highest value in the dataset always appears as the right bound of the crisp interval.
From Table 1 and Figure 2 it can be seen that the lowest of the four values (i.e. 13055), appears as the lower bound of the first crisp interval u 1 , and the highest value (i.e. 14696), appears as the upper bound in the second crisp interval, u 2 . Generally, these values will not be matched due to rounding errors occurring as a result of applying Equations 1 and 6. Therefore our algorithm has to adjust slightly the segment lengths to fit into the universe of discourse. Now we are able to fuzzify the first four historical enrollments according to membership functions A 1 and A 2 , defined by: and As Figure 3 indicates, the boundaries of A 1 and A 2 generally overlap. For instance, this happens in the case of the enrollment for year 1973, which was 13867. This element has a partial degree of membership in both sets A 1 and A 2 .
The membership degree of element 13867 in A 1 is 0.5155 ≈ 0.52, and in A 2 , it is 0.4845 ≈ 0.48. Hence the enrollment for 1973 is fuzzified as A 1 since its membership degree is higher in this set. If the membership degree was exactly 0.5, the element will be associated to either The results of fuzzifying the first four years of enrollment in the University of Alabama are shown in Table 2.

Fuzzifying the Dataset
Using the same procedure applied in the example from previous section, we derive the trapezoidal membership functions of the entire Alabama enrollment dataset from 1971 to 1992, shown in Table 3.
Similarly the fuzzified annual enrollments are listed in Table 4. It is important to remark that when assigning the fuzzy sets in Table 4, we have used full knowledge of the time series, to find the fuzzy set in which these values have maximum membership degree, as shown in Table 3.
From fuzzified data in Table 4, we get the first order relationships in Table 5.
Where A j → A k may be interpreted as A j being the current state at time t i−1 and A k the next state at time t i of a fuzzy time series. Using these simple rules with one antecedent and one consequent, we can approximate the fuzzy time series by deffuzifying the output. This is done by calculating the centroid of the fuzzy sets at time t i . Calculating the centroid consists in finding the midpoint m i of the core interval in the membership function u i , given by m i = (a 2 + a 3 )/2, since the membership functions are symmetrical trapezoids defined by A i = (a 1 ,a 2 ,a 3 ,a 4 ). Our model obtained MAPE=9609.4 and MSE=0.50%. These results represent the optimal maximum forecasting accuracy that we can expect to obtain with our proposed partitioning method.

Rule Forecasting
To perform forecasting we need to find composed rules that will solve the ambiguities in the rule base. This is done by grouping all rules that have the same antecedent or current state. After this grouping we get the following simple and composed rules in Table 3: To perform forecasting, we use the process suggested in 4 consisting in applying two basic principles.

Principle 1: For matching single rules:
Ai → Aj where A i is the fuzzified number for year i. We forecast a value for time t i +1 associated with fuzzy set A j by calculating the centroid or midpoint m j in fuzzy number A j .

Principle 2: For matching composed rules:
where A i is the fuzzified number for year i. This means that the forecasting value for time t i + 1 will be calculated as the aggregated value of the midpoints of the fuzzy sets {j,k,..,m}.
To apply these principles we need to train our model to extract the fuzzy sets and rules in the time series as was described in section 3.1.
Forecasting for time t i + 1 consist in finding the rule that has fuzzy set A i associated to time t i as its antecedent. Once the rule is found we apply Principles 1 or 2. It must be noted that once a forecast for time t i +1 is produced and the real value is known, the time series is updated to include the new value. The updated time series is then fuzzified again using the six fuzzification steps to create a new rule base. The new rule base is then used to forecast a value for time t i+2 . This process continues for the rest of forcasts.
Forecasting with composed rules, is done by calculating the average of the centroids in the consequent of the rules. This works well when the time series changes smoothly i.e. when the difference between the centroids used in the composed rules is small. However, if the difference is large, the average may not be a good representation for all the values in the antecedent. Additionally, if the same rule is applied at several time intervals we will get repeated forecasting values. To add flexibility in forecasting, we need a way to change our forecasts according to how close the centroids in the consequent of a rule are. For this purpose we may use an OWA operator 17 . A17 (18956,19147,19337,19531) Table 4. Fuzzified Annual Enrollments age using an orness value of 1/2. These orness values are aimed at moving the forecasts closer to the largest centroid value. The orness of 3/4, was chosen since its associated weights in the OWA operator can be easily calculated using an analytical closed form described by 18 , with the following equation, for Orness=3/4:

Fuzzy Set Trapezoid Function
Our model applies the following rule to decide which orness value should be used in a composed rule such as where gcentroid is the resulting centroid, R is the range of the time series as defined by Equation 5 and avd is the average distance or segment length of the trapezoidal functions. We call our automatic partitioning method together with the application of the principles 1 and 2, and the OWA operator our WFTSF model. Table 7 shows a comparison of the results obtained by WFTSF with other higher order models that have been optimized. The table shows that WFTSF model outperforms the first order models in 4,8 but also the higher order models in 5,19,20 in terms of MAPE and MSE. The rest of Table 6. Disambiguated rule base. Table 5. First order relations extracted from the time series the higher order algorithms perform better than WFTSF due to the use of higher order models and optimization techniques.

Algorithm Evaluation
We also applied our model to the time series of electricity demand reported in 13 , where our model obtained MAPE = 68563 and MSE = 4.77, which shows that with half of the data we used in the University of Alabama dataset, the model increases MAPE significantly. Finally, we tested our model with the time series of the daily stock exchange price of SBI reported in 6 . Our model obtained MSE = 1255.46 and MAPE = 0.90 whereas the more complex method described in 6 obtained a significantly better result with MSE = 782.46.

Conclusions
In this paper we have presented a new and simple first order fuzzy time series forecasting model that generates automatically a partition of the universe of discourse in intervals, using the variations observed in the datasets. We also show that its forecasting accuracy can be improved with an OWA operator. Our experiments show that WFTSF, outperforms in forecasting accuracy not only the results obtained by other first order models, but also some higher order models in terms of MAPE and MSE. Our future work includes designing a more accurate and higher order model based on optimizing the weights applied to the rules.

Chen[4] order=1
Cheng [ Table 7. Results of different first and higher order models