Exemple #1
0
        protected PatternTree(IList <NodeSymbol> preorderRepresentation, bool singleChild, MiningParams miningParams)
        {
            if (preorderRepresentation == null)
            {
                throw new ArgumentNullException("preorderRepresentation");
            }
            if (preorderRepresentation.Count < 2 || preorderRepresentation.Count % 2 != 0)
            {
                throw new ArgumentException("Invalid preorder representation.");
            }

            PreorderString = preorderRepresentation.ToPreorderString(miningParams.Separator);

            SingleChild = singleChild;

            PreorderRepresentation = new ReadOnlyCollection <NodeSymbol>(preorderRepresentation);

            depthOccSet = new Dictionary <Depth, DepthOccSet>();

            supportTransactionSet = new HashSet <TreeId>();

            NumberOfRightMostOcc = 0;

            RootSupport = 0;

            AbleToConnect     = Is2Pattern;
            AbleToBeConnected = !Is1Pattern;
            AbleToCombine     = true;

            MiningParams = miningParams;
        }
Exemple #2
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);
        }
Exemple #3
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);
        }
Exemple #4
0
        protected CCTreeMinerAlgorithm(ICloneable miningParams)
        {
            if (miningParams == null)
            {
                throw new ArgumentNullException("miningParams");
            }

            IsMining = false;

            MiningParams = (MiningParams)miningParams.Clone();
        }
        public override string ToString()
        {
            var sb = new StringBuilder(MiningParams.ToString());

            sb.Append(Environment.NewLine);
            sb.AppendLine("Maximal Depth: " + MaxDepth);
            sb.AppendLine(string.Format("Total Time Elapsed: {0}ms", TotalTimeElapsed));
            sb.AppendLine("Extended Patterns Count: " + ExtendedPatternsCount);
            sb.AppendLine("Frequent Patterns Count: " + FrequentPatternsCount);
            sb.AppendLine("Closed Patterns Count: " + ClosedPatternsCount);
            sb.AppendLine("Maximal Patterns Count: " + MaximalPatternsCount);

            return(sb.ToString());
        }
Exemple #6
0
        public static PatternTree Create(NodeSymbol[] preorderRepresentation,
                                         bool singleChild, MiningParams miningParams)
        {
            if (preorderRepresentation == null || preorderRepresentation.Length < 2)
            {
                throw new ArgumentException("Invalid preorder representation.");
            }

            if (preorderRepresentation.Length == 2)
            {
                return(new OnePatternTree(preorderRepresentation, singleChild, miningParams));
            }

            return(new PatternTree(preorderRepresentation, singleChild, miningParams));
        }
        public static MiningResults Mine(IList <ITextTree> treeSet, MiningParams miningParams)
        {
            if (treeSet == null)
            {
                throw new ArgumentNullException("treeSet");
            }
            if (miningParams == null)
            {
                throw new ArgumentNullException("miningParams");
            }

            var cctreeMiner = CCTreeMinerFactory.GetCCTreeMiner(miningParams);

            return(cctreeMiner.Mine(treeSet));
        }
Exemple #8
0
        protected MiningParams(MiningParams another)
        {
            subtreeType = another.SubtreeType;

            mineOrdered = another.MineOrdered;

            mineFrequent = another.MineFrequent;
            mineClosed   = another.MineClosed;
            mineMaximal  = another.MineMaximal;

            supportType          = another.SupportType;
            thresholdRoot        = another.ThresholdRoot;
            thresholdTransaction = another.ThresholdTransaction;

            separator       = another.separator;
            backTrackSymbol = string.Copy(another.backTrackSymbol);
        }
Exemple #9
0
        internal static CCTreeMinerAlgorithm GetCCTreeMiner(MiningParams miningParams)
        {
            if (miningParams == null)
            {
                throw new ArgumentNullException("miningParams");
            }

            switch (miningParams.SubtreeType)
            {
            case SubtreeType.BottomUp:
                return(new BottomUpMiner(miningParams));

            case SubtreeType.Induced:
                return(new InducedMiner(miningParams));

            case SubtreeType.Embedded:
                return(new EmbeddedMiner(miningParams));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemple #10
0
 public BottomUpMiner(MiningParams miningParams) : base(miningParams)
 {
     throw new NotImplementedException();
 }
 public EmbeddedMiner(MiningParams miningParams) : base(miningParams)
 {
     throw new NotImplementedException();
 }
Exemple #12
0
        internal void PruneAfterConnection(MiningParams param, Depth depth)
        {
            switch (param.SupportType)
            {
            case SupportType.Transaction:
            {
                if (AbleToCombine || AbleToConnect)
                {
                    var t = TransactionSupportAbove(depth + 1, true);
                    if (t < param.ThresholdTransaction)
                    {
                        AbleToCombine = false;
                        AbleToConnect = false;
                    }
                }

                if (AbleToBeConnected)
                {
                    var t = TransactionSupportAbove(depth + 1, false);
                    if (t < param.ThresholdTransaction)
                    {
                        AbleToBeConnected = false;
                    }
                }
            }
            break;

            case SupportType.RootOccurrence:
            {
                if (AbleToCombine || AbleToConnect)
                {
                    var r = RootSupportAbove(depth + 1, true);
                    if (r < param.ThresholdRoot)
                    {
                        AbleToCombine = false;
                        AbleToConnect = false;
                    }
                }

                if (AbleToBeConnected)
                {
                    var r = RootSupportAbove(depth + 1, false);
                    if (r < param.ThresholdRoot)
                    {
                        AbleToBeConnected = false;
                    }
                }
            }
            break;

            case SupportType.Hybrid:
            {
                if (AbleToCombine || AbleToConnect)
                {
                    var t = TransactionSupportAbove(depth + 1, true);
                    if (t < param.ThresholdTransaction)
                    {
                        AbleToCombine = false;
                        AbleToConnect = false;
                    }
                    else
                    {
                        var r = RootSupportAbove(depth + 1, true);
                        if (r < param.ThresholdRoot)
                        {
                            AbleToCombine = false;
                            AbleToConnect = false;
                        }
                    }
                }

                if (AbleToBeConnected)
                {
                    var t = RootSupportAbove(depth + 1, false);
                    if (t < param.ThresholdTransaction)
                    {
                        AbleToBeConnected = false;
                    }
                    else
                    {
                        var r = RootSupportAbove(depth + 1, false);
                        if (r < param.ThresholdRoot)
                        {
                            AbleToBeConnected = false;
                        }
                    }
                }
            }
            break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemple #13
0
 public InducedMiner(MiningParams miningParams) : base(miningParams)
 {
 }
Exemple #14
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);
            }
        }
 internal OnePatternTree(IList <NodeSymbol> preorderRepresentation, bool singleChild, MiningParams miningParams)
     : base(preorderRepresentation, singleChild, miningParams)
 {
 }