1
1
import matplotlib .pyplot as plt
2
2
import numpy as np
3
+ from dataclasses import dataclass
4
+ """
5
+ By @Shreya123714
3
6
7
+ #How fuzzy set is created using FuzzySet Class
8
+ >>>me = FuzzySet("Sheru",0.4,1,0.6)
9
+ >>>me.__str__()
10
+ 'Sheru: [0.4, 1, 0.6]'
11
+ >>>me
12
+ FuzzySet(name='Sheru', left_boundary=0.4, peak=1, right_boundary=0.6)
13
+ >>>s = FuzzySet("Siya",0.5,1,0.7)
4
14
15
+ #Union Operations
16
+ >>>s.union(me)
17
+ FuzzySet(name='Siya ∪ Sheru', left_boundary=0.4, peak=0.7, right_boundary=1.0)
18
+
19
+ #Intersection Operation
20
+ >>>s.intersection(me)
21
+ FuzzySet(name='Siya ∩ Sheru', left_boundary=0.5, peak=0.6, right_boundary=1.0)
22
+
23
+ #Complement Operation
24
+ >>>s.complement()
25
+ FuzzySet(name='¬Siya', left_boundary=0.30000000000000004, peak=0.5, right_boundary=0)
26
+ """
27
+
28
+
29
+ @dataclass
5
30
class FuzzySet :
6
31
"""
7
32
A class for representing and manipulating triangular fuzzy sets.
@@ -21,22 +46,26 @@ class FuzzySet:
21
46
this fuzzy set.
22
47
plot(): Plot the membership function of the fuzzy set.
23
48
"""
24
-
25
- def __init__ (
26
- self , name : str , left_boundary : float , peak : float , right_boundary : float
27
- ) -> None :
28
- """
49
+ name : str
50
+ left_boundary : float
51
+ peak : float
52
+ right_boundary : float
53
+
54
+ # def __init__(
55
+ # self, name: str, left_boundary: float, peak: float, right_boundary: float
56
+ # ) -> None:
57
+ """
29
58
Initializes a triangular fuzzy set with the given parameters.
30
59
Args:
31
60
name (str): The name or label of the fuzzy set.
32
61
left_boundary (float): The left boundary of the fuzzy set.
33
62
peak (float): The peak (central) value of the fuzzy set.
34
63
right_boundary (float): The right boundary of the fuzzy set.
35
- """
36
- self .name = name # Fuzzy set name
37
- self .left_boundary = left_boundary # Left boundary
38
- self .peak = peak # Peak value
39
- self .right_boundary = right_boundary # Right boundary
64
+ """
65
+ # self.name = name # Fuzzy set name
66
+ # self.left_boundary = left_boundary # Left boundary
67
+ # self.peak = peak # Peak value
68
+ # self.right_boundary = right_boundary # Right boundary
40
69
41
70
def membership (self , x : float ) -> float :
42
71
"""
0 commit comments