java - not getting exact result in closed itemsets -


in variable total(instance of array list class) have list of frequent item sets. while finding closed frequent item sets displaying wrong result.

in intersection method going find whether 2 array lists same or not.

     arraylist close=new arraylist();                  system.out.println("total: "+total);              for(int i1=0;i1<total.size();i1++)             {                 list list1=(list)total.get(i1);                  if(close.size()==0)                 close.add(list1);                 else                 {                     list tp=intersection(list1,close);                  if(tp.size()!=0)                 close.add(list1);             }         }         system.out.println("close: "+close);      for(int i2=0;i2<total.size();i2++)         {             list list1=(list)total.get(i2);              if(close.size()!=0)             {                 for(int i1=0;i1<close.size();i1++)                 {                 list list2=(list)close.get(i1);                 list tp=intersect(list1,list2);                  if(tp.size()!=0)                 {                     if(!close.contains(list1))                     { //here hm containing list of frequent item sets support count.                          if(((integer)hm.get(list1)>(integer)hm.get(list2))&&((integer)hm.get(list1)!=(integer)hm.get(list2)))                         {                             close.add(list1);                             //system.out.println(list1+": "+hm.get(list1)+"  "+list2+": "+hm.get(list2));                         }  }                         }                         }                      }                  }   public <t> list<t> intersection(list<t> list1, list<t> list2)      {         list<t> list = new arraylist<t>();         (t t : list1)          {             list<t> list3=(list<t>)list2.get(0);             if(!list3.contains(t))              {                 return list1;             }             if(list.size()!=0)             return list1;         }         return list;     }  in total object values  total: [[1, 3, 7, 9, 12], [1, 3, 7, 9], [1, 3, 9, 12], [1, 7, 9, 12], [1, 3, 7, 12], [3, 7, 9, 12], [3, 9, 12], [3, 7, 9], [3, 7, 12], [1, 7, 12], [1, 9, 12], [ 7, 9, 12], [1, 7, 9], [1, 3, 12], [1, 3, 9], [1, 3, 7], [1, 9], [1, 12], [1, 3],  [12, 15], [1, 7], [3, 12], [7, 9], [9, 12], [7, 12], [3, 15], [3, 9], [3, 7], [ 3], [1], [7], [12], [9], [15]]  in close close: [[1, 3, 7, 9, 12], [1, 3, 9, 12], [3, 9, 12], [1, 9, 12], [1, 3, 12], [1,  3, 9], [12, 15], [3, 15], [1, 9], [1, 12], [1, 3], [3, 12], [9, 12], [7, 12], [ 3, 9], [15], [3], [1], [7], [12], [9]] 

your intersection code badly badly broken.

use unit tests.

try code on computing intersection of [1,2,3], [3,4,5].

if i'm not mistaken, returns first list.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -