Interval Type-2 Fuzzy Sets Type Reduction

Mon February 3, 2020
type2-fuzzy-library type2-fuzzy fuzzy python IT2FS

Jerry Mendel’s book can be safely considered as the Type-2 Fuzzy Logic bible. It is not an easy or inexpensive read, but definitely the best way to get to know the world of Type-2 Sets.

In this post a book example, where the centroid of a number of Interval Type-2 sets was calculated is replicated using the Type-2 Library.

Type reduction in these cases is carried out by using the function it2_kernikmendel_reduce(interval_set), and a crisp set, the centroid, is returned back.


'''
This module executes the karnik-mendel type reduction 
algorithm and compares the results with those obtained 
in mendel's book

References:
-----------
Mendel, Jerry M. Uncertain rule-based fuzzy systems. 
Springer, Cham, 2017. pages 261-262
'''

import numpy as np
from numpy.random import normal
import math
import matplotlib.pyplot as plt
from type2fuzzy import IntervalType2FuzzySet
from type2fuzzy import it2_kernikmendel_reduce

def gaussian(x, mean, sigma):
  g = np.exp(-0.5*(((x - mean)/sigma)**2))
  return g

def generate_sets_uncertain_mean(m1_m2_list):
  
  it2fs_list = []
  
  x= np.linspace(0,10,101)

  for m1_m2 in m1_m2_list:
    m1 = m1_m2[0]
    m2 = m1_m2[1]

    g1 = gaussian(x, m1 ,1)
    g2 = gaussian(x, m2 ,1)
  
    hmf = np.maximum(g1,g2)
  
    one_indexes = np.where(hmf==1)[0]

    if len(one_indexes) > 1:
      hmf[one_indexes[0]: one_indexes[1]] = 1
  
    lmf = np.minimum(g1,g2)

    it2fs_list.append(
      IntervalType2FuzzySet.from_hmf_lmf(x, hmf, lmf))

  return it2fs_list

def generate_sets_uncertain_variance(m1_m2_list):
  
  it2fs_list = []
  
  x= np.linspace(0,10,101)


  for s1_s2 in m1_m2_list:
    s1 = s1_s2[0]
    s2 = s1_s2[1]

    g1 = gaussian(x, 5 ,s1)
    g2 = gaussian(x, 5 ,s2)
  
    hmf = np.maximum(g1,g2)
    lmf = np.minimum(g1,g2)

    it2fs_list.append(
      IntervalType2FuzzySet.from_hmf_lmf(x, hmf, lmf))

  return it2fs_list

def it2fs_centroid(it2fs_list):
  
  for it2fs in it2fs_list:
    centroid = it2_kernikmendel_reduce(
      it2fs, information='none', precision=4)
        print(f'Centroid: {centroid}')

# test 1 - table 9-1
# results obtained:
# [5.00000]
# [4.87498, 5.12502]
# [4.74952, 5.25048]
# [4.62265, 5.37735]
# [4.49285, 5.50715]
# [4.21675, 5.78325]
# [3.90697, 6.09303]
# [3.55194, 6.44806]
# [3.15053, 6.84947]
m1_m2_list = [(5,5), (4.875,5.125), (4.75, 5.25), 
  (4.625, 5.375), (4.5, 5.5), (4.25, 5.75), (4,6), 
  (3.75, 6.25), (3.5 ,6.5)]
it2fs_list_m = generate_sets_uncertain_mean(m1_m2_list)
print('Uncertain Mean Results')
it2fs_centroid(it2fs_list_m)
print('\n')

# test 2 - table 9-2
# results obtained:
# [5.00000]
# [4.80054, 5.19946]
# [4.60079, 5.39921]
# [4.39849, 5.60151]
# [4.18488, 5.81512]
# [3.93441, 6.06559]
# [3.59388, 6.40612]
s1_s2_list = [(1,1), (0.875,1.125), (0.75, 1.25), 
  (0.625,1.375), (0.5, 1.5), (0.375,1.625), (0.25,1.75)]
it2fs_list_v = generate_sets_uncertain_variance(s1_s2_list)
print('Uncertain Variance Results')
it2fs_centroid(it2fs_list_v)




Paper Implementation - Uncertain rule-based fuzzy logic systems Introduction and new directions-Jerry M. Mendel; Prentice-Hall, PTR, Upper Saddle River, NJ, 2001,    555pp., ISBN 0-13-040969-3. Example 9-4, page 261

October 8, 2022
type2-fuzzy type2-fuzzy-library fuzzy python IT2FS paper-workout

Type Reduction of Interval Type-2 Fuzzy Sets

April 6, 2022
type2-fuzzy type2-fuzzy-library fuzzy python IT2FS

Paper Implementation - C. Wagner and H. Hagras. 'Toward general type-2 fuzzy logic systems based on zSlices.'

A look at C. Wagner and H. Hagras. 'Toward general type-2 fuzzy logic systems based on zSlices.', working of paper examples using T2Fuzz Library
type2-fuzzy paper-workout type2-fuzzy-library fuzzy python
comments powered by Disqus


machine-learning 27 python 21 fuzzy 14 azure-ml 11 hugo_cms 11 linear-regression 10 gradient-descent 9 type2-fuzzy 8 type2-fuzzy-library 8 type1-fuzzy 5 cnc 4 dataset 4 datastore 4 it2fs 4 excel 3 paper-workout 3 r 3 c 2 c-sharp 2 experiment 2 hyperparameter-tuning 2 iot 2 model-optimization 2 programming 2 robotics 2 weiszfeld_algorithm 2 arduino 1 automl 1 classifier 1 computation 1 cost-functions 1 development 1 embedded 1 fuzzy-logic 1 game 1 javascript 1 learning 1 mathjax 1 maths 1 mxchip 1 pandas 1 pipeline 1 random_walk 1 roc 1 tools 1 vscode 1 wsl 1