public IEnumerable <IEmergingPattern> Mine(InstanceModel model, IEnumerable <Instance> instances, Feature classFeature) { EmergingPatternCreator EpCreator = new EmergingPatternCreator(); IEmergingPatternSimplifier simplifier; if (Multivariate) { simplifier = new EmergingPatternSimplifier(new MultivariateItemComparer()); } else { simplifier = new EmergingPatternSimplifier(new ItemComparer()); } List <IEmergingPattern> patternsList = new List <IEmergingPattern>(); if (MinePatternsWhileBuildingTree) { DecisionTreeBuilder.OnSplitEvaluation = delegate(IDecisionTreeNode node, ISplitIterator iterator, List <SelectorContext> currentContext) { IChildSelector currentSelector = null; for (int i = 0; i < iterator.CurrentDistribution.Length; i++) { double[] distribution = iterator.CurrentDistribution[i]; if (EPTester.Test(distribution, model, classFeature)) { if (currentSelector == null) { currentSelector = iterator.CreateCurrentChildSelector(); } EmergingPattern ep = EpCreator.ExtractPattern(currentContext, model, classFeature, currentSelector, i); ep.Counts = (double[])distribution.Clone(); patternsList.Add(simplifier.Simplify(ep)); } } }; DoMine(model, instances, classFeature, EpCreator, null); } else { DoMine(model, instances, classFeature, EpCreator, p => { if (EPTester.Test(p.Counts, model, classFeature)) { patternsList.Add(simplifier.Simplify(p)); } } ); } return(patternsList); }
public IEmergingPattern Simplify(IEmergingPattern p) { EmergingPattern result = new EmergingPattern(p.Model, p.ClassFeature, p.ClassValue); if (p.Counts != null) { result.Counts = (double[])p.Counts.Clone(); } if (p.Supports != null) { result.Supports = (double[])p.Supports.Clone(); } _collection.SetResultCollection(result.Items); _collection.AddRange(p.Items); return(result); }