# Fuzzy logic for classification

I am trying to implement fuzzy logic system to classifiy a dataset with 12 inputs and 1 ouput.

I wanna understand as how to fuzzify inputs, in particular how we set intervals or segments in order to fuzzify the inputs.

Below is an example of fuzzification but the choice of the intervals is not clear.

Any suggestion or explication will be appreciated

# Generate fuzzy membership functions
qual_lo = fuzz.trimf(x_qual, [0, 0, 5])
qual_md = fuzz.trimf(x_qual, [0, 5, 10])
qual_hi = fuzz.trimf(x_qual, [5, 10, 10])


I think it would be more helpful for us if you put all yours code and language which are you using. I suppose that's are you using Python. In this case try Python library scikit-fuzzy. Some examples at the link: https://pythonhosted.org/scikit-fuzzy/auto_examples/index.html

• Yes i am using Python i will share the code once i finish Thanks a lot Jan 23, 2019 at 13:06

In general, fuzzification is a way to account for noise in data by assigning "soft labels" instead of hard ones.

For instance, imagine a binary classification problem and one example where you are not sure whether it belongs to class 0 or 1. In that case, it may be detrimental to let your model learn a hard label (either 0 or 1), since you are not sure of its true value. So you may think to shift to consider fuzzy labels, which means you consider the example as belonging to different classes with given confidence (imagine this as degree of membership or fuzzy membership).

To do that, you have to assign a number between 0 and 1 to each of the classes. Of course you have multiple options in terms of

• different mappings (i.e., functions) from classes to fuzzy membership values
• specific parametrization of the above mapping

The code you provided refers to a commonly adopted family of functions for fuzzy membership called triangular membership and it works by assigning linearly increasing/decreasing membership values around a central point in the input. You can look at this picture for a more graphical explanation (see here for more details) : The parameters determine the exact shape of the triangular function. Namely, the start of the rising path, the apex of its trajectory and the end point. Unfortunately, the choice of such parameters is application specific and there are no "magic" values that work always (at least to the best of my knowledge).