Techno Blender
Digitally Yours.

Machine Learning with Fuzzy Logic | by Nnamdi Uzoukwu | Jul, 2022

0 78


How to extract control rules from data using Fuzzy logic

Photo by 愚木混株 cdd20 on Unsplash

The foundation of fuzzy logic is the idea that truth can be stated as a continuum; in other words, an event is not categorically true or false, but partially true or partially false [1]. In fuzzy logic, values of system variables may be expressed in linguistic terms such as “high,” “low” and “medium,” which designate regions of interest in a data set. These linguistic expressions are called fuzzy sets (or regions). Fuzzification, then, provides a method whereby each observation is assigned a degree of belonging to each of the fuzzy sets. This allows us to develop a linguistic summarization of a numerical data set and gain an intuitive understanding of the underlying patterns. Subsequently, the generated textual model may be deployed to create control rules for making future predictions. This is why fuzzy logic has found a lot of applications in control systems.

The aim of this article is to present a straight-forward and practical method for generating fuzzy rules from numerical data. This will be illustrated with a data set containing observations of relative humidity, temperature and heat index. In the end, a numerical observation such as

will be transformed into a textual information as follows

to arrive at the rule statement:

IF relative humidity is medium and temperature is medium, THEN heat index is high

Through this logical mapping of input to output, i.e.,

fuzzy logic provides us with a powerful modelling tool — an IF-THEN rule that can be applied to predictive modelling.

Step 1: Having preprocessed the data, the domain (or the universe of discourse as commonly used in fuzzy logic) for the input and output spaces is determined.

The domain for the variables: relative humidity, temperature and heat index are the intervals defined by the minimum and maximum observations recorded.

Step 2: The intervals are divided into 3 overlapping regions using triangular functions as shown below. This now creates the fuzzy regions denoted as low, mid, and high.

Fuzzification of a numerical measurement, X. Image by author

A single measurement will belong to each of this region with a grade that ranges from 0–1. The higher this value, the greater the degree of belonging to that particular region. The sum of the membership degree of a measurement will be equal to 1. The measurement X in the figure above that lies within the interval of the length of a ruler will be fuzzified as given below.

Thus, X belongs to the set “low” with a grade of 0, and the set “mid” with a grade of 0.4 and the set “high” with a grade of 0.6

Step 3: Each observation is assigned to the region in which it has the highest membership grade. The measurement, X, above will be assigned to the region “high” and the degree is noted.

Step 4: At this point, every record in the data has been transformed into text, forming a rule. The rule degree is computed, which is the product of the membership grades of the fuzzy sets that form part of the rule. For example, the transformed observation shown below gives one rule, as has been described previously.

The rule degree, then, is the product of the grades in which the relative humidity is “mid,” the temperature is “mid,” and the heat index is “high.”

Step 5: In the final stage, a summary of the rules is constructed by obtaining one rule from a group of rules that have the same antecedent. The chosen rule is the one that has the highest rule degree; therefore, its consequent is preserved. The antecedent of a rule is the assigned membership of the input variables: temperature and relative humidity, while the consequent is that of the output variable: heat index.

To set the stage for developing Python codes, the relevant modules and the preprocessed data are imported. The data consists of 13801 training set observations. For simplicity’s sake, I represented relative humidity and the heat index using humidity and heat, respectively.

Data by AP-Channel research group, Bandung Institute of Technology

Next, the fuzzifier class — which accepts a data series and assigns the observations a grade of belonging to the fuzzy sets — is constructed. The sickit-fuzzy library is used to develop the code. The fuzz.trimf() method creates the triangular membership functions, while the fuzz.interp_membership() method assigns the observations a membership grade to the fuzzy regions.

The following codes apply fuzzification to all the variables in the data.

Relative humidity:

Temperature:

Heat index:

When the membership columns are merged, the following transformed dataset is obtained:

Finally, a summary function is created to extract the final rule set.

The data frame above describes the strongest relationships in the data. This can easily be translated into control rules as follows:

Rule 1: IF relative humidity is high and the temperature is low, THEN heat index is lowRule 2: IF relative humidity is high and temperature is medium, THEN heat index is medium
.
.
.
Rule 6: IF relative humidity is medium and temperature is medium, THEN heat index is medium

A machine learning method based on fuzzy logic has been developed to extract relationships, modelled as rules, from a dataset. The six rules obtained in this project summarize the strongest connections among the variables and could be employed to predict the heat index for an unseen piece of data collected under the same conditions — using the temperature and relative humidity — with a significant level of accuracy, while at the same time providing a linguistic snapshot of the inherent pattern in the data set. This makes fuzzy logic an important modelling tool in control systems where non-crisp inputs are required.

[1] Sickit image team (2016), Fuzzy control primer, sickit-fuzzy documentation

Data credit: The data set used for the illustration was generated by the AP channnel research group at the Bandung Institute of Technology Indonesia for a precision farming project sponsored by Dr. Acep Purqon, my thesis supervisor. It consists of 20-day measurements of temperature, relative humidity, and the heat index of a growth room where green choy sum is grown.


How to extract control rules from data using Fuzzy logic

Photo by 愚木混株 cdd20 on Unsplash

The foundation of fuzzy logic is the idea that truth can be stated as a continuum; in other words, an event is not categorically true or false, but partially true or partially false [1]. In fuzzy logic, values of system variables may be expressed in linguistic terms such as “high,” “low” and “medium,” which designate regions of interest in a data set. These linguistic expressions are called fuzzy sets (or regions). Fuzzification, then, provides a method whereby each observation is assigned a degree of belonging to each of the fuzzy sets. This allows us to develop a linguistic summarization of a numerical data set and gain an intuitive understanding of the underlying patterns. Subsequently, the generated textual model may be deployed to create control rules for making future predictions. This is why fuzzy logic has found a lot of applications in control systems.

The aim of this article is to present a straight-forward and practical method for generating fuzzy rules from numerical data. This will be illustrated with a data set containing observations of relative humidity, temperature and heat index. In the end, a numerical observation such as

will be transformed into a textual information as follows

to arrive at the rule statement:

IF relative humidity is medium and temperature is medium, THEN heat index is high

Through this logical mapping of input to output, i.e.,

fuzzy logic provides us with a powerful modelling tool — an IF-THEN rule that can be applied to predictive modelling.

Step 1: Having preprocessed the data, the domain (or the universe of discourse as commonly used in fuzzy logic) for the input and output spaces is determined.

The domain for the variables: relative humidity, temperature and heat index are the intervals defined by the minimum and maximum observations recorded.

Step 2: The intervals are divided into 3 overlapping regions using triangular functions as shown below. This now creates the fuzzy regions denoted as low, mid, and high.

Fuzzification of a numerical measurement, X. Image by author

A single measurement will belong to each of this region with a grade that ranges from 0–1. The higher this value, the greater the degree of belonging to that particular region. The sum of the membership degree of a measurement will be equal to 1. The measurement X in the figure above that lies within the interval of the length of a ruler will be fuzzified as given below.

Thus, X belongs to the set “low” with a grade of 0, and the set “mid” with a grade of 0.4 and the set “high” with a grade of 0.6

Step 3: Each observation is assigned to the region in which it has the highest membership grade. The measurement, X, above will be assigned to the region “high” and the degree is noted.

Step 4: At this point, every record in the data has been transformed into text, forming a rule. The rule degree is computed, which is the product of the membership grades of the fuzzy sets that form part of the rule. For example, the transformed observation shown below gives one rule, as has been described previously.

The rule degree, then, is the product of the grades in which the relative humidity is “mid,” the temperature is “mid,” and the heat index is “high.”

Step 5: In the final stage, a summary of the rules is constructed by obtaining one rule from a group of rules that have the same antecedent. The chosen rule is the one that has the highest rule degree; therefore, its consequent is preserved. The antecedent of a rule is the assigned membership of the input variables: temperature and relative humidity, while the consequent is that of the output variable: heat index.

To set the stage for developing Python codes, the relevant modules and the preprocessed data are imported. The data consists of 13801 training set observations. For simplicity’s sake, I represented relative humidity and the heat index using humidity and heat, respectively.

Data by AP-Channel research group, Bandung Institute of Technology

Next, the fuzzifier class — which accepts a data series and assigns the observations a grade of belonging to the fuzzy sets — is constructed. The sickit-fuzzy library is used to develop the code. The fuzz.trimf() method creates the triangular membership functions, while the fuzz.interp_membership() method assigns the observations a membership grade to the fuzzy regions.

The following codes apply fuzzification to all the variables in the data.

Relative humidity:

Temperature:

Heat index:

When the membership columns are merged, the following transformed dataset is obtained:

Finally, a summary function is created to extract the final rule set.

The data frame above describes the strongest relationships in the data. This can easily be translated into control rules as follows:

Rule 1: IF relative humidity is high and the temperature is low, THEN heat index is lowRule 2: IF relative humidity is high and temperature is medium, THEN heat index is medium
.
.
.
Rule 6: IF relative humidity is medium and temperature is medium, THEN heat index is medium

A machine learning method based on fuzzy logic has been developed to extract relationships, modelled as rules, from a dataset. The six rules obtained in this project summarize the strongest connections among the variables and could be employed to predict the heat index for an unseen piece of data collected under the same conditions — using the temperature and relative humidity — with a significant level of accuracy, while at the same time providing a linguistic snapshot of the inherent pattern in the data set. This makes fuzzy logic an important modelling tool in control systems where non-crisp inputs are required.

[1] Sickit image team (2016), Fuzzy control primer, sickit-fuzzy documentation

Data credit: The data set used for the illustration was generated by the AP channnel research group at the Bandung Institute of Technology Indonesia for a precision farming project sponsored by Dr. Acep Purqon, my thesis supervisor. It consists of 20-day measurements of temperature, relative humidity, and the heat index of a growth room where green choy sum is grown.

FOLLOW US ON GOOGLE NEWS

Read original article here

Denial of responsibility! Techno Blender is an automatic aggregator of the all world’s media. In each content, the hyperlink to the primary source is specified. All trademarks belong to their rightful owners, all materials to their authors. If you are the owner of the content and do not want us to publish your materials, please contact us by email – [email protected]. The content will be deleted within 24 hours.

Leave a comment