2 - WAP in Python To Perform Various Operations in Fuzzy
2 - WAP in Python To Perform Various Operations in Fuzzy
In command prompt
pip install fuzzywuzzy
Complement :
Consider a Fuzzy Sets denoted by A , then let’s consider Y be the Complement of it, then
for every member of A , Y will be:
degree_of_membership(Y)= 1 - degree_of_membership(A)
Program
# Example to Demonstrate the
# Difference Between Two Fuzzy Sets
A = dict()
Y = dict()
for A_key in A:
Y[A_key]= 1-A[A_key]
print('Fuzzy Set Complement is :', Y)
OUTPUT:
The Fuzzy Set is : {'a': 0.2, 'b': 0.3, 'c': 0.6, 'd': 0.6}
Fuzzy Set Complement is : {'a': 0.8, 'b': 0.7, 'c': 0.4, 'd': 0.4}
4. Difference :
Consider 2 Fuzzy Sets denoted by A and B, then let’s consider Y be the Intersection of them,
then for every member of A and B, Y will be:
degree_of_membership(Y)= min(degree_of_membership(A), 1- degree_of_membership(B))
Program
# Example to Demonstrate the
# Difference Between Two Fuzzy Sets
A = dict()
B = dict()
Y = dict()
OUTPUT:
The First Fuzzy Set is : {'a': 0.2, 'b': 0.3, 'c': 0.6, 'd': 0.6}
The Second Fuzzy Set is : {'a': 0.9, 'b': 0.9, 'c': 0.4, 'd': 0.5}
Fuzzy Set Difference is : {'a': 0.09999999999999998, 'b': 0.09999999999999998, 'c': 0.6, 'd':
0.5}