3.7.2. Membership Function

For taking decision on the input crisp values, a triangular membership function is used in our approach. The function of fuzzy sets that are achieved by crisp values of linguistic variables and show the relationships of these crisp values to the set are divided as a membership function. It is actually degree of truth that occurs between 0 and 1. There are many different kinds of membership functions, i.e., triangular MF, Trapezoidal MF, Gaussian MF, etc. It is used to plot the values of non-fuzzy sets to linguistic fuzzy sets.

Triangular Membership Function: In our research we use a triangular membership function which describes in fuzzy membership functions approach as shown in Figure 5. Fuzzy logic involves precise logical operations and these are little bit unlike those used in logic of approximate degree of truth, they are conjunction, disjunction and negation. In order to ge<sup>t</sup> the smallest values from the all available fuzzy variables, we use a minimum function known as conjunction.

**Figure 5.** Graphical representation of Triangular Membership Function.

Figure 5 shows a triangular membership function. For example, we take three fuzzy variables a, b and m and also with their truth values of 0.3, 0.6 and 0.9, correspondingly; as shown in Equation (4):

$$a \uparrow b \uparrow m = \min(a; b; m) = 0 \text{:} \mathbf{3} \tag{4}$$

Just like the last solved example, we take the max function now just as we find the min function. Here, disjunction involves the maximum function as shown in Equation (5):

$$a \, \_-b \, \_-m = \max(a; b ; m) = 0 ; \theta . \tag{5}$$

In our research, we use a triangular membership function. We use this membership function because it maintains three variables and creates a relation between them. Here we categorize sentiments analysis score into three linguistic terms that identifies the sentiment scoring of reviews. These linguistic variables are used for evaluating customer loyalty. These terms are Positive (*a*), Negative (*b*), Neutral ( *m*). Here we take only the subjective reviews for sentiment analysis because subjective reviews can easily state the opinion of the consumer. Here we prefer triangular membership function also known as trimf because we take three linguistic variables, i.e., *a*, *b* and *x*, where trimf describe by a lower limit *a*, an upper limit *b*, and a value *c*, where *a* < *c* < *b* as shown in Equation (6).

$$\text{Triangular}(\mathbf{x}; a, b, m) = \begin{cases} \mathbf{x} < a & \text{0} \\ a \le \mathbf{x} \le m & \frac{(\mathbf{x} - \mathbf{a})}{(m - a)} \\ m \le \mathbf{x} \le b & \frac{(b - \mathbf{x})}{(b - m)} \\ m \le \mathbf{x} & \text{0} \end{cases} \tag{6}$$

where *a*, *b* and *m* represent the x-coordinates for triangle, *x* represents the crisp value from the isolated variable fuzzy universe of discourse. We classified the sentiment score into three parts:


We use these sentiment scores in order to evaluate loyalty of customers towards online products. In our proposed method, we use three types of loyalty which distinguish how much the consumer is loyal towards the product and services and their values lies according the fuzzy logic triangular membership function.


Here we take three different types of customer loyalty which are denoted by triangular membership functions as shown in Equation (7):

$$LO(\mathbf{x}) = \begin{cases} \text{if } 0.0 \le \mathbf{x} < 0.3 & \text{PseudoLogality} \\ \text{if } 0.3 \le \mathbf{x} < 0.7 & \text{LatentLoyalty} \\ \text{if } 0.7 \le \mathbf{x} \le 1.0 & \text{TrueLoyalty} \end{cases} \tag{7}$$

Fuzzy Rules Based System: Three most common types of fuzzy rule based systems, which are named as Mamdani, Sugeno, Tsukamoto, etc. These first two kinds of fuzzy rule-based systems are used to executed on regression problems and the output of these systems is a real value, and the third type is used to implement to problems which relates to categorization. We use Mamdani inference system in our research.

Mamdani Fuzzy Inference System: Mamdani fuzzy inference system is proposed by Ebrahim Mamdani it in 1975. It is most general and highly useful approach used in the research methods. It was the first control system constructed by the use of fuzzy set theory. It has six basic stages:


In this study, we use Mamdani fuzzy inference: Mamdani systems are instinctive that means it is usually based on what a person feels about something to be true even without knowing a reasonable answer. It is fully appropriate to human input.

We used Mamdani rule based systems which is being implemented on MATLAB. When we plot a graph for membership functions, the curve of membership function is built in MATLAB and it is used to plot membership values between 0 and 1 where 0 shows the starting point and 1 is the peak point. The values occurs between 0 and 1 represents that how input is plotted to membership function value. The membership function for sentiment analysis is given in Equation (8):

$$A = \{ \mathbf{x}, p\_A(\mathbf{x}), o\_A(\mathbf{x}), n\_A(\mathbf{x}) \mid \mathbf{x} \in X \}\tag{8}$$

where "*x*" is the review taken from the file, "*pA*(*x*)" is the membership of positive reviews, *oA*(*x*) is the membership of neutral reviews and *nA*(*x*) is the membership of negative reviews.

We take sentiment analysis as an input, which shows that the value lies between


We plot a graph showing these sentiment values and terms by using MATLAB which is given below:

By taking the input linguistic variables- Sentiment analysis score. The Figure 6 shows indicates that Sentiment analysis score greater 0.7 is positive. Hence, all scores lie between 0.7 and 1 will always be positive.

Fuzzy Rules: The backbone of any fuzzy logic system is its fuzzy rules. By using these rules, we can easily describe the controlled output and the conclusion is taken. These are simple IF-ELSE rules. Suppose we have a variable x included in the problem (which is our sentiment score), so the loyalty output has its own membership function which is low, medium and high e.g., when we apply rules (shown in Table 6), it will give:



**Figure 6.** The triangular fuzzy membership function plot for sentiment analysis as inputs.

Table 6 defines rules which are written in the form of given technique in MATLAB. The given figure shows that if our sentiment score is positive, i.e., it lies in the values between 0.7 to 1, then our loyalty is true.

By following these rules, suppose the degree of membership for *x* is 0.45 to the MF medium, then the loyalty will be also 0.45 medium.
