LogIntelligence / NeuralLog

Log-based Anomaly Detection Without Log Parsing (ASE 2021, Research Track)
MIT License
107 stars 36 forks source link

What does this "balance" function do? #4

Closed X-zhihao closed 1 year ago

X-zhihao commented 1 year ago
def balancing(x, y):
    print(y.count(0), y.count(1))
    if y.count(0) > y.count(1):
        pos_idx = [i for i, l in enumerate(y) if l == 1]
        neg_idx = [i for i, l in enumerate(y) if l == 0]
        pos_idx = shuffle(pos_idx)
        neg_idx = shuffle(neg_idx)
        neg_idx = neg_idx[:len(pos_idx) * 5]
        check_ids = [False] * len(x)
        for idx in pos_idx:
            check_ids[idx] = True
        for idx in neg_idx:
            check_ids[idx] = True
        x = [s for i, s in enumerate(x) if check_ids[i]]
        y = [s for i, s in enumerate(y) if check_ids[i]]

And

for idx in pos_idx:
            check_ids[idx] = True
        for idx in neg_idx:
            check_ids[idx] = True

Both “for” loops make check_ids[] equal to true, is that right?

X-zhihao commented 1 year ago

l know