偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

時(shí)間序列異常檢測(cè):MSET-SPRT組合方法的原理和Python代碼實(shí)現(xiàn)

人工智能
在異常檢測(cè)領(lǐng)域,尤其針對(duì)工業(yè)機(jī)械、核反應(yīng)堆和網(wǎng)絡(luò)安全等復(fù)雜系統(tǒng),傳統(tǒng)方法往往難以有效處理高維度且相互關(guān)聯(lián)的數(shù)據(jù)流。多元狀態(tài)估計(jì)技術(shù)(MSET) 與序貫概率比檢驗(yàn)(SPRT) 的組合方法在此類(lèi)場(chǎng)景中展現(xiàn)出顯著優(yōu)勢(shì)。

在異常檢測(cè)領(lǐng)域,尤其針對(duì)工業(yè)機(jī)械、核反應(yīng)堆和網(wǎng)絡(luò)安全等復(fù)雜系統(tǒng),傳統(tǒng)方法往往難以有效處理高維度且相互關(guān)聯(lián)的數(shù)據(jù)流。多元狀態(tài)估計(jì)技術(shù)(MSET) 與序貫概率比檢驗(yàn)(SPRT) 的組合方法在此類(lèi)場(chǎng)景中展現(xiàn)出顯著優(yōu)勢(shì)。

MSET-SPRT是一種結(jié)合機(jī)器學(xué)習(xí)狀態(tài)估計(jì)與統(tǒng)計(jì)假設(shè)檢驗(yàn)的混合技術(shù)框架,通過(guò)其高精度和穩(wěn)健性,被廣泛應(yīng)用于關(guān)鍵任務(wù)系統(tǒng)的監(jiān)控與分析。該方法能夠?qū)崟r(shí)識(shí)別系統(tǒng)行為的微小偏差,為預(yù)防性維護(hù)和異常事件預(yù)警提供可靠依據(jù)。

MSET-SPRT理論基礎(chǔ)

多元狀態(tài)估計(jì)技術(shù)(MSET)原理

MSET作為一種非參數(shù)非線性回歸技術(shù),通過(guò)歷史觀測(cè)數(shù)據(jù)構(gòu)建系統(tǒng)正常狀態(tài)模型。其核心工作機(jī)制包括:

建立包含歷史正常系統(tǒng)狀態(tài)的記憶矩陣,作為參考基準(zhǔn);利用學(xué)習(xí)到的歷史狀態(tài)間關(guān)系計(jì)算加權(quán)組合,從而估計(jì)當(dāng)前系統(tǒng)的預(yù)期狀態(tài);通過(guò)對(duì)比觀測(cè)值與估計(jì)值,計(jì)算系統(tǒng)行為偏差,為異常檢測(cè)提供基礎(chǔ)指標(biāo)。

序貫概率比檢驗(yàn)(SPRT)方法

SPRT是一種基于統(tǒng)計(jì)推斷的序貫假設(shè)檢驗(yàn)方法,專(zhuān)用于確定系統(tǒng)行為偏差是否具有統(tǒng)計(jì)顯著性。其主要功能為:

持續(xù)評(píng)估殘差誤差(實(shí)際觀測(cè)值與模型估計(jì)值之間的差異),并根據(jù)預(yù)設(shè)的統(tǒng)計(jì)模型進(jìn)行假設(shè)檢驗(yàn);當(dāng)檢測(cè)到的偏差超過(guò)統(tǒng)計(jì)置信閾值時(shí),系統(tǒng)能夠及時(shí)發(fā)出預(yù)警信號(hào),同時(shí)控制虛警率在可接受范圍內(nèi)。

MSET-SPRT框架通過(guò)上述兩種技術(shù)的協(xié)同作用,為多元數(shù)據(jù)異常檢測(cè)提供了準(zhǔn)確且高效的解決方案,特別適用于高維度、高相關(guān)性的時(shí)間序列數(shù)據(jù)分析。

Python實(shí)現(xiàn)MSET-SPRT異常檢測(cè)

下面通過(guò)一個(gè)精簡(jiǎn)的示例來(lái)演示MSET-SPRT方法在Python中的實(shí)現(xiàn)過(guò)程。

導(dǎo)入必要的庫(kù)

import numpy as np
 import scipy.stats as stats
 import matplotlib.pyplot as plt

生成模擬數(shù)據(jù)集

構(gòu)建一個(gè)多元正態(tài)分布數(shù)據(jù)集,用于模擬正常運(yùn)行狀態(tài)下的系統(tǒng)行為:

# Simulating normal system behavior (3 correlated sensors)
np.random.seed(42)
mean = [50, 75, 100]  # Mean values for three sensors
cov = [[10, 5, 2], [5, 15, 3], [2, 3, 20]]  # Covariance matrix

# Generate 500 normal operation samples
 normal_data = np.random.multivariate_normal(mean, cov, size=500)

實(shí)現(xiàn)MSET算法

采用基于加權(quán)最近鄰的方法實(shí)現(xiàn)MSET算法,用于估計(jì)系統(tǒng)的預(yù)期行為:

class MSET:
    def __init__(self, memory_matrix):
        self.memory_matrix = memory_matrix  # Store normal system states

    def estimate(self, input_vector):
        """
        Estimates the expected state based on historical data.
        Uses nearest neighbors to compute weighted estimation.
        """
        weights = np.exp(-np.linalg.norm(self.memory_matrix - input_vector, axis=1))
        weights /= np.sum(weights)
         return np.dot(weights, self.memory_matrix)

初始化MSET模型,將正常運(yùn)行數(shù)據(jù)作為記憶矩陣:

# Initialize MSET with normal data as memory
 mset_model = MSET(memory_matrix=normal_data)

計(jì)算殘差

計(jì)算實(shí)際觀測(cè)值與MSET估計(jì)值之間的殘差,作為異常檢測(cè)的基礎(chǔ):

# filepath: deephub\5\20250327\article.md
# Simulated test data (normal + some anomalies)
test_data = np.vstack([
    np.random.multivariate_normal(mean, cov, size=450),  # Normal
    np.random.multivariate_normal([70, 50, 130], cov, size=50)  # Anomalies
])

# Compute estimated values
estimated_data = np.array([mset_model.estimate(x) for x in test_data])
# Compute residuals
 residuals = np.linalg.norm(test_data - estimated_data, axis=1)

應(yīng)用SPRT進(jìn)行異常檢測(cè)

基于似然比檢驗(yàn)原理實(shí)現(xiàn)SPRT算法,用于判定殘差是否表示異常狀態(tài):

# Define thresholds for SPRT
alpha = 0.05  # False positive rate
beta = 0.05   # False negative rate
mu_0, sigma_0 = np.mean(residuals[:450]), np.std(residuals[:450])  # Normal behavior
mu_1 = mu_0 + 3 * sigma_0  # Anomalous mean shift

# SPRT decision function
def sprt_test(residual):
    """ Sequential Probability Ratio Test for anomaly detection """
    likelihood_ratio = stats.norm(mu_1, sigma_0).pdf(residual) / stats.norm(mu_0, sigma_0).pdf(residual)
    return likelihood_ratio > (1 - beta) / alpha
# Apply SPRT
anomalies = np.array([sprt_test(res) for res in residuals])
# Plot results
plt.figure(figsize=(12, 5))
plt.plot(residuals, label="Residuals", color="blue")
plt.axhline(mu_1, color="red", linestyle="dashed", label="Anomaly Threshold")
plt.scatter(np.where(anomalies)[0], residuals[anomalies], color="red", label="Detected Anomalies", zorder=2)
plt.xlabel("Time")
plt.ylabel("Residual Magnitude")
plt.legend()
plt.title("MSET-SPRT Anomaly Detection")
 plt.show()

結(jié)果分析與解釋

圖中數(shù)據(jù)可視化結(jié)果展示了MSET-SPRT方法的異常檢測(cè)效果:

藍(lán)色曲線表示系統(tǒng)狀態(tài)殘差時(shí)間序列,反映了實(shí)際觀測(cè)值與估計(jì)值之間的偏差大?。患t色虛線標(biāo)示出異常檢測(cè)閾值,該閾值基于正常運(yùn)行數(shù)據(jù)的統(tǒng)計(jì)特性計(jì)算得出;紅色標(biāo)記點(diǎn)則代表被SPRT算法判定為異常的時(shí)間點(diǎn),這些點(diǎn)的殘差值顯著高于正常波動(dòng)范圍。

分析結(jié)果表明,MSET-SPRT方法能夠有效區(qū)分正常系統(tǒng)波動(dòng)與異常行為,提供了一種可靠的多元時(shí)間序列異常檢測(cè)方案。該方法特別適用于需要高精度異常檢測(cè)的工業(yè)監(jiān)控、設(shè)備健康管理和網(wǎng)絡(luò)安全等領(lǐng)域。

責(zé)任編輯:華軒 來(lái)源: DeepHub IMBA
相關(guān)推薦

2021-03-31 11:20:57

PythonADTK異常檢測(cè)

2024-09-09 14:57:31

2024-04-26 12:29:36

2018-05-08 14:47:38

虛擬機(jī)方法代碼

2022-09-21 23:41:40

機(jī)器學(xué)習(xí)開(kāi)源數(shù)據(jù)

2023-03-30 15:12:47

2023-09-20 11:42:52

2024-05-29 11:36:44

2019-08-06 10:35:25

Python時(shí)間序列可視化

2009-01-03 09:13:00

2009-07-22 14:43:36

2024-10-24 16:46:41

2022-09-22 15:42:02

機(jī)器學(xué)習(xí)異常值工具

2022-08-21 16:41:04

Python異常檢測(cè)

2018-01-23 09:17:22

Python人臉識(shí)別

2022-09-30 10:31:06

Python時(shí)間序列數(shù)據(jù)

2018-08-16 10:05:07

2017-09-27 15:17:54

HTML5Hybrid手勢(shì)

2020-03-18 20:16:44

數(shù)據(jù)樣本標(biāo)準(zhǔn)計(jì)算

2017-06-21 12:22:33

點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)