home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.ai.fuzzy      Fuzzy logic... all warm and fuzzy-like      1,275 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 350 of 1,275   
   Dmitry A. Kazakov to Ethan Seng   
   Re: membership functions of independent    
   29 Oct 04 11:25:40   
   
   From: mailbox@dmitry-kazakov.de   
      
   On 28 Oct 2004 16:41:46 -0700, Ethan Seng wrote:   
      
   > May I know how would the procedure differ if   
   > y is also a fuzzy variable?   
      
   You can take any crisp method and run it through with fuzzy values. The   
   result will be fuzzy. For example, if you plainly apply linear regression   
   formulae to fuzzy data the result will be fuzzy.   
      
   The following small fuzzy linear-regression test program:   
      
   --- source file test_regression.adb (Ada 95)   
   with Ada.Text_IO;          use Ada.Text_IO;   
   with Fuzzy_Floats;         use Fuzzy_Floats;   
   with Fuzzy.Edit.Floats;    use Fuzzy.Edit.Floats;   
   with Strings_Edit;         use Strings_Edit;   
   with Strings_Edit.Floats;  use Strings_Edit.Floats;   
      
   procedure Regression_Test is   
      
      type Fuzzy_Array is array (Integer range <>) of Fuzzy_Float;   
      procedure Linear   
                (  X, Y : Fuzzy_Array;   
                   A, B : out Fuzzy_Float   
                )  is   
         N      : constant Fuzzy_Float := To_Fuzzy (Float (X'Length));   
         Sum_XX : Fuzzy_Float := To_Fuzzy (0.0);   
         Sum_XY : Fuzzy_Float := To_Fuzzy (0.0);   
         Sum_X  : Fuzzy_Float := To_Fuzzy (0.0);   
         Sum_Y  : Fuzzy_Float := To_Fuzzy (0.0);   
         Iy     : Integer     := Y'First;   
      begin   
         if X'Length < 2 or else Y'Length /= X'Length then   
            raise Constraint_Error;   
         end if;   
         for Ix in X'Range loop   
            Sum_X  := Sum_X + X (Ix);   
            Sum_Y  := Sum_Y + Y (Iy);   
            Sum_XX := Sum_XX + X (Ix) * X (Ix);   
            Sum_XY := Sum_XY + X (Ix) * Y (Iy);   
            Iy := Iy + 1;   
         end loop;   
         Sum_XY := Sum_XY - (Sum_X * Sum_Y) / N;   
         Sum_XX := Sum_XX - (Sum_X * Sum_X) / N;   
         A := Sum_XY / Sum_XX;   
         B := (Sum_Y - A * Sum_X) / N;   
      end Linear;   
      
      File   : File_Type;   
      Text   : String (1..80);   
      Length : Integer;   
      X, Y   : Fuzzy_Array (1..20);   
      A, B   : Fuzzy_Float;   
   begin   
      Open (File, In_File, "regression.txt");   
      for I in X'Range loop   
         Get_Line (File, Text, Length);   
         declare   
            Line    : String renames Text (1..Length);   
            Pointer : Integer := Line'First;   
         begin   
            Get (Line, Pointer, SpaceAndTab);   
            Get (Line, Pointer, X (I));   
            Get (Line, Pointer, SpaceAndTab);   
            Get (Line, Pointer, Y (I));   
         end;   
      end loop;   
      Close (File);   
      Linear (X, Y, A, B);   
      Put_Line ("Estimated A=" & Image (A));   
      Put_Line ("Estimated B=" & Image (B));   
   end Regression_Test;   
      
   --- data file regression.txt (samples: x,y pairs)   
   1	100   
   2.3	90   
   4	80   
   4.1	77   
   5	60, 59..61:0.7, 58..63:0.5   
   6	50   
   8	40   
   9.1	44   
   10	30   
   12	37   
   12.4	35   
   13	20   
   14.7	21   
   15.2	15   
   16.8	14   
   17	10   
   19	8   
   20	6   
   20.1	3   
   21	1   
      
   estimates A and b by fitting the above samples using Ax+B. The result is:   
      
   A= (fuzzy, the membership function is a union of the weighted intervals)   
   -4.570818..-4.570690,   
   -4.592101..-4.549407:0.773,   
   -4.628232..-4.521689:0.541   
      
   B= (fuzzy)   
   89.77281..89.77450,   
   89.47732..90.06998:0.773,   
   89.10758..90.58676:0.541   
      
   In the samples above only one y (for x=5) was fuzzy.   
      
   > What kind of methods can one use for such a case?   
      
   You can take any known crisp method and "fuzzify" it, as I did in the   
   example above. That would be of course naive and maybe crude, but it should   
   work. Then there are lots of natively fuzzy ML methods: fuzzy clustering,   
   decision/model/regression trees, fuzzy-neuro etc. Have a look at PhD thesis   
   by Luis Fernando Rainho Alves Torgo:   
      
   http://www.liacc.up.pt/~ltorgo/PhD   
      
   --   
   Regards,   
   Dmitry A. Kazakov   
   http://www.dmitry-kazakov.de   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca