FISDeT: Fuzzy Inference System Development Tool
- DOI
- 10.2991/ijcis.2017.10.1.2How to use a DOI?
- Keywords
- Fuzzy Inference System; Python; FCL; Open Source Software
- Abstract
This paper introduces FISDeT, a tool to support the design of Fuzzy Inference Systems, composed of a set of Python modules sharing the standard specification language FCL used for FIS definition. FISDeT includes a graphical user interface that enables easy definition and quick update of elements composing the knowledge base of a FIS. Given the knowledge base, the tool can perform the inference of fuzzy rules, providing the output of a FIS for any given input. Modules for creating a fuzzy rule base for classification and verifying the behavior of the classification system are integrated within the environment. The paper also reports applications of FISDeT to acquire available knowledge bases and create a FIS for an image processing task.
- Copyright
- © 2017, the Authors. Published by Atlantis Press.
- Open Access
- This is an open access article under the CC BY-NC license (http://creativecommons.org/licences/by-nc/4.0/).
1. Introduction
A Fuzzy Inference System (FIS) is an extension of a classical rule-based system, having IF-THEN rules with antecedents and consequents composed by fuzzy logic statements1,2. A FIS is made up of a Knowledge Base, that comprises the information used by the human expert in the form of linguistic rules, and an Inference Engine, that uses the input values and the information from the Knowledge Base to perform a reasoning process and to infer output values. FISs are suitable for solving real-world problems for which it is too difficult to obtain a mathematical model, while it is quite easy to describe the solution linguistically by means of IF-THEN rules. They have been successfully applied in many fields such as decision-making, control3, image recognition4 and non-linear system modeling5.
Despite the power of FISs for solving a wide range of problems, their implementation requires some effort and programming expertise. In the last years, many tools have been developed to enable easy design of a FIS by reducing specific expertise. Some tools have become commercially available, such as the MATLAB Fuzzy logic toolbox (www.mathworks.com), others are currently available as open source software, mainly based on Java or C++ languages (see section 2). To the best of our knowledge, no open source tool based on the Python language has been developed so far.
In this paper we present FISDeT (Fuzzy Inference System Development Tool), a novel tool aimed to facilitate the creation of a fuzzy rule-based system. The current release of FISDeT for different platforms is available at https://github.com/Fisdet/FISDeT. FISDeT is conceived as a package implemented in Python on the basis of the pyfuzzy library6. It includes two main modules, one devoted to the creation of the knowledge base and the other designed to accomplish the inference of fuzzy rules. Key aspects of the proposed tool are userfriendliness and interactivity which allow the user to define and quickly modify the fuzzy knowledge base by means of a simple and intuitive graphical interface. After fuzzy rules have been created and tested, the tool stores the created knowledge base as a source code which follows the standard FCL (Fuzzy Control Language) introduced by IEC 6113119, thus enabling portability of the created FIS on different inference systems supporting FCL.
The paper is organized as follows. Section 2 provides an overview of other existing tools for FIS design. The FISDeT tool is described in section 3. In section 4 we present the pyfuzzy library and the standard language FCL which it supports. We discuss application examples in section 5. Final remarks are presented in section 6.
2. Related works
A number of software tools have been proposed in literature to create and execute a FIS. In this section we highlight the major features of non-commercial tools in order to present FISDeT as a novel alternative in this scenario. We focus our interest on free software distributions since open source software plays an important role in the scientific research community7. We start from the analysis reported in Ref. 8 (where twenty-five non commercial packages for FIS design are considered) to outline the main features of existing tools.
Some of existing packages and libraries, such as DotFuzzy9, FRBS10, JFuzzinator11, libFuzzyEngine12, nxtfuzzylogic13 enable the design of a FIS for specific purposes. Such specific tools, even if they are simple and easy to use, usually have limited functionality. For example, they include only one membership function (typically trapezoid) and/or one defuzzification method. Hence, general-purpose tools are preferable. FisPRO14 is a general-purpose tool developed in Java that provides an interactive environment for designing and optimizing fuzzy inference systems. To our knowledge, no tool exists in the Python community that enables the design of general-purpose FISs. In this sense, we propose FISDeT as a novel Python tool for the design of a general-purpose FIS.
Concerning standardization, only few packages support the FCL language defined by the IEC 61131-7 specification. FCL is a structured language oriented to the definition of fuzzy logic-based control systems. Only a limited programming experience is required to learn and understand such a language. A number of packages can be mentioned among those currently supporting FCL: FFLL15, AwiFuzz16 and JFuzzyQT17 (they are all written in C++). However, as stated in Ref. 8, in many cases such tools present problems when trying to read FCL files. With regard to Java tools, JFuzzyLogic8 is one that correctly supports FCL. Currently there are no tools written in Python that support FCL. To this aim, we propose FISDeT as a novel Python tool supporting the FCL standard.
In short, the main deficiencies of the existing tools are: lack of standardization, difficulty in the use, special-purpose design. These are the limitations that encouraged the development of the FISDeT tool described in this paper. FISDeT has been developed by following the line of the most recent tools, being designed to provide standardization, platform independence and easy use. In addition, it represents the first tentative in the Python developers community to provide a tool supporting standard FIS design.
Recently, in Ref. 18 a deep analysis of existing software for fuzzy system development has been presented. The authors emphasize the four aspects that should guide further research directions in fuzzy systems software in the future, namely interoperability, novelty, usability, and relevance. We followed these guidelines to analyze the main strength points of FISDeT. Regarding interoperability, it is widely admitted by the fuzzy community that there is a need for a universal standard language to foster the interoperability of software for fuzzy system development18. Since FISDeT uses the FCL language to define fuzzy systems, it allows to exchange fuzzy systems across different platforms and thus improves interoperability. The novelty of a newly developed tool requires a previous analysis based on the functionality criteria of the existing software in the literature to enable researchers to identify the software needs that the current software cannot provide18. We have carried out a preliminary analysis of the existing software in the literature according to basic characteristics such as programming language, interoperability, GUI, use of FCL, general/special purpose, open-source. Table 1 shows a comparison of the FISDeT facilities with other tools reported in literature. From the analysis it emerged that: i) no software for fuzzy systems has been developed using the Python language so far; ii) there are only a few software offering a GUI for easy user interaction. FISDeT is going to introduce in the literature panorama some elements of novelty in both those respects. Regarding usability, Ref. 18 states that “the open-source model makes it easier for other researchers to develop and adapt available software to their problems and provides many advantages.” Moreover, usability is obviously enhanced whenever a tool includes visual support among its facilities. FISDeT is an open-source tool and it is equipped with a properly designed GUI, hence its usability is high. Finally, regarding relevance, we made the FISDeT software available on the Github platform so that users can download our software that we are going to keep updated. This kinds of commitments will contribute to the relevance of our tool.
Language | Platform independence | GUI | FCL | General-purpose | Open source | |
---|---|---|---|---|---|---|
AwiFuzz | C++ | ✓ | - | ✓ | - | ✓ |
DotFuzzy | C# | ✓ | - | - | - | ✓ |
FFLL | C++ | ✓ | - | ✓ | - | ✓ |
Fispro | C++/Java | ✓ | ✓ | - | ✓ | ✓ |
FRBS | C++ | ✓ | - | - | - | ✓ |
JFuzzinator | Java | ✓ | - | - | - | ✓ |
jFuzzyLogic | Java | ✓ | - | ✓ | ✓ | ✓ |
jFuzzyQt | C++ | ✓ | - | ✓ | ✓ | ✓ |
libFuzzyEngine | C++ | ✓ | - | - | - | ✓ |
nxtfuzzylogic | Java | ✓ | - | - | - | ✓ |
FISDeT | Python | ✓ | ✓ | ✓ | ✓ | ✓ |
Comparison of a number of fuzzy logic tools: the features are related to the presentation proposed in Section 2: programming language for implementation; independence from specific platforms; presence of GUI; support for the FCL standard; general-purpose conception; open source availability.
3. Architecture of FISDeT
FISDeT is conceived as a development environment with a GUI that enables easy construction of a FIS and efficient inference of fuzzy rules. Figure 1 shows the general architecture of FISDeT. It is composed of two main modules:
- •
The KBC (Knowledge Base Creator) contains a set of procedures written in Python designed to enable all the steps related to the definition of the fuzzy knowledge base (i.e., the definition of input and output variables, linguistic terms and rules). The KBC stores all these elements in FCL format, which is the common format used inside the environment when handling the FIS components. Besides manual definition of the knowledge base, the user is allowed to import an existing knowledge base in FCL format and eventually to modify its elements.
- •
The IE (Inference Engine) contains a set of procedures included in the pyfuzzy library related to the parsing of a FCL file, the importing of input data and the inference of fuzzy rules. Using a graphical interface, the outcome values of the FIS are graphically shown.
Both these modules communicate with a GUI providing a simple and intuitive access to the elements of the FIS. A detailed description of the KBC and IE modules is given in the following.
3.1. The Knowledge Base Creator
The KBC module is designed as a graphical tool to guide the user through the definition of:
- •
the input/output variables
- •
the fuzzy sets associated to each variable
- •
the fuzzy rules
To this aim, the KBC module includes two areas: the fuzzy variable area and the fuzzy rule area.
In the fuzzy variable area the user can define the name of the input/output variables, together with the linguistic terms (fuzzy sets) associated to each variable and the corresponding membership functions. To define fuzzy sets, the user can choose among three predefined types of membership functions (triangular, trapezoidal and Gaussian). With regard to the output variable, a singleton fuzzy set can also be defined. The graphical interface (depicted in Figure 2) presents the plot of fuzzy sets for each variable. The user can define/adjust the values of the membership function parameters by typing new values in the provided text areas, and confirming by clicking on the “
In the fuzzy rule area (Figure 4) the user can easily define rule’s antecedents and consequents: the IF-THEN structure of a fuzzy rule is highlighted on the screen and each antecedent (or consequent) can be defined by choosing a fuzzy term from a combo box. Once defined, a rule can be added to the knowledge base by simply clicking on the iconic “
Besides manual definition of the knowledge base, the KBC module enables the importing of an existing knowledge base stored in FCL format, thus allowing the visualization of its elements. Once the knowledge base is imported, the user can edit or delete any fuzzy set, by simply clicking on it and selecting the proper iconic button. Also, the user can access the list of rules and eventually delete some rules.
3.2. The Inference Engine
The IE module performs the standard process of rule inference. Such an inference process is accomplished on the basis of a number of subsequent steps. Firstly, the knowledge base is retrieved: the IE captures the FIS configuration by reading the involved parameters stored in a FCL file. Then the user is supposed to specify a set of input values. Finally, the engine applies the process of rule inference and calculates the output value that is brought to the attention of the user. Figure 5 shows the GUI of the inference engine.
The inference process can be also applied to a collection of input data, that can be uploaded by means of the “textscimport data” button. This enables the application of a FIS to a wide range of real-world problems for which observational data are available. Suppose that a FIS has been defined to solve a diagnosis problem. In such a case, it could be useful to perform inference of rules and obtain the outcome of the FIS for a collection of data describing a set of patients. This issue is shown in the experimental section 5.
4. Implementation of FISDeT
The implementation of FISDeT is based on the Python language. As concerns the KBN module, we developed a number of classes to implement the procedures pertaining to the fuzzy variable area and the fuzzy rule area. Figure 6 shows the class diagram related to the fuzzy variable area.
The implementation of the IE module is mainly based on pyfuzzy6, an open source library written in Python that allows the design of fuzzy controllers. One main advantage of using this library is the independence of the platform: being written in Python, pyfuzzy is compatible with any operating system. Moreover pyfuzzy provides a standardization of FIS design to the developers community since it is based on the standard Fuzzy Control Language (FCL) published by the International Electrotechnical Commission (IEC 61131-7)19. The IEC-61131 norm is well known for defining the Programmable Controller Languages, commonly used in industrial applications. All IEC-61131 languages are modular. The basic module is called Programmable Organization Unit (POU) and includes Programs, Functions or Function Blocks. A system is usually composed of many POUs, and each of these POUs can be programmed in a different language. A Function Block resembles a very primitive object. It can have multiple input and multiple output variables, can be enabled by an external signal, and can have local variables. Unlike an object, a function block only has one execution block (i.e. there are no methods). The underlying idea for these limitations is that one should be able to implement programs using either text-based or graphic-based languages. Having only one execution block allows to easily control execution when using graphic-based language to interconnect POUs.
FCL uses a single POU type called Fuzzy Inference System (FIS) which is composed of one or more Function Blocks (FBs). Each FB has variables (input, output or instance variables) as well as one or more Rule Blocks (RBs). Each rule block is composed of a set of rules, as well as Aggregation, Activation and Accumulation methods. Aggregation methods play the role of AND, OR and NOT operators for fuzzy sets. These can be Minimum, Product or Bounded difference operators. Activation methods define how rule antecedents modify rule consequents, i.e. once the IF part has been evaluated, how this result is applied to the THEN part of the rule. The most common activation operators are Minimum and Product. Finally, accumulation methods defines how the consequents from multiple rules are combined within a Rule Block. Accumulation methods defined in the standard include: Maximum, Bounded sum, Normed sum, Probabilistic OR, and Sum. All methods defined in the standard are implemented in pyfuzzy. The code reported in the following lines shows a simple FIS described using FCL.
FUNCTION_BLOCK dummy
VAR_INPUT
temperature : REAL; (* RANGE(0 .. 40) *)
end_var
var_output
output : REAL; (* RANGE(−4 .. 4) *)
end_var
fuzzyfy temperature
TERM cold := (0, 0) (0, 1) (10, 1) (19, 0) ;
TERM warm := (11, 0) (17, 1) (29, 1) (34, 0) ;
TERM hot := (29, 0) (34, 1) (40, 1) (40, 0) ;
end_fuzzyfy
defuzzyfy output
TERM high := (−4, 0) (−4, 1) (−3, 1) (0, 0) ;
TERM zero := (−2, 0) (0, 1) (0, 1) (2, 0) ;
TERM low := (0, 0) (2.5, 1) (4, 1) (4, 0) ;
ACCU:MAX;
METHOD:MaxRight;
DEFAULT := 0;
end_defuzzyfy
ruleblock temperature
AND:MIN
RULE 0:IF (temperature IS cold) THEN (output IS high);
RULE 1:IF (temperature IS warm) THEN (output IS zero);
RULE 2:IF (temperature IS hot) THEN (output IS low);
end_ruleblock
end_function_block
Only two membership functions are defined in the IEC standard: singleton and piece-wise linear. The pyfuzzy library also implements other commonly used membership functions: trapezoidal, sigmoidal, and Gaussian. Pyfuzzy implements the standard fuzzy inference process according to the Mamdani-type model. Besides different rule aggregation and activation methods, some defuzzification methods are supported, which are ‘Center of gravity’, ‘Rightmost Max’, ‘Center of area’, ‘Leftmost Max’, ‘Mean max’ (for continuous membership functions), or ‘Center of gravity’ (for discrete membership functions).
To perform the parsing of FCL code we used ANTLR v320. This is a powerful parser generator for reading, processing, executing, or translating structured text of grammatical descriptions containing actions in a variety of target languages, including FCL.
As described in this section, FISDeT is grounded on the pyfuzzy library. It should be pointed out, however, that the implementation of a GUI allows the FISDeT user to disengage from code as well as to avoid the employment of a Python IDE where some specific library must be imported. The adopted GUI enables a guided approach for building up an inference system without writing lines of code or descending into the details of some particular library.
5. Application examples
In order to illustrate the usage of FISDeT we consider a couple of employment examples. The first one concerns the use of FISDeT for the acquisition and the modification of a FIS whose knowledge base was previously extracted in an automatic way from a set of data representative of a classification problem. The second one is an example of FIS definition, i.e. the creation of a knowledge base “from scratch” by exploiting only the human experts’ knowledge.
5.1. Importing a FIS
The first example aims at showing the capability of the FISDeT tool to visualize and analyze the knowledge base of a given FIS. In this example we employed the well-known Iris dataset which deals with classification of Iris flowers and a previously defined FIS that was automatically generated from data by using the DC* algorithm21. DC* automatically extracts interpretable fuzzy rules from data by means of a double clustering process. This process preserves the multidimensional relations among data and allows to define both the minimal required granulation level for each input feature without further tuning mechanisms. The only required parameter for DC* is the number of prototypes needed for the first clustering phase, corresponding to the maximum number of fuzzy rules in the rule base. Obviously DC* is adopted here for the sake of example: any other algorithm for rule extraction can be used as well, provided that a rule representation can be obtained in the FCL standard.
Once translated in the FCL format*, the extracted fuzzy rules were imported in FISDeT (Figure 7). After the importing operation, all the FIS components are available for visualization and the inference process can be performed. FISDeT can provide the inference result for a single input sample as well as for a collection of input samples, that can be imported using the “
5.2. Creating a FIS
The second example concerns a common problem of image processing, namely contrast enhancement, which is one of the principal intensity transformations that can be applied to a digital image.
According to Ref. 22, we can express the task of enhancing the contrast of a gray-scale image by means of the following fuzzy rules:
IF a pixel is dark THEN make it darker
IF a pixel is gray THEN make it gray
IF a pixel is bright THEN make it brighter
Finally, we defined fuzzy rules using the interface provided by FISDeT (Figure 10). Once completed the definition of the knowledge base, we saved it as an FCL file†. The resulting FIS can be used to enhance the contrast of any gray-level image. Given the pixel intensities of an image, FISDeT performs inference of rules and provides new intensity values for the enhanced image. Figure 11 shows the result of applying the inference of the defined FIS to a couple of images.
6. Conclusions
In this paper, we described FISDeT, a software tool for the design of a FIS following the standard IEC 61131. FISDeT brings the benefits of open source software and standardization to the fuzzy systems community. As application examples, we used FISDeT both to acquire available fuzzy knowledge bases (related to a specific classification problem) and to design a FIS purposely conceived to tackle a specific task (related to the problem of image contrast enhancement), thus showing how FISDeT can be used to easily implement a FIS from scratch. Experimentation with the tool on such application examples leads to the conclusion that FISDeT offers a very simple and straightforward way to develop fuzzy rule-based systems for a broad variety of problems.
The effectiveness of the tool lays on an accurate design which focuses on user-friendliness and interactivity. Summarizing, its main advantages are:
- •
Standardization. FISDeT is based on the pyfuzzy library which contains the basic programming elements for the standard IEC 61131-7, which reduces programming work.
- •
Extensibility. FISDeT is an open source environment, which is of special interest for the research community.
- •
Platform independence. FISDeT can be run on any hardware and operating system configuration that supports Python.
- •
User-friendliness. The graphical interface reduces programming work and extends the range of possible users applying fuzzy systems.
The FISDeT software package is continuously being updated and improved. The current release of FISDeT for different platforms is available at https://github.com/Fisdet/FISDeT. By now the tool enables the construction of MISO Mamdanitype fuzzy systems. Further work is in progress to extend FISDeT so as to enable the definition of MIMO fuzzy systems.
Footnotes
The knowledge base extracted by DC* was translated in the FCL standard by an additional Python module purposely designed.
The FCL code for this case study is available for download at https://github.com/Fisdet/FISDeT.
References
Cite this article
TY - JOUR AU - Giovanna Castellano AU - Ciro Castiello AU - Vincenzo Pasquadibisceglie AU - Gianluca Zaza PY - 2017 DA - 2017/01/01 TI - FISDeT: Fuzzy Inference System Development Tool JO - International Journal of Computational Intelligence Systems SP - 13 EP - 22 VL - 10 IS - 1 SN - 1875-6883 UR - https://doi.org/10.2991/ijcis.2017.10.1.2 DO - 10.2991/ijcis.2017.10.1.2 ID - Castellano2017 ER -