User Tools

Site Tools


ai_anomaly_detection

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
ai_anomaly_detection [2025/05/23 16:47] – [3. Combining with Visualization] eagleeyenebulaai_anomaly_detection [2025/06/26 18:20] (current) – [AI Anomaly Detection] eagleeyenebula
Line 1: Line 1:
 ====== AI Anomaly Detection ====== ====== AI Anomaly Detection ======
-* **[[https://autobotsolutions.com/god/templates/index.1.html|More Developers Docs]]**:+[[https://autobotsolutions.com/aurora/wiki/doku.php?id=ai_anomaly_detection|Wiki]]: [[https://autobotsolutions.com/god/templates/ai_anomaly_detection.html|Framework]]: [[https://github.com/AutoBotSolutions/Aurora/blob/Aurora/ai_anomaly_detection.py|GitHub]]: [[https://autobotsolutions.com/artificial-intelligence/anomaly-detection-module-proactive-insights-for-data-consistency/|Article]]: 
 The **AI Anomaly Detection** system is a Python-based utility that identifies outliers in datasets using statistical principles like standard deviation. This function is essential for finding anomalous data points that deviate significantly from the dataset's normal range. The **AI Anomaly Detection** system is a Python-based utility that identifies outliers in datasets using statistical principles like standard deviation. This function is essential for finding anomalous data points that deviate significantly from the dataset's normal range.
 +
 +
 +{{youtube>0m1Ivadc2PM?large}}
 +
  
 ===== Overview ===== ===== Overview =====
Line 23: Line 28:
 **Threshold for Anomalies**: **Threshold for Anomalies**:
 Data points are considered anomalies if they fall outside the range: Data points are considered anomalies if they fall outside the range:
 +<code>
 [mean - (3 * standard deviation), mean + (3 * standard deviation)] [mean - (3 * standard deviation), mean + (3 * standard deviation)]
 +</code>
 ==== 2. Logging Information ==== ==== 2. Logging Information ====
  
Line 34: Line 39:
  
 **Example Log Messages**: **Example Log Messages**:
 +<code>
 INFO: Detecting anomalies in the data... INFO: Anomalies detected: [120, -45] INFO: Detecting anomalies in the data... INFO: Anomalies detected: [120, -45]
 +</code>
 ====== Function Details ====== ====== Function Details ======
  
Line 44: Line 49:
  
 **Signature**: **Signature**:
-   python+<code> 
 +python
 def detect_anomalies(data: List[float]) -> List[float]: def detect_anomalies(data: List[float]) -> List[float]:
     """     """
Line 51: Line 57:
     :return: List of anomalies detected     :return: List of anomalies detected
     """     """
 +</code>
 ===== Examples ===== ===== Examples =====
  
Line 57: Line 63:
  
 **Input Example**: **Input Example**:
-   python+<code> 
 +python
 data = [10, 12, 15, 10, 11, 14, 120, 12, 9, -45] data = [10, 12, 15, 10, 11, 14, 120, 12, 9, -45]
 anomalies = detect_anomalies(data) anomalies = detect_anomalies(data)
 print(f"Anomalies: {anomalies}") print(f"Anomalies: {anomalies}")
 +</code>
 **Output**: **Output**:
- +<code>
 Anomalies: [120, -45] Anomalies: [120, -45]
-  +</code>
  
 **Explanation**: **Explanation**:
Line 75: Line 82:
  
 **Example: Empty Dataset**: **Example: Empty Dataset**:
-   python+<code> 
 +python
 data = [] data = []
 anomalies = detect_anomalies(data) anomalies = detect_anomalies(data)
 print(f"Anomalies: {anomalies}") print(f"Anomalies: {anomalies}")
-  +</code>
 **Output**: **Output**:
- +<code>
 Anomalies: [] Anomalies: []
-  +</code>
 **Explanation**: **Explanation**:
 The function immediately returns an empty list if the dataset is empty. The function immediately returns an empty list if the dataset is empty.
  
 **Example: All Data Within Range**: **Example: All Data Within Range**:
-   python+<code> 
 +python
 data = [100, 102, 98, 101, 99] data = [100, 102, 98, 101, 99]
 anomalies = detect_anomalies(data) anomalies = detect_anomalies(data)
 print(f"Anomalies: {anomalies}") print(f"Anomalies: {anomalies}")
-  +</code>
 **Output**: **Output**:
- +<code>
 Anomalies: [] Anomalies: []
-  +</code> 
  
 **Explanation**: **Explanation**:
Line 109: Line 115:
  
 **Input Data**: **Input Data**:
-   python+<code> 
 +python
 data = [100, 150, 200, 1000, 105, 210, 980, 115, 195] data = [100, 150, 200, 1000, 105, 210, 980, 115, 195]
 anomalies = detect_anomalies(data) anomalies = detect_anomalies(data)
-  +</code>
 **Output**: **Output**:
- +<code>
 Anomalies: [1000, 980] Anomalies: [1000, 980]
-  +</code>
 **Explanation**: **Explanation**:
 Outliers 1000 and 980 are classified as anomalies due to their significant deviation from the mean of the dataset. Outliers 1000 and 980 are classified as anomalies due to their significant deviation from the mean of the dataset.
Line 128: Line 133:
  
 **Framework for Live Data Streams**: **Framework for Live Data Streams**:
-   python+<code> 
 +python
 import random import random
 import time import time
Line 148: Line 154:
  
 stream_anomaly_detection() stream_anomaly_detection()
 +</code>
 ===== Advanced Usage ===== ===== Advanced Usage =====
  
Line 154: Line 160:
  
 By default, the function uses **3 standard deviations** as the threshold for anomaly detection. To customize this, modify the following part of the function: By default, the function uses **3 standard deviations** as the threshold for anomaly detection. To customize this, modify the following part of the function:
-   python+<code> 
 +python
 anomalies = [x for x in data if abs(x - mean) > THRESHOLD * std_dev] anomalies = [x for x in data if abs(x - mean) > THRESHOLD * std_dev]
-  +</code>
 **Example Custom Threshold**: **Example Custom Threshold**:
-   python+<code> 
 +python
 THRESHOLD = 2  # Using 2 standard deviations instead of 3 THRESHOLD = 2  # Using 2 standard deviations instead of 3
 data = [12, 15, 18, 10, 140] data = [12, 15, 18, 10, 140]
 anomalies = detect_anomalies(data) anomalies = detect_anomalies(data)
 print(f"Anomalies with Threshold={THRESHOLD}: {anomalies}") print(f"Anomalies with Threshold={THRESHOLD}: {anomalies}")
- +</code>
 ==== 2. Batch Detection for Multiple Data Sets ==== ==== 2. Batch Detection for Multiple Data Sets ====
  
Line 170: Line 177:
  
 **Example**: **Example**:
-   python+<code> 
 +python
 datasets = [ datasets = [
     [10, 12, 14, 18, 200],     [10, 12, 14, 18, 200],
Line 180: Line 188:
     anomalies = detect_anomalies(data)     anomalies = detect_anomalies(data)
     print(f"Dataset {idx + 1}: {anomalies}")     print(f"Dataset {idx + 1}: {anomalies}")
-  +</code>
 **Output**: **Output**:
- +<code>
 Dataset 1: [200] Dataset 2: [700] Dataset 3: [500] Dataset 1: [200] Dataset 2: [700] Dataset 3: [500]
 +</code>
 ==== 3. Combining with Visualization ==== ==== 3. Combining with Visualization ====
  
Line 190: Line 198:
  
 **Example with Matplotlib**: **Example with Matplotlib**:
-   python+<code> 
 +python
 import matplotlib.pyplot as plt import matplotlib.pyplot as plt
  
Line 209: Line 218:
 plt.legend() plt.legend()
 plt.show() plt.show()
 +</code>
 ===== Applications ===== ===== Applications =====
  
Line 219: Line 229:
 **3. Preprocessing for AI Pipelines**: **3. Preprocessing for AI Pipelines**:
 Flag and handle anomalous data points before model training to improve model robustness and accuracy. Flag and handle anomalous data points before model training to improve model robustness and accuracy.
- 
---- 
  
 ===== Best Practices ===== ===== Best Practices =====
Line 232: Line 240:
 3. **Visualization**: 3. **Visualization**:
 Combine detection results with visualizations for better interpretability. Combine detection results with visualizations for better interpretability.
- 
---- 
- 
 ===== Conclusion ===== ===== Conclusion =====
  
 The **AI Anomaly Detection** framework provides a robust, flexible, and extensible mechanism for outlier detection in numerical datasets. With applications ranging from real-time monitoring to preprocessing for AI pipelines, the system is a valuable tool for automated anomaly analysis. By leveraging advanced usage patterns like visualization and threshold adjustments, the functionality can be tailored to a wide range of industry applications. The **AI Anomaly Detection** framework provides a robust, flexible, and extensible mechanism for outlier detection in numerical datasets. With applications ranging from real-time monitoring to preprocessing for AI pipelines, the system is a valuable tool for automated anomaly analysis. By leveraging advanced usage patterns like visualization and threshold adjustments, the functionality can be tailored to a wide range of industry applications.
ai_anomaly_detection.1748018827.txt.gz · Last modified: 2025/05/23 16:47 by eagleeyenebula