43
Intelligent Data Analysis Michael R. Berthold Frank Hoffmann Lotfi A. Zadeh cture 2 : Introduction to Fuzzy Lo

Fuzzy Logic Overview

Embed Size (px)

DESCRIPTION

Lógica Difusa

Citation preview

  • Intelligent Data AnalysisMichael R. BertholdFrank HoffmannLotfi A. Zadeh

    Lecture 2 : Introduction to Fuzzy Logic

  • Fuzzy LogicFuzzy Sets Fuzzy NumbersFuzzy OperatorsFuzzy RulesFuzzy InferenceMatlab Fuzzy Toolbox

  • ResourcesWebFuzzy & Neuro-Fuzzy Repository at the University of Southampton http://www.isis.ecs.soton.ac.uk/resources/nfinfoJournals Fuzzy Sets & SystemsIEEE Transactions on Fuzzy SystemsJournal of Approximative ReasoningIntelligent Data Analysis (electronic)

  • Resources Software / Shareware Xfuzzy (fuzzy system design, verification, synthesis) NEFCON (Matlab Simulink) UNFUZZY (C / C++) FOOL & FOX (Xwindows) Commercial Matlab Fuzzy Logic Toolbox FuzzyTECH by Inform DataEngine by MIT SieFuzzy by SIEMENS

  • Types of UncertaintyStochastic uncertainty example: rolling a dice

    Linguistic uncertaintyexamples : low price, tall people, young age

    Informational uncertainty- example : credit worthiness, honesty

  • Classical Setsyoung = { x P | age(x) 20 } characteristic function:young(x) =1 : age(x) 200 : age(x) > 20A=youngx [years]young(x)10

  • Fuzzy SetsClassical Logic

    Element x belongs to set Aor it does not:(x){0,1}A=youngx [years]A(x)10Fuzzy Logic

    Element x belongs to set Awith a certaindegree of membership:(x)[0,1]A=youngx [years]A(x)10x=23x=23

  • Fuzzy SetFuzzy Set A = {(x, A(x)) : x X, A(x) [0,1]} a universe of discourse X : 0 x 100 a membership function A : X [0,1]A=youngx [years]A(x)10=0.8x=23Definition :

  • Definitions :x(x)10abcd Normalized fuzzy set Asup x X A(x) = 1

    Uni-modal fuzzy set only one peak

  • Types of Membership Functionsx(x)10abcdTrapezoid: x(x)10Gaussian: N(m,s)msx(x)10abSingleton: (a,1) and (b,0.5)x(x)10abdTriangular:

  • Membership functionsxA(x)10abcdcore: CA:={x | A(x)=1} = [b,c]support: SA:={x | A(x)>0} = (a,d)-cut: A:={x | A(x)= }

  • Fuzzy NumbersFuzzy Numbers have restricted fuzzy sets: X = 1their core is a point: 1 x : (x)=1left and right flank of are monotonically increasing, respectively decreasingCommon choices are triangular MS-functions easy internal representation (a,b,c)x(x)10abc

  • Computing with Fuzzy NumbersAddition:A+B(x) = max{A(y), B(z) | x=y+z}x(x)10A(x)B(x)A+B(x)Multiplication: AB(x) = max{A(y), B(z) | x=yz}x(x)10A(x)B(x)AB(x)

  • The Extension PrincipleFor arbitrary functions f:f(A)(y) = max{A(x) | y=f(x)}Assume a fuzzy set A and a function f:How does the fuzzy set f(A) look like?

  • Operators on Fuzzy SetsUnionx10AB(x)=min{A(x),B(x)}A(x)B(x)x10AB(x)=max{A(x),B(x)}A(x)B(x)Intersectionx10AB(x)=A(x) B(x)A(x)B(x)x10AB(x)=min{1,A(x)+B(x)}A(x)B(x)

  • T-Norms and T-ConormsA function T : [0,1]x[0,1] => [0,1] is called a t-normiff for any u,v,w [0,1] T(u,1) = u 1 as unitu v T(u,w) T(v,w) monotonicityT(u,v) = T(v,u) commutativityT(u,T(v,w)) = T(T(u,v),w) associativityA t-norm is strict if it is strictly increasing in [0,1]x[0,1]

    Examples: min(u,v) minimum uv algebraic product

    max(0,u+v-1)bounded product

  • T-Conorms or S-normsA function S : [0,1]x[0,1] => [0,1] is called a t-conormor s-norm iff for any u,v,w [0,1] S(u,0) = u 0 as unitu v S(u,w) S(v,w) monotonicityS(u,v) = S(v,u) commutativityS(u,S(v,w)) = (S(u,v),w) associativityA s-norm is strict if it is strictly increasing in [0,1]x[0,1]

    Examples: max(u,v) maximum u+v-uv algebraic summin(1,u+v)bounded sum

  • ComplementNegation:A(x)= -1(1 - (A(x))) AA(x) 1AA(x) 0 :[0,1] -> [0,1]

    Classical law does not always hold:Example : A(x) = 0.6 A(x) = 1 - A(x) = 0.4AA(x) = max(0.6,0.4) = 0.6 1 AA(x) = min(0.6,0.4) = 0.4 0

    Negation:A(x)= 1 - A(x)

  • De Morgan LawS(u,v) = 1 T(1-u,1-v) T(u,v) = 1 S(1-u,1-v)

    S(u,v) = N(T(N(u),N(v))) : N-DualT(u,v) = N(S(N(u),N(v))) : N-Dualmax(u,v) = 1 min(1-u,1-v)uv = 1 - (1-u)+(1-v) + (1-u)(1-v)max(0,u+v-1) = 1 - min(1,1-u+1-v)

  • Operator - SpectrumdrasticproductminalgebraicsumboundedsumT-normsS-norms(T-conorms)algebraicproductmaxboundedproductdrasticsum u if v=1drastic product : T(u,v)= v if u=10 otherwise{ u if v=0drastic sum : T(u,v)= v if u=01 otherwise{

  • Cylindrical Extension Imbed a lower dimensional fuzzy set in a higher dimensional spacefuzzy set A with universe of discourse X1 and MSF mA andadditional universe X2 Definition: CX1xX2 A is called the cylindrical extension of A to the universe X1x X2 iff

    (x1,x2) X1x X2 : m CX1xX2 A(x1,x2) = mA (x1)

  • Cartesian Productfuzzy set A with universe of discourse X1 and MSF mA andfuzzy set B with universe of discourse X2 and MSF mB andDefinition: AxB is called the cartesian product of A and B to the universe X1x X2 iff

    (x1,x2) X1x X2 : m AxB (x1,x2) = min (mA (x1), mB (x2))Notice: min can be replaced by any other t-norm

  • Fuzzy Relationsclassical relation R X x Y defined by mR(x,y) = 1 iff (x,y) R 0 iff (x,y) R|{fuzzy relation R X x Y defined by mR(x,y) [0,1]mR(x,y) describes to which degree x and y are relatedIt can also be interpreted as the truth value of the proposition x R y

  • Fuzzy RelationsX = { rainy, cloudy, sunny }Y = { sun bathing, bicycling, camping, reading }X/Y sun bathing bicycling camping reading rainycloudysunny0.00.20.01.00.00.80.30.31.00.20.70.0Example:

  • Fuzzy Sets & Linguistic VariablesA linguistic variable combines several fuzzy sets.example: linguistic variable : temperaturelinguistics terms (fuzzy sets) : { cold, warm, hot }

  • Fuzzy Rulescausal dependencies can be expressed in form of if-then-rulesgeneral form: if then example: if temperature is cold and oil is cheap then heating is high

  • Fuzzy Rulebase Temperature :coldwarmhotOil price:

    cheap

    normal

    expensivehighhighmedium

    highmediumlow

    mediumlowlowHeating

  • Fuzzy Knowledge-Base

    Fuzzy Data-Base:Definition of linguistic input and output variablesDefinition of fuzzy membership functions

    Fuzzy Knowledge-BaseFuzzy Rule-Base:List of fuzzy rulesif temperature is cold and oil price is cheap then heating is high.

    x [C](x)10coldwarmhot6020

  • Fuzzy InferenceDetermine degree of membership for each term of an input variable :temperature : t=15 C oilprice : p=$13/barrel1. Fuzzification

  • Fuzzy Inference2. Combine the terms in one degree of fulfillment for the entire antecedent using a fuzzy AND: min-operatorante = min{cold(t), cheap(p)} = min{0.5,0.3} = 0.3

  • Fuzzy Inference3. Inference step: Apply the degree of membership of the antecedent to the consequent of the rule using a t-norm: min or prod operatorhigh(h)... then heating is highconsequent(h)h10high(h)ante =0.3...consequent(h)min-inference:cons. = min{ante , high } prod-inference: cons. = ante high

  • Fuzzy Inferenceh10... then heating is high... then heating is medium... then heating is low4. Aggregate all the rules consequents using the max-operator for union

  • Defuzzification5. Determine crisp value from output membership function for example using Center of Gravity-method:h10consequent(h)COG73Center of singletons defuzzification:h = Si mi Ai ci Si mi Ai

    mi = degree of membership fuzzy set iAi = area of fuzzy set i ci = center of gravity of fuzzy set i

  • Schema of a Fuzzy DecisionFuzzificationInferenceDefuzzificationtcoldwarmhotmeasuredtemperature0.20.7if temp is cold then valve is openif temp is warm then valve is halfif temp is hot then valve is closerule-basecold =0.7warm =0.2hot =0.0vopenhalfclosecrisp outputfor valve-setting0.20.7

  • Building a Fuzzy System in Matlabfis=newfis('fuzzy_heating','mamdani');fis=addvar(fis,'input','temperature',[-10 40]);fis=addvar(fis,'input','oilprice',[5 30]);fis=addvar(fis,'output','heating',[0 100]);fis=addmf(fis,'input',1,'cold','trapmf',[-10 -10 0 10]);fis=addmf(fis,'input',1,'warm','trapmf',[0 10 20 30]);fis=addmf(fis,'input',1,'hot','trapmf',[20 30 40 40]);fis=addmf(fis,'input',2,'cheap','trapmf',[5 5 10 15]);fis=addmf(fis,'input',2,'normal','trapmf',[10 15 20 25]);fis=addmf(fis,'input',2,'expensive','trapmf',[20 25 30 30]);fis=addmf(fis,'output',1,'low','trimf',[0 25 50]);fis=addmf(fis,'output',1,'medium','trimf',[25 50 75]);fis=addmf(fis,'output',1,'high','trimf',[50 75 100]);

  • Building a Fuzzy System in Matlabrulelist=[ 1 1 3 1 1 1 2 3 1 1 1 3 2 1 1 2 1 3 1 1 2 2 2 1 1 2 3 1 1 1 3 1 2 1 1 3 2 3 1 1 3 3 3 1 1];fis=addrule(fis,rulelist);showrule(fis)gensurf(fis);Surfview(fis);

    first inputsecond inputoutputrule weightoperator (1=AND, 2=OR)1. If (temperature is cold) and (oilprice is normal) then (heating is high) (1) 2. If (temperature is cold) and (oilprice is expensive) then (heating is medium) (1)3. If (temperature is warm) and (oilprice is cheap) then (heating is high) (1) 4. If (temperature is warm) and (oilprice is normal) then (heating is medium) (1) 5. If (temperature is cold) and (oilprice is cheap) then (heating is high) (1) 6. If (temperature is warm) and (oilprice is expensive) then (heating is low) (1)7. If (temperature is hot) and (oilprice is cheap) then (heating is medium) (1) 8. If (temperature is hot) and (oilprice is normal) then (heating is low) (1) 9. If (temperature is hot) and (oilprice is expensive) then (heating is low) (1)

  • Fuzzy Systems in Matlaby=evalfis([x1 x2],fis);writefis(fismatrix,heating);fis=readfis(heating);getfis(fis,input,1) Name=temperature NumMFs=3 MFLabels= cold warm hot Range= [-10 40]getfis(fis,input,1,.mf,1,params) [ -10 10 0 10]setfis(fis,input,1,mf,1,params,[-10 5 5 15]);

  • Takagi-Sugeno-Kang Fuzzy RulesMamdani rule: Outputs are fuzzy sets B if X1 is A1 and X2 is A2 Xn is An then Y is BTSK- rule: Outputs are functions f(xi) if X1 is A1 and X2 is A2 . Xn is An then Y=f(x1,x2,..xn)1. Order TSK- rule: Outputs are linear functions of xi if X1 is A1 and X2 is A2Xn is An then Y=a0 + a1x1 +anxn

  • Learning Fuzzy Rule Sets from DataAdjustable parameters in a Fuzzy Rule Set:Number,Distribution,and shape of membership functions for each attribute.consequent for each rule

    constructive or adaptive?

  • Dividing the Input SpaceGrid basedIndividual membership functions

  • Grid based Approachesequidistant grid, assign output of each tile from nearest example (Wang&Mendel 91)divide grid at point of largest error (Higgins&Goodman, 93)initialize grid equidistant, move membership functions similar to BackProp (Nauck&Kruse, 91-95)

  • Individual Rule ApproachesDerive Fuzzy Rules from Radial Basis Function Network, using Gaussian membership functions (several authors)Extract Rules directly from the data (Simpson 91, Berthold&Huber95)Extract Rules from decision trees.

  • Fine tuning Fuzzy Rule SetsHeuristics that move membership functions to minimize error (similar to Back prop)Convert Rules into Neural Network, then Train Network and afterwards extract modified rules.Use Genetic Algorithms to fine tune rules...

    *Southampton has links to Software, Journals, *Xfuzzy : Sevilla, Spain (World Championships)NEFCON : Braunschweig &Magdeburg Prof. KruseUNFUZZY : ColombiaFOOL&FOX Oldenburg*Stochastic uncertainty an event occurs with a given probability lexical or linguistic uncertainty imprecise description of an object or concept3. Informational uncertainty uncertainty caused by missing or incomplete information*Membership function also called characteristic function*Alpha cuts usual for implementation in a computer*Bounded product *Bounded sum *Center of singletons is computationally easier