def runOnSynth(): #reads data and parses first file in folder sd = readSynthetic(synthData[0]) #Running kcenterOut on the data kcent = kco.kcentersOut(sd.data, sd.k, sd.s) ans = kcent.kcentersOut() printSD(sd) kc.kCCost(sd.data, ans, sd.s)
def computeKCoutliers(synthD): num = 0 stats = [] for f in synthD: #reads data and parses first file in folder sd = readSynthetic(f) print("Iteration:", num) num += 1 for j in range(int(sd.k / 2)): sd.runk = sd.k + j precs = [] recs = [] for i in range(5): #Running kcenterOut on the data kcent = kco.kcentersOut(sd.data, sd.runk, sd.s) ans = kcent.kcentersOut() #Computing cost sd.costs.append(kc.kCCost(sd.data, ans, sd.s)) prec, rec = kc.kCPrecRecall(sd, ans) precs.append(prec) recs.append(rec) sd.precs = precs sd.recs = recs #example for adding extra stats, i.e. time. For headers, go to top sd.extrastats = [ mean(np.array(precs)), max(precs), mean(np.array(recs)), max(recs) ] printSD(sd) stats = addAnswer(stats, sd) sd.costs = [] return stats
def sampleReadData(): dataSynth = get_csv(synthData[0]) kcent = kco.kcentersOut(dataSynth, 10, 10.0) ans = kcent.kcentersOut() print(ans)