I am playing around with a way to structure fuzzy data using python. I am really wondering about some applications of such data.
It looks like I would have to do Type 2 fuzzy logic in order to get real fuzziness, because if a value isn't in the set that I have created (which is crisp) then am I to think that the value still doesn't belong to the set?
Here is the code:
#Only Integers right now
# Need backwards fuzziness (hi to low)
# Need to handle float ranges
cold = [1,213]
hot = [90,100]
funny = [8,10]
close = [0,5]
joes_distance = 1
joes_funniness = 9
def membership(x,List):
return (float(x)-List[0])/(List[-1]-List[0])
def Is(x,List):
print membership(x,List)
return x in range(List[0],List[-1]+1)
print Is(joes_distance,close)
print Is(93,hot)
if Is(joes_funniness,funny):
print "Joe is %s funny"%membership(joes_funniness,funny)
else:
print "Joe is not funny at all"
def get_fuzzy_values(List,Label):
for i in range(List[0],List[-1]+1):
print str(i) + " is " + str((float(i)-List[0])/(List[-1]-List[0])) + " " + Label
get_fuzzy_values(cold,"Cold")
So for an object to be considered close, it has to be in the range of 0-5. But is an object that is 5.1 units away not close? Well, it is still close, but to another degree. So, using any sort of boolean logic seems futile when trying to keep everything fuzzy. Perhaps I should consider the extremes to be only the values in consideration?
Anything that has any temperature is both hot and cold, but to various degrees of hot and cold (how do you work with this type of logic).
At any rate, I am still wondering about some possible applications of the current structure I have in an AI system. Or perhaps in a game at all.
I know my code is probably unnecessarily elaborate, but I am just toying with ideas right now.