def testing(filename, n, p): scorelist = [] f = open("./components/org.taz.core/src/main/python/hmm/" + filename) try: reader = C.reader(f) floats = [] for row in reader: floats.append(map(int, row)) finally: f.close() test_data = np.array(floats) #print test_data testlist = LinkedList() start = False stop = False count = 0 numb1 = 0 for data in test_data: testlist.appendLast(data) count = count + 1 if count == n: start = True if count == p: stop = True if start and not stop: data_list = [] data_list = testlist.printList() final_list = np.array(data_list) #print final_list value = model.score(np.array(data_list)) scorelist.append(value) testlist.deleteHead() numb1 = numb1 + 1 return scorelist
def testing(filename, n): scorelist = [] f = open(filename) try: reader = C.reader(f) floats = [] for row in reader: floats.append(map(int, row)) finally: f.close() test_data = np.array(floats) #print test_data testlist = LinkedList() start = False count = 0 numb1 = 0 for data in test_data: testlist.appendLast(data) count = count + 1 if count == n: start = True if start: data_list = [] data_list = testlist.printList() final_list = np.array(data_list) #print final_list value = model.score(np.array(data_list)) scorelist.append(value) testlist.deleteHead() numb1 = numb1 + 1 return scorelist
def testingHMM(self, filename, n, p, model): scorelist = [] normalizedScores = [] f = open(filename) try: reader = C.reader(f) floats = [] for row in reader: floats.append(map(int, row)) finally: f.close() test_data = np.array(floats) #print test_data testlist = LinkedList() start = False stop = False count = 0 numb1 = 0 points = 0 for data in test_data: testlist.appendLast(data) count = count + 1 if count == n: start = True if count == p: stop = True if start and not stop: data_list = [] data_list = testlist.printList() final_list = np.array(data_list) #print final_list value = model.score(np.array(data_list)) # if numb1 > 0: # lastval = scorelist[numb1-1] # norval = (lastval-value)/float(lastval) # normalizedScores.append(norval) # if norval > 0: # if points == 0: # start = count # points = points + 1 # if points > 30: # end = count # print "Start:" + str(start) + "End:" + str(end) # points = 0 scorelist.append(value) testlist.deleteHead() numb1 = numb1 + 1 return scorelist
try: reader = C.reader(f) floats = [] for row in reader: floats.append(map(int, row)) finally: f.close() test_data = np.array(floats) #print test_data testlist = LinkedList() start = False count = 0 numb = 0 for data in test_data: testlist.appendLast(data) count = count + 1 if count == 10: start = True if start: data_list = [] data_list = testlist.printList() final_list = np.array(data_list) print final_list value = model.score(np.array(data_list)) scorelist.append(value) testlist.deleteHead() numb = numb + 1 print count print testlist.size() #Anomaly