Esempio n. 1
0
        protected ItemSet <T> Union(ItemSet <T> is1, ItemSet <T> is2)
        {
            ItemSet <T> c = is1.Clone();

            c.Add(is2[is2.Count - 1]);

            foreach (long id2 in is2.TransactionIDList)
            {
                bool isFound = false;
                foreach (long id1 in is1.TransactionIDList)
                {
                    if (id1 == id2)
                    {
                        isFound = true;
                        break;
                    }
                }

                if (isFound)
                {
                    c.TransactionIDList.Add(id2);
                }
            }
            return(c);
        }
Esempio n. 2
0
        private int Mine(FPTree fpTree, ItemSet anItemSet)
        {
            int    minedItemSets = 0;
            FPTree projectedTree;

            projectedTree = fpTree.Project(anItemSet.GetLastItem());
            minedItemSets = projectedTree.FrequentItems.Count;
            foreach (Item anItem in projectedTree.FrequentItems)
            {
                ItemSet nextItemSet = anItemSet.Clone();
                nextItemSet.AddItem(anItem);
                minedItemSets += Mine(projectedTree, nextItemSet);
            }
            return(minedItemSets);
        }
        public void TestResultSet()
        {
            List<MyPoint> set1 = new List<MyPoint>();
            set1.Add(new MyPoint(0, 0));
            set1.Add(new MyPoint(1, 1));
            set1.Add(new MyPoint(2, 2));
            set1.Add(new MyPoint(5, 0));
            set1.Add(new MyPoint(6, 1));
            set1.Add(new MyPoint(7, 2));

            ItemSet iSet1 = new ItemSet();
            ItemSet iSet2 = new ItemSet();

            iSet1.Add(0);
            iSet1.Add(2);
            iSet1.Add(4);

            iSet2.Add(1);
            iSet2.Add(3);
            iSet2.Add(5);

            Results2 r2 = new Results2();
            r2.AddResult(iSet1.GetIndices());

            Results2 r3 = r2.Clone();
            r3.AddResult(iSet2.GetIndices());

            Assert.AreEqual(2, r3.Count);
            Assert.AreEqual(1, r2.Count);

            ItemSet iSet3 = iSet1.Clone();
            iSet3.Add(1);
            iSet3.Add(3);
            iSet3.Add(5);

            Assert.AreEqual(3, iSet1.Count);
            Assert.AreEqual(6, iSet3.Count);
        }
        public void SpeedTest2()
        {
            ItemSet seta = new ItemSet();
            seta.SetUp(10);

            for (int i = 0; i < 100000; ++i)
            {
                MyList<MyPoint> set1 = new MyList<MyPoint>();
                set1.Add(new MyPoint(1, 6));
                set1.Add(new MyPoint(2, 6));
                set1.Add(new MyPoint(5, 6));
                set1.Add(new MyPoint(3, 6));
                set1.Add(new MyPoint(2, 5));
                set1.Add(new MyPoint(3, 5));
                set1.Add(new MyPoint(5, 5));
                set1.Add(new MyPoint(3, 4));
                set1.Add(new MyPoint(3, 7));
                set1.Add(new MyPoint(6, 4));

                ItemSet workSet = seta.Clone();
                ItemSet currentLine = new ItemSet();

                currentLine.Add(0);
                currentLine.Add(1);
                LineParams par = new LineParams(set1[0], set1[1]);

                workSet.RemoveAt(0);
                workSet.RemoveAt(1);

                for (int k = 0; k < workSet.Count; ++k)
                {
                    int id = workSet.GetItemIndex(k);
                    if (par.IsCollinear(set1[id]))
                    {
                        currentLine.Add(id);
                        workSet.RemoveAt(id);
                    }
                }
            }
        }