This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Scanner; | |
| public class uncleJohny { | |
| public static void main(String[] args) { | |
| Scanner sc = new Scanner(System.in); | |
| int T = sc.nextInt(); // Number of test Cases | |
| int i, j, l; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def multivariateGaussian(X, mu, sigma2): | |
| n = np.size(sigma2, 1) | |
| m = np.size(sigma2, 0) | |
| #print(m,n) | |
| if n == 1 or m == 1: | |
| # print('Yes!') | |
| sigma2 = np.diag(sigma2[0, :]) | |
| #print(sigma2) | |
| X = X - mu |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| import scipy.io as sio | |
| import math |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dataset = sio.loadmat('anomalyData.mat') | |
| X = dataset['X'] | |
| Xval = dataset['Xval'] | |
| yval = dataset['yval'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| plt.scatter(X[:, 0], X[:, 1], marker = "x") | |
| plt.xlabel('Latency(ms)') | |
| plt.ylabel('Throughput(mb/s)') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def estimateGaussian(X): | |
| n = np.size(X, 1) | |
| m = np.size(X, 0) | |
| mu = np.zeros((n, 1)) | |
| sigma2 = np.zeros((n, 1)) | |
| mu = np.reshape((1/m)*np.sum(X, 0), (1, n)) | |
| sigma2 = np.reshape((1/m)*np.sum(np.power((X - mu),2), 0),(1, n)) | |
| return mu, sigma2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def multivariateGaussian(X, mu, sigma2): | |
| n = np.size(sigma2, 1) | |
| m = np.size(sigma2, 0) | |
| #print(m,n) | |
| if n == 1 or m == 1: | |
| # print('Yes!') | |
| sigma2 = np.diag(sigma2[0, :]) | |
| #print(sigma2) | |
| X = X - mu |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def selectThreshHold(yval, pval): | |
| F1 = 0 | |
| bestF1 = 0 | |
| bestEpsilon = 0 | |
| stepsize = (np.max(pval) - np.min(pval))/1000 | |
| epsVec = np.arange(np.min(pval), np.max(pval), stepsize) | |
| noe = len(epsVec) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def findIndices(binVec): | |
| l = [] | |
| for i in range(len(binVec)): | |
| if binVec[i] == 1: | |
| l.append(i) | |
| return l |
OlderNewer