In this exercise, you will implement an anomaly detection algorithm to detect anomalous behavior in server computers. The features measure the through put (mb/s) and latency (ms) of response of each server. While your servers were operating, you collected m = 307 examples of how they were behaving,
and thus have an unlabeled dataset {*x (1)*, . . . , x(m)}. You suspect that the vast majority of these examples are “normal” (non-anomalous) examples of the servers operating normally, but there might also be some examples of servers acting anomalously within this dataset.
p=gaussian(X,means,sigma2) anoms=np.array([X[i] for i inrange(X.shape[0])if p[i]<bestEpsilon]) plotGaussian(X,means,sigma2) plt.scatter(anoms[:,0],anoms[:,1],c='r',marker='o')
p=gaussian(X,means,sigma2) anoms=np.array([X[i] for i inrange(X.shape[0])if p[i]<bestEpsilon]) plotGaussian(X,means,sigma2) plt.scatter(anoms[:,0],anoms[:,1],c='r',marker='o')
means,sigma2=estimateGaussian(X2,isCovariance=False) pval=gaussian(Xval2,means,sigma2) bestEpsilon,bestF1=selectThreshold(yval2,pval) p=gaussian(X2,means,sigma2) anoms=[X2[i] for i in range(len(X2)) if p[i]<bestEpsilon] len(anoms) 117
1 2 3 4 5 6 7
means,sigma2=estimateGaussian(X2,isCovariance=True) pval=gaussian(Xval2,means,sigma2) bestEpsilon,bestF1=selectThreshold(yval2,pval) p=gaussian(X2,means,sigma2) anoms=[X2[i] for i in range(len(X2)) if p[i]<bestEpsilon] len(anoms) 122