Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Negative Selection Algorithm | Artificial Immune Systems
Bio-Inspired Algorithms with Python

bookNegative Selection Algorithm

メニューを表示するにはスワイプしてください

Note
Definition

The negative selection algorithm is inspired by the biological immune system distinguishing self from non-self. T-cells that react to self are eliminated, leaving only those that can recognize foreign invaders. The algorithm defines self (normal data), generates detectors that do not match self, and uses these to detect anomalies.

The process involves three steps:

  • Generate a representative set of self samples to capture normal system behavior;
  • Create a large number of random detectors;
  • Eliminate detectors matching self, leaving active detectors that flag anomalies when they match new data.
12345678910111213141516171819202122232425262728293031323334
import random def generate_random_detector(length): """Generate a random binary string detector of given length.""" return ''.join(random.choice('01') for _ in range(length)) def match(detector, self_set, r): """ Returns True if detector matches any string in self_set with at least r contiguous matching bits. """ for self_str in self_set: for i in range(len(self_str) - r + 1): if detector[i:i+r] == self_str[i:i+r]: return True return False def negative_selection(self_set, num_detectors, length, r): """ Generate detectors that do not match any self string with at least r contiguous matching bits. """ detectors = [] while len(detectors) < num_detectors: detector = generate_random_detector(length) if not match(detector, self_set, r): detectors.append(detector) return detectors # Example usage: self_set = ['11001', '10011', '11100'] detectors = negative_selection(self_set, num_detectors=5, length=5, r=3) print("Generated detectors:", detectors)
copy

Strengths and Limitations of the Negative Selection Algorithm

The negative selection algorithm provides a straightforward method for anomaly detection, inspired by immune systems. Key strengths:

  • Ability to detect unseen anomalies by targeting data outside the self set;
  • No need for prior knowledge of anomalous patterns, only a clear self definition.

Limitations include:

  • Detector generation becomes slow as the self set grows;
  • Less effective for high-dimensional or continuous data due to sparse non-self coverage;
  • Potential for false positives or negatives if the self set is not fully representative or detectors are poorly defined.

Despite these issues, the negative selection algorithm is a core idea in artificial immune systems and robust anomaly detection.

question mark

Which statement best describes the negative selection algorithm and its characteristics?

正しい答えを選んでください

すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 4.  2

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

セクション 4.  2
some-alt