public void GrowthProb(FPTransitions transitions) { SetMinSupport(mMinSupport, transitions.Size()); FPNodeHeadTable table = BuildHeaderTable(transitions); FPTreeNode root = BuildFPTree(transitions, table); if (transitions.mDepth > mMaxDepth) { return; } int total = transitions.Size(); int size = table.Size(); if (size == 0) { return; } GenerateProbOne(root, table, ref total); GenerateProbTwo(root, table, ref total); GenerateProbThree(root, table, ref total); }
private FPTreeNode BuildFPTree(FPTransitions transitions, FPNodeHeadTable table) { FPTreeNode root = new FPTreeNode("", null); int size = transitions.Size(); for (int i = 0; i < size; ++i) { Queue <FPItem> record = new Queue <FPItem>(); SortByTable(transitions[i], table, ref record); FPTreeNode subTreeRoot = root; FPTreeNode tmpRoot = null; while (record.Count > 0 && ((tmpRoot = subTreeRoot.FindChild(record.Peek().mName)) != null)) { tmpRoot.Increasement(1); subTreeRoot = tmpRoot; record.Dequeue(); } AddNodes(subTreeRoot, record, table); } return(root); }
public void Growth(FPTransitions transitions, List <string> postPatterns) { SetMinSupport(mMinSupport, transitions.Size()); FPNodeHeadTable table = BuildHeaderTable(transitions); FPTreeNode root = BuildFPTree(transitions, table); if (transitions.Depth > mMaxDepth) { return; } int size = table.Size(); if (size == 0) { return; } string post = ""; if (postPatterns != null) { int num = postPatterns.Count; for (int n = num - 1; n >= 0; --n) { post += postPatterns[n] + " "; } post.Trim(); } for (int i = 0; i < size; ++i) { FPTreeNode child = table.mHeaderNode[i]; FPTreeNode next = child.NextNode; FPTransitions newTransitions = null; List <string> samples = new List <string>(); while (next != null) { string str = ""; FPTreeNode parent = next.mParent; while (parent != null) { str += parent.mName; str += " "; parent = parent.mParent; } str.Trim(); if (str == "") { next = next.NextNode; continue; } if (transitions.Depth <= mMaxDepth) { for (int j = 0; j < next.mCount; ++j) { samples.Add(str); } } if (post == "") { Debug.Log(str); } else { Debug.Log(str + " : " + post); } next = next.NextNode; } if (transitions.Depth <= mMaxDepth) { newTransitions = FPGrowth.ParseFromArray(samples, transitions.mDuplicate); List <string> newPostPattern = new List <string>(); int num = postPatterns.Count; for (int n = 0; n < num; ++n) { newPostPattern.Add(postPatterns[n]); } newPostPattern.Add(child.mName); if (newTransitions != null) { newTransitions.Depth = transitions.Depth + 1; Growth(newTransitions, newPostPattern); } } } }