Package fuzz :: Module fset :: Class FuzzySet
[hide private]
[frames] | no frames]

Class FuzzySet

source code

 object --+        
          |        
        set --+    
              |    
iset.IndexedSet --+
                  |
                 FuzzySet

Discrete fuzzy set class.

Nested Classes [hide private]
  _itemcls
Fuzzy element class.
  FuzzySetIterator
Discrete fuzzy set iterator class.
Instance Methods [hide private]
new empty set object
__init__(self, iterable=set([]))
Construct a fuzzy set from an optional iterable.
source code
FuzzySet.FuzzySetIterator
__iter__(self)
Return an iterator for this fuzzy set.
source code
int
__len__(self)
Override the length function.
source code
bool
__contains__(self, element)
Override the contents function.
source code
object
__getitem__(self, key)
Return a set item indexed by key (including those with a membership degree of zero).
source code
str
__str__(self)
String representation of a fuzzy set.
source code
list
keys(self)
Return a list of keys in the set (including those with a membership degree of zero).
source code
float
mu(self, key)
Return the membership degree of the element specified by key.
source code
FuzzySet
__or__(self, other)
Return the fuzzy union of two fuzzy sets as a new fuzzy set.
source code
FuzzySet
__ior__(self, other)
In-place fuzzy union.
source code
FuzzySet
union(self, other, norm=0)
Return the fuzzy union of two fuzzy sets as a new fuzzy set.
source code
FuzzySet
efficient_union(self, other)
Optimized version of the standard fuzzy union for large fuzzy sets.
source code
FuzzySet
__and__(self, other)
Return the fuzzy intersection of two fuzzy sets as a new fuzzy set.
source code
FuzzySet
__iand__(self, other)
In-place fuzzy intersection.
source code
FuzzySet
intersection(self, other, norm=0)
Return the fuzzy intersection of two fuzzy sets as a new fuzzy set.
source code
bool
__eq__(self, other)
Compare two fuzzy sets for equality.
source code
bool
__ne__(self, other)
Compare two fuzzy sets for inequality.
source code
bool
isdisjoint(self, other)
Report whether two fuzzy sets have a null intersection.
source code
bool
issubset(self, other)
Report whether another fuzzy set contains this fuzzy set.
source code
bool
issuperset(self, other)
Report whether this fuzzy set contains another fuzzy set.
source code
bool
__le__(self, other)
Report whether another fuzzy set contains this fuzzy set.
source code
bool
__ge__(self, other)
Report whether this fuzzy set contains another fuzzy set.
source code
bool
__lt__(self, other)
Report whether another fuzzy set strictly contains this fuzzy set,
source code
bool
__gt__(self, other)
Report whether this fuzzy set strictly contains another fuzzy set.
source code
float
overlap(self, other)
Return the degree of overlap of this fuzzy set on another fuzzy set.
source code
FuzzySet
complement(self, comp=0, **kwargs)
Return the complement of this fuzzy set.
source code
set
alpha(self, alpha)
Alpha cut function.
source code
set
salpha(self, alpha)
Strong alpha cut function.
source code
 
prune(self)
Prune the fuzzy set of all elements with zero membership.
source code
 
normalize(self)
Normalize the fuzzy set by scaling all membership degrees by a factor such that the height equals 1.
source code

Inherited from iset.IndexedSet: __setitem__, add, copy, difference, difference_update, has_key, intersection_update, symmetric_difference, symmetric_difference_update, update

Inherited from set: __cmp__, __getattribute__, __isub__, __ixor__, __new__, __rand__, __reduce__, __repr__, __ror__, __rsub__, __rxor__, __sizeof__, __sub__, __xor__, clear, discard, pop, remove

Inherited from object: __delattr__, __format__, __reduce_ex__, __setattr__, __subclasshook__

Static Methods [hide private]
 
_binary_sanity_check(other)
Check that the other argument to a binary operation is also a fuzzy set, raising a TypeError otherwise.
source code
Class Variables [hide private]
  NORM_STANDARD = 0
  NORM_ALGEBRAIC = 1
  NORM_BOUNDED = 2
  NORM_DRASTIC = 3
  COMP_STANDARD = 0
  COMP_YAGER = 1

Inherited from set: __hash__

Properties [hide private]
set support
Support, the crisp set of all elements with non-zero membership in the fuzzy set.
set kernel
Kernel, the crisp set of all elements with membership degree of exactly
float height
Height function.
float cardinality
Scalar cardinality, the sum of membership degrees of all elements.
bool normal
Returns whether the fuzzy set is normal (height = 1).

Inherited from object: __class__

Method Details [hide private]

__init__(self, iterable=set([]))
(Constructor)

source code 

Construct a fuzzy set from an optional iterable.

Parameters:
  • iterable (object) - The iterable to construct from (optional).
Returns: new empty set object
Overrides: object.__init__

__iter__(self)

source code 

Return an iterator for this fuzzy set.

Returns: FuzzySet.FuzzySetIterator
Iterator.
Overrides: set.__iter__

__len__(self)
(Length operator)

source code 

Override the length function.

Returns: int
Size of this fuzzy set.
Overrides: set.__len__

__contains__(self, element)
(In operator)

source code 

Override the contents function.

Returns: bool
True if in the set, false otherwise.
Overrides: set.__contains__

__getitem__(self, key)
(Indexing operator)

source code 

Return a set item indexed by key (including those with a membership degree of zero).

Parameters:
  • key (object) - The index of the item to get.
Returns: object
The matching item.
Overrides: iset.IndexedSet.__getitem__

__str__(self)
(Informal representation operator)

source code 

String representation of a fuzzy set.

Returns: str
String representation.
Overrides: object.__str__

keys(self)

source code 

Return a list of keys in the set (including those with a membership degree of zero).

Returns: list
List of keys in the set.
Overrides: iset.IndexedSet.keys

mu(self, key)

source code 

Return the membership degree of the element specified by key. Returns zero for any non-member element.

Returns: float
The membership degree of the specified element.

__or__(self, other)
(Or operator)

source code 

Return the fuzzy union of two fuzzy sets as a new fuzzy set.

Parameters:
  • other (FuzzySet) - The other fuzzy set.
Returns: FuzzySet
The fuzzy union.
Overrides: set.__or__

__ior__(self, other)

source code 

In-place fuzzy union.

Parameters:
  • other (FuzzySet) - The other fuzzy set.
Returns: FuzzySet
The fuzzy union (self).
Overrides: set.__ior__

union(self, other, norm=0)

source code 

Return the fuzzy union of two fuzzy sets as a new fuzzy set.

t-Conorm Types: 0 - Standard Union 1 - Algebraic Sum 2 - Bounded Sum 3 - Drastic Union

Parameters:
  • other (FuzzySet) - The other fuzzy set.
  • norm (int) - The t-conorm type to use.
Returns: FuzzySet
The fuzzy union.
Overrides: set.union

efficient_union(self, other)

source code 

Optimized version of the standard fuzzy union for large fuzzy sets.

Parameters:
  • other (FuzzySet) - The other fuzzy set.
Returns: FuzzySet
The fuzzy union.

__and__(self, other)
(And operator)

source code 

Return the fuzzy intersection of two fuzzy sets as a new fuzzy set.

Parameters:
  • other (FuzzySet) - The other fuzzy set.
Returns: FuzzySet
The fuzzy intersection.
Overrides: set.__and__

__iand__(self, other)

source code 

In-place fuzzy intersection.

Parameters:
  • other (FuzzySet) - The other fuzzy set.
Returns: FuzzySet
The fuzzy intersection (self).
Overrides: set.__iand__

intersection(self, other, norm=0)

source code 

Return the fuzzy intersection of two fuzzy sets as a new fuzzy set.

t-Norm Types: 0 - Standard Intersection 1 - Algebraic Product 2 - Bounded Difference 3 - Drastic Intersection

Parameters:
  • other (FuzzySet) - The other fuzzy set.
  • norm (int) - The t-norm type to use.
Returns: FuzzySet
The fuzzy intersection.
Overrides: set.intersection

__eq__(self, other)
(Equality operator)

source code 

Compare two fuzzy sets for equality.

Parameters:
  • other (FuzzySet) - The other fuzzy set.
Returns: bool
True if equal, false otherwise.
Overrides: set.__eq__

__ne__(self, other)

source code 

Compare two fuzzy sets for inequality.

Parameters:
  • other (FuzzySet) - The other fuzzy set.
Returns: bool
True if not equal, false otherwise.
Overrides: set.__ne__

isdisjoint(self, other)

source code 

Report whether two fuzzy sets have a null intersection.

Parameters:
  • other (FuzzySet) - The other fuzzy set.
Returns: bool
True if null intersection.
Overrides: set.isdisjoint

issubset(self, other)

source code 

Report whether another fuzzy set contains this fuzzy set.

Parameters:
  • other (FuzzySet) - The other fuzzy set.
Returns: bool
True if a subset, false otherwise.
Overrides: set.issubset

issuperset(self, other)

source code 

Report whether this fuzzy set contains another fuzzy set.

Parameters:
  • other (FuzzySet) - The other fuzzy set.
Returns: bool
True if a superset, false otherwise.
Overrides: set.issuperset

__le__(self, other)
(Less-than-or-equals operator)

source code 

Report whether another fuzzy set contains this fuzzy set.

Parameters:
  • other (FuzzySet) - The other fuzzy set.
Returns: bool
True if a subset, false otherwise.
Overrides: set.__le__

__ge__(self, other)
(Greater-than-or-equals operator)

source code 

Report whether this fuzzy set contains another fuzzy set.

Parameters:
  • other (FuzzySet) - The other fuzzy set.
Returns: bool
True if a superset, false otherwise.
Overrides: set.__ge__

__lt__(self, other)
(Less-than operator)

source code 

Report whether another fuzzy set strictly contains this fuzzy set,

Parameters:
  • other (FuzzySet) - The other fuzzy set.
Returns: bool
True if a strict subset, false otherwise.
Overrides: set.__lt__

__gt__(self, other)
(Greater-than operator)

source code 

Report whether this fuzzy set strictly contains another fuzzy set.

Parameters:
  • other (FuzzySet) - The other fuzzy set.
Returns: bool
True if a strict superset, false otherwise.
Overrides: set.__gt__

overlap(self, other)

source code 

Return the degree of overlap of this fuzzy set on another fuzzy set.

Parameters:
  • other (FuzzySet) - The other fuzzy set.
Returns: float
The overlap in [0, 1] of this set on the other.

_binary_sanity_check(other)
Static Method

source code 

Check that the other argument to a binary operation is also a fuzzy set, raising a TypeError otherwise.

Parameters:
  • other (FuzzySet) - The other argument.

complement(self, comp=0, **kwargs)

source code 

Return the complement of this fuzzy set.

Parameters:
  • comp (int) - The complement type (optional).
Returns: FuzzySet
The complement of this fuzzy set.

alpha(self, alpha)

source code 

Alpha cut function. Returns the crisp set of members whose membership degrees meet or exceed the alpha value.

Parameters:
  • alpha (float) - The alpha value for the cut in (0, 1].
Returns: set
The crisp set result of the alpha cut.

salpha(self, alpha)

source code 

Strong alpha cut function. Returns the crisp set of members whose membership degrees exceed the alpha value.

Parameters:
  • alpha (float) - The alpha value for the cut in [0, 1].
Returns: set
The crisp set result of the strong alpha cut.

Property Details [hide private]

support

Support, the crisp set of all elements with non-zero membership in the fuzzy set.

Get Method:
unreachable.support(self) - Support, the crisp set of all elements with non-zero membership in the fuzzy set.
Type:
set

kernel

Kernel, the crisp set of all elements with membership degree of exactly

Get Method:
unreachable.kernel(self) - Kernel, the crisp set of all elements with membership degree of exactly
Type:
set

height

Height function. Returns the maximum membership degree of any element in the fuzzy set.

Get Method:
unreachable.height(self) - Height function.
Type:
float

cardinality

Scalar cardinality, the sum of membership degrees of all elements.

Get Method:
unreachable.cardinality(self) - Scalar cardinality, the sum of membership degrees of all elements.
Type:
float

normal

Returns whether the fuzzy set is normal (height = 1).

Get Method:
unreachable.normal(self) - Returns whether the fuzzy set is normal (height = 1).
Type:
bool