public IEnumerable <SuspiciousNode> SelectSuspiciousAcceptedNodes( IReadOnlyList <List <SuspiciousNode> > candidateNodesLists, Classifier classifier) { for (int i = 0; i < candidateNodesLists.Count; i++) { var candidates = candidateNodesLists[i]; foreach (var candidate in candidates) { candidate.BitsCount = LearningExperimentUtil.CountBits(candidate.Vector & _acceptingFeatureBitMask); } candidates.Sort((t1, t2) => t1.BitsCount.CompareTo(t2.BitsCount)); var count = DetermineCount(classifier, i); foreach (var candidate in candidates) { if (candidate.Used) { continue; } yield return(candidate); candidate.Used = true; if (--count == 0) { break; } } } }
private IEnumerable <SuspiciousNode> SelectSuspiciousElementsWithMaskWithSmallGrowing( IReadOnlyList <List <SuspiciousNode> > candidateNodesLists, BigInteger xor, BigInteger mask) { for (int i = 0; i < candidateNodesLists.Count; i++) { var vector = BigInteger.Zero; var candidates = candidateNodesLists[i]; while (true) { var minDiffCount = int.MaxValue; SuspiciousNode newNode = null; foreach (var candidate in candidates) { var newVector = (vector | (candidate.Vector ^ xor)) & mask; var diff = newVector ^ vector; var diffCount = LearningExperimentUtil.CountBits(diff); if (diffCount > 0 && minDiffCount > diffCount) { minDiffCount = diffCount; vector = newVector; newNode = candidate; } } if (newNode != null) { yield return(newNode); } else { break; } } } }
private IEnumerable <SuspiciousNode> SelectSuspiciousElementsWithMaskForFastRejectionLearning( List <List <SuspiciousNode> > candidateNodesLists, BigInteger xor, BigInteger mask, Classifier classifier) { for (int i = 0; i < candidateNodesLists.Count; i++) { var vector = BigInteger.Zero; var classifierUnit = classifier.Units[i]; var candidates = candidateNodesLists[i] .OrderBy( t => LearningExperimentUtil.CountBits( classifierUnit.Accepting & ((t.Vector & _rejectingFeatureBitMask) ^ _rejectingFeatureBitMask))) .ToList(); foreach (var candidate in candidates) { var newVector = (vector | (candidate.Vector ^ xor)) & mask; if (newVector == vector) { continue; } vector = newVector; yield return(candidate); } } }
public IEnumerable <SuspiciousNode> SelectNodesForFastRejectionLearning( IReadOnlyList <List <SuspiciousNode> > candidateNodesLists, Classifier classifier) { for (int i = 0; i < candidateNodesLists.Count; i++) { var candidates = candidateNodesLists[i]; var rejectingVector = classifier.Units[i].Rejecting; foreach (var cnadidate in candidates) { cnadidate.BitsCount = LearningExperimentUtil.CountBits( (cnadidate.Vector & _rejectingFeatureBitMask) | rejectingVector); } candidates.Sort((t1, t2) => t1.BitsCount.CompareTo(t2.BitsCount)); var count = DetermineCount(classifier, i); for (int j = candidates.Count - 1; j >= 0; j--) { var candidate = candidates[j]; if (candidate.Used) { continue; } yield return(candidate); candidate.Used = true; if (--count == 0) { break; } } } }
public IEnumerable <SuspiciousNode> SelectNodesForSlowAcceptanceLearning( IReadOnlyList <List <SuspiciousNode> > candidateNodesLists, Classifier classifier) { for (int i = 0; i < candidateNodesLists.Count; i++) { var candidates = candidateNodesLists[i]; var acceptingVector = classifier.Units[i].Accepting; foreach (var target in candidates) { target.BitsCount = LearningExperimentUtil.CountBits(target.Vector & acceptingVector); } candidates.Sort((t1, t2) => t1.BitsCount.CompareTo(t2.BitsCount)); var count = DetermineCount(classifier, i); for (int j = candidates.Count - 1; j >= 0; j--) { var candidate = candidates[j]; if (candidate.Used) { continue; } yield return(candidate); candidate.Used = true; if (--count == 0) { break; } } } }
public IEnumerable <SuspiciousNode> SelectNodesForSlowRejectionLearningStrongly( IReadOnlyList <List <SuspiciousNode> > candidateNodesLists, Classifier classifier) { for (int i = 0; i < candidateNodesLists.Count; i++) { var candidates = candidateNodesLists[i]; var rejectingUnit = classifier.Units[i].Rejecting; foreach (var target in candidates) { target.BitsCount = LearningExperimentUtil.CountBits( (target.Vector & _rejectingFeatureBitMask) | rejectingUnit); } candidates.Sort((t1, t2) => t1.BitsCount.CompareTo(t2.BitsCount)); var vector = _rejectingFeatureBitMask; var count = DetermineStrongCount(i, classifier); foreach (var candidate in candidates) { if (!candidate.Used) { continue; } var newVector = vector & candidate.Vector; if (newVector == vector) { continue; } vector = newVector; yield return(candidate); candidate.Used = true; if (--count == 0) { break; } } } }
private SuspiciousNode SelectMostDifferentElement( IEnumerable <BigInteger> existings, IEnumerable <SuspiciousNode> candidates, BigInteger mask) { if (!existings.Any()) { return(candidates.FirstOrDefault()); } var maxDiff = 0; SuspiciousNode ret = null; foreach (var candidate in candidates) { var vector = candidate.Vector & mask; var diff = existings.Min(f => LearningExperimentUtil.CountBits((f & mask) ^ vector)); if (maxDiff < diff) { maxDiff = diff; ret = candidate; } } return(ret); }
public IEnumerable <SuspiciousNode> SelectNodesForFastAcceptanceLearningStrongly( IReadOnlyList <List <SuspiciousNode> > candidateNodesLists, Classifier classifier) { for (int i = 0; i < candidateNodesLists.Count; i++) { var candidates = candidateNodesLists[i]; var acceptingVector = classifier.Units[i].Accepting; foreach (var target in candidates) { target.BitsCount = LearningExperimentUtil.CountBits(target.Vector & acceptingVector); } candidates.Sort((t1, t2) => t1.BitsCount.CompareTo(t2.BitsCount)); var vector = BigInteger.Zero; var count = DetermineStrongCount(i, classifier); foreach (var candidate in candidates) { if (candidate.Used) { continue; } var newVector = (vector | candidate.Vector) & _acceptingFeatureBitMask; if (newVector == vector) { continue; } vector = newVector; yield return(candidate); candidate.Used = true; if (--count == 0) { break; } } } }
public IEnumerable <int> CountRejectingFeatures() { return(Units.Select(c => LearningExperimentUtil.CountBits(c.Rejecting >> AcceptingFeatureCount))); }
public IEnumerable <int> CountAcceptingFeatures() { return(Units.Select(c => LearningExperimentUtil.CountBits(c.Accepting & AcceptingFeatureBitMask))); }