Skip to content

Commit 941421f

Browse files
committed
📝 add anomaly detection readme
1 parent 43d4232 commit 941421f

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed

images/AnomalyDetection_08.png

23.5 KB
Loading

images/AnomalyDetection_09.png

59.7 KB
Loading

images/AnomalyDetection_10.png

23.2 KB
Loading

readme.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1126,6 +1126,39 @@ def selectThreshold(yval,pval):
11261126
若:
11271127
![enter description here][55]
11281128
表示x1,x2**负相关**
1129+
- 实现代码:
1130+
```
1131+
# 多元高斯分布函数
1132+
def multivariateGaussian(X,mu,Sigma2):
1133+
k = len(mu)
1134+
if (Sigma2.shape[0]>1):
1135+
Sigma2 = np.diag(Sigma2)
1136+
'''多元高斯分布函数'''
1137+
X = X-mu
1138+
argu = (2*np.pi)**(-k/2)*np.linalg.det(Sigma2)**(-0.5)
1139+
p = argu*np.exp(-0.5*np.sum(np.dot(X,np.linalg.inv(Sigma2))*X,axis=1)) # axis表示每行
1140+
return p
1141+
```
1142+
### 6、单元和多元高斯分布特点
1143+
- 单元高斯分布
1144+
- 人为可以捕捉到`feature`之间的关系时可以使用
1145+
- 计算量小
1146+
- 多元高斯分布
1147+
- 自动捕捉到相关的feature
1148+
- 计算量大,因为:![$$\Sigma \in {R^{n \times {\rm{n}}}}$$](http://latex.codecogs.com/png.latex?%5Cfn_cm%20%24%24%5CSigma%20%5Cin%20%7BR%5E%7Bn%20%5Ctimes%20%7B%5Crm%7Bn%7D%7D%7D%7D%24%24)
1149+
- `m>n``Σ`可逆时可以使用。(若不可逆,可能有冗余的x,因为线性相关,不可逆,或者就是m<n)
1150+
1151+
### 7、程序运行结果
1152+
- 显示数据
1153+
![enter description here][56]
1154+
- 等高线
1155+
![enter description here][57]
1156+
- 异常点
1157+
![enter description here][58]
1158+
1159+
1160+
1161+
----------------------------------
11291162

11301163

11311164
[1]: ./images/LinearRegression_01.png "LinearRegression_01.png"
@@ -1182,4 +1215,7 @@ def selectThreshold(yval,pval):
11821215
[52]: ./images/AnomalyDetection_03.png "AnomalyDetection_03.png"
11831216
[53]: ./images/AnomalyDetection_05.png "AnomalyDetection_05.png"
11841217
[54]: ./images/AnomalyDetection_07.png "AnomalyDetection_07.png"
1185-
[55]: ./images/AnomalyDetection_06.png "AnomalyDetection_06.png"
1218+
[55]: ./images/AnomalyDetection_06.png "AnomalyDetection_06.png"
1219+
[56]: ./images/AnomalyDetection_08.png "AnomalyDetection_08.png"
1220+
[57]: ./images/AnomalyDetection_09.png "AnomalyDetection_09.png"
1221+
[58]: ./images/AnomalyDetection_10.png "AnomalyDetection_10.png"

0 commit comments

Comments
 (0)