예제 #1
0
        internal static void PruneAfterConnection(PatternRecorderFrequent fRecorder, MiningParams param, Depth depth)
        {
            if (!param.MineFrequent && (param.MineClosed || param.MineMaximal))
            {
                PruneCannotBeClosed(fRecorder, param, depth);
            }

            PruneCannotBeExtended(fRecorder, param, depth);
        }
예제 #2
0
        private static void PruneCannotBeExtended(PatternRecorderFrequent fRecorder, MiningParams param, Depth depth)
        {
            var fDi = fRecorder.GetFrequentsAtDepth(depth + 1);

            foreach (var fpt in fDi)
            {
                fpt.PruneAfterConnection(param, depth);
            }

            fRecorder.RemoveCannotBeExtended(depth + 1);
        }
예제 #3
0
        private static void PruneCannotBeClosed(PatternRecorderFrequent fRecorder, MiningParams param, Depth depth)
        {
            if (param.MineFrequent || !(param.MineClosed || param.MineMaximal))
            {
                return;
            }

            var rDi = fRecorder.GetFanout1FrequentsAtDepth(depth);

            rDi.Sort();

            var dic = new Dictionary <NodeSymbol, List <PatternTree> >();

            foreach (var t in rDi)
            {
                if (t.Is2Pattern)
                {
                    continue;
                }

                var key = t.FirstSymbol + "," + t.SecondSymbol;

                if (!dic.ContainsKey(key))
                {
                    dic.Add(key, new List <PatternTree>());
                }

                dic[key].Add(t);
            }

            foreach (var fpSet in dic)
            {
                var keysRedundant = new HashSet <string>();
                for (var i = 0; i < fpSet.Value.Count; i++)
                {
                    var ti = fpSet.Value[i];
                    for (var j = 0; j < fpSet.Value.Count; j++)
                    {
                        var tj = fpSet.Value[j];

                        if (i == j)
                        {
                            continue;
                        }

                        if (ti.Size >= tj.Size || ti.TransactionSupport != tj.TransactionSupport || ti.RootSupport != tj.RootSupport)
                        {
                            continue;
                        }

                        if (!ti.IsSuperPattern(tj, depth))
                        {
                            continue;
                        }
                        var maxDif = (param.SupportType == SupportType.Transaction)
                            ? param.ThresholdTransaction : param.ThresholdRoot;

                        if (ti.NumberOfRightMostOcc - tj.NumberOfRightMostOcc >= maxDif)
                        {
                            continue;
                        }

                        keysRedundant.Add(ti.PreorderString);
                        break;
                    }
                }

                fRecorder.RemoveRedundantForClosed(keysRedundant);
                Debug.WriteLine("Depth:{0} RemoveRedundantForClosed Number={1}", depth, keysRedundant.Count);
            }
        }