public static void Test_Arff_CountFrequency()
        {
            string tmp = "";
            MessageBox.Show("Use Weather Nominal.arff");
            using (OpenFileDialog newOFD=new OpenFileDialog())
            {
                if (newOFD.ShowDialog() == DialogResult.OK)
                {
                    tmp = newOFD.FileName;
                }
            }
            Arff tmp2 = new Arff(File.ReadAllText(tmp));

            Condition c1 = new Condition("outlook", "overcast");
            //Condition c2 = new Condition("temperature", "hot");
            //Condition c3 = new Condition("humidity", "high");
            List<Condition> c = new List<Condition>(); c.Add(c1);
            //c.Add(c2);
            //c.Add(c3);

            int count=tmp2.CountFrequency(new Item(c, 0));

            MessageBox.Show(string.Format("{0} appears {1} times",
                c1.ToString(), count));
        }
        public FPTree(Arff source, int minimumCoverage, int maximumItemSetSize, double minimumAccuracy, int resultSize)
        {
            //load input
            Source = source;
            MinimumCoverage = minimumCoverage;
            MaximumItemSetSize = maximumItemSetSize;
            MinimumAccuracy = minimumAccuracy;
            ResultSize = resultSize;

            //initiate Root
            Root = new FPTreeNode();

            //local variables
            ItemSet ItemSet;
            ItemSet HighFrequencyOneItemSet;
            FPTreeTable FPTreeTable;

            //get the size 1 ItemSet
            ItemSet = new ItemSet(Source);

            //initiate High Frequency 1-item set
            HighFrequencyOneItemSet = ItemSet.DeepCopy();
            HighFrequencyOneItemSet.MeetMinimumCoverage(MinimumCoverage);
            HighFrequencyOneItemSet.OrderByFrequencyDescending();

            //initiate FPTreeTable
            FPTreeTable = new FPTreeTable(Source, HighFrequencyOneItemSet);

            //build FPTree
            BuildFPTreeFromRoot(FPTreeTable);
        }
 public static void Test_ItemSet_ItemSetConstructor()
 {
     string tmp = "";
     using (OpenFileDialog newOFD = new OpenFileDialog())
     {
         if (newOFD.ShowDialog() == DialogResult.OK)
         {
             tmp = newOFD.FileName;
         }
     }
     Arff tmp2 = new Arff(File.ReadAllText(tmp));
     ItemSet tmp3 = new ItemSet(tmp2);
 }
 public static void Test_FPTree_Constructor()
 {
     string path = "";
     using (OpenFileDialog newOFD = new OpenFileDialog())
     {
         if (newOFD.ShowDialog() == DialogResult.OK)
         {
             path = newOFD.FileName;
         }
     }
     Arff source = new Arff(File.ReadAllText(path));
     FPTree FPTree = new FPTree(source, 6, 0, 0, 0);
 }
        public ItemSet(Arff source)
        {
            Source = source;
            Items = new List<Item>();

            foreach (var attribute in source.Attributes)
            {
                var valueList = attribute.Data.Select(i => i.Value).OrderBy(i=>i).GroupBy(i=>i);
                foreach (var value in valueList)
                {
                    Items.Add(new Item(new Condition(attribute.AttributeName, value.Key).ToList(), -1));
                }
            }
            UpdateItemsFrequency();
        }
 public static void Test_ItemSet_MeetMinimumCoverage()
 {
     string tmp = "";
     using (OpenFileDialog newOFD = new OpenFileDialog())
     {
         if (newOFD.ShowDialog() == DialogResult.OK)
         {
             tmp = newOFD.FileName;
         }
     }
     Arff tmp2 = new Arff(File.ReadAllText(tmp));
     ItemSet tmp3 = new ItemSet(tmp2);
     tmp3.MeetMinimumCoverage(6);
     tmp3.OrderByFrequencyDescending();
 }
 public FPTreeTable(Arff source, ItemSet itemSet)
 {
     if (itemSet.Size() == 1)
     {
         Records = new List<FPTreeTableRecord>();
         for (int i = 0; i < source.Count(); i++)
         {
             //for every record
             FPTreeTableRecord Record = new FPTreeTableRecord();
             foreach (var item in itemSet.Items)
             {
                 if (source.RecordContains(i, item))
                 {
                     Record.Add(new FPTreeTableRecordItem(item));
                 }
             }
             if (Record.Count() != 0) { Records.Add(Record); }
         }
     }
     else
     { throw new Exception("Error creating FPTreeTable: invalid itemset, only 1-item itemset allowed"); }
 }