예제 #1
0
        public FPTree(IInputDatabaseHelper inDatabaseHelper, float minSup)
            : this()
        {
            minimumSupport      = minSup;
            inputDatabaseHelper = inDatabaseHelper;

            float temp = minimumSupport * inputDatabaseHelper.TotalTransactionNumber;

            minimumSupportCount = (int)temp;
            if (temp % 1 != 0)
            {
                minimumSupportCount++;
            }

            CalculateFrequentItems();
            frequentItems = frequentItems.OrderByDescending(x => x.SupportCount).ToList();// Xong B1.1

            inputDatabaseHelper.OpenDatabaseConnection();
            List <string> aTransaction = new List <string>();

            do
            {
                aTransaction = inputDatabaseHelper.GetNextTransaction();
                if (aTransaction.Exists(x => x != "y" && x != "?"))
                {
                    continue;
                }
                InsertTransaction(aTransaction);
            }while (aTransaction.Count > 0);
            inputDatabaseHelper.CloseDatabaseConnection();
        }
예제 #2
0
        public int CreateFPTreeAndGenerateFrequentItemsets(
            IInputDatabaseHelper _inputHelper, IOutputDatabaseHelper _outHelper, float minSup)
        {
            outputDatabaseHelper = _outHelper;
            var    watch   = System.Diagnostics.Stopwatch.StartNew();
            FPTree _fpTree = new FPTree(_inputHelper, minSup);

            fpTree = _fpTree;
            int totalFrequentItemSets = GenerateFrequentItemSets();

            watch.Stop();
            outputDatabaseHelper.WriteAggregatedResult(minSup, totalFrequentItemSets, (double)watch.ElapsedMilliseconds);
            return(totalFrequentItemSets);
        }
예제 #3
0
파일: FPTree.cs 프로젝트: tokichie/fp
        public FPTree(IInputDatabaseHelper inDatabaseHelper, float minSup)
            : this()
        {
            minimumSupport      = minSup;
            inputDatabaseHelper = inDatabaseHelper;

            minimumSupportCount = (int)(minimumSupport * (float)inputDatabaseHelper.TotalTransactionNumber);

            CalculateFrequentItems();
            frequentItems = frequentItems.OrderByDescending(x => x.SupportCount).ToList();

            inputDatabaseHelper.OpenDatabaseConnection();
            List <string> aTransaction = new List <string>();

            do
            {
                aTransaction = inputDatabaseHelper.GetNextTransaction();
                InsertTransaction(aTransaction);
            }while (aTransaction.Count > 0);
            inputDatabaseHelper.CloseDatabaseConnection();
        }
예제 #4
0
 public AprioriAlgorithm(IInputDatabaseHelper _inDatabaseHelper, IOutputDatabaseHelper _outDatabaseHelper, int _minimumSupportCount)
     : this(_inDatabaseHelper, _outDatabaseHelper)
 {
     MinimumSupportCount = _minimumSupportCount;
 }
예제 #5
0
 //constructor
 public AprioriAlgorithm(IInputDatabaseHelper _inDatabaseHelper, IOutputDatabaseHelper _outDatabaseHelper)
 {
     inputDatabaseHelper  = _inDatabaseHelper;
     outputDatabaseHelper = _outDatabaseHelper;
     MinimumSupport       = 0f;
 }