Example #1
0
    private bool HasInFrequentSubset(ItemSet candidate, ItemSet li, int k)
    {
        ItemSet subSet    = SubSet(candidate, k);
        ItemSet curList   = null;
        ItemSet liCurList = null;

        for (int i = 0; i < subSet.Count; i++)
        {
            curList = (ItemSet)subSet.arr[i];
            for (int j = 0; j < li.Count; j++)
            {
                liCurList = (ItemSet)li.arr[j];
                if (liCurList.Equals(curList))
                {
                    return(false);
                }
            }
        }
        return(true);;
    }
Example #2
0
 public bool ItemSetListContainsItemSet(ItemSet IS)
 {
     if (itemSetList == null || itemSetList.Count <= 0) return false;
     bool contains = false;
     foreach (ItemSet ISs in itemSetList)
     {
         if (IS.Equals(ISs)) {
             contains = true;
             break;
         }
     }
     return contains;
     //return itemSetList.Contains(IS);
 }
Example #3
0
    private ItemSet apriori(ItemSet data, double support)
    {
        ItemSet result      = new ItemSet();
        ItemSet li          = new ItemSet();
        ItemSet conList     = new ItemSet();
        ItemSet subConList  = new ItemSet();
        ItemSet subDataList = new ItemSet();
        ItemSet CurList     = null;
        ItemSet subList     = null;
        int     k           = 2;

        li.Add(new ItemSet());
        li.Add(this.FindOneColSet(data, support));

        while (((ItemSet)li.arr[k - 1]).Count != 0)
        {
            Console.WriteLine(k - 1);
            conList = AprioriGenerate((ItemSet)li.arr[k - 1], k - 1, support);
            for (int i = 0; i < data.Count; i++)
            {
                subDataList = SubSet((ItemSet)data.arr[i], k);
                for (int j = 0; j < subDataList.Count; j++)
                {
                    subList = (ItemSet)subDataList.arr[j];
                    for (int n = 0; n < conList.Count; n++)
                    {
                        ((ItemSet)subDataList.arr[j]).Sort();
                        ((ItemSet)conList.arr[n]).Sort();
                        CurList = (ItemSet)conList.arr[n];
                        if (subList.Equals(CurList))
                        {
                            ((ItemSet)conList.arr[n]).ICount++;
                        }
                    }
                }
            }

            li.Add(new ItemSet());
            for (int i = 0; i < conList.Count; i++)
            {
                ItemSet con = (ItemSet)conList.arr[i];
                if (con.ICount >= support)
                {
                    ((ItemSet)li.arr[k]).Add(con);
                }
            }

            k++;
        }
        //for (int j = 0; j < li.Count; j++)
        //{
        //    for (int h = 0; h < li.Count; h++)
        //    {
        //        if (((ItemSet)li.arr[j]).Equals((ItemSet)li.arr[h]))
        //        {
        //            li.arr.RemoveAt(j);
        //            li.Count = li.arr.Count;
        //        }
        //    }
        //}
        for (int i = 0; i < li.Count; i++)
        {
            result.Add((ItemSet)li.arr[i]);
        }
        return(result);
    }
 private bool InItemSetMap(ItemSet iset)
 {
     int status = 0;
     bool flag = false;
     while (status < ItemSetMap.Count)
     {
        if(iset.Equals(ItemSetMap.Keys.ElementAt(status)))
        {
            flag=true;
            break;
        }
        status++;
     }
     return flag;
 }